(core) Adding sort options for columns.

Summary:
Adding sort options for columns.
- Sort menu has a new option "More sort options" that opens up Sort left menu
- Each sort entry has an additional menu with 3 options
-- Order by choice index (for the Choice column, orders by choice position)
-- Empty last (puts empty values last in ascending order, first in descending order)
-- Natural sort (for Text column, compares strings with numbers as numbers)
Updated also CSV/Excel export and api sorting.
Most of the changes in this diff is a sort expression refactoring. Pulling out all the methods
that works on sortExpression array into a single namespace.

Test Plan: Browser tests

Reviewers: alexmojaki

Reviewed By: alexmojaki

Subscribers: dsagal, alexmojaki

Differential Revision: https://phab.getgrist.com/D3077
This commit is contained in:
Jarosław Sadziński
2021-11-03 12:44:28 +01:00
parent 0f946616b6
commit 3c72639e25
20 changed files with 992 additions and 267 deletions

View File

@@ -1,3 +1,5 @@
import { Sort } from 'app/common/SortSpec';
/**
*
* An interface for accessing the columns of a table by their
@@ -7,7 +9,6 @@
*
*/
export interface ColumnGetters {
/**
*
* Takes a _grist_Tables_column ID and returns a function that maps
@@ -15,12 +16,14 @@ export interface ColumnGetters {
* values if available, drawn from a corresponding display column.
*
*/
getColGetter(colRef: number): ((rowId: number) => any) | null;
getColGetter(spec: Sort.ColSpec): ColumnGetter | null;
/**
*
* Returns a getter for the manual sort column if it is available.
*
*/
getManualSortGetter(): ((rowId: number) => any) | null;
getManualSortGetter(): ColumnGetter | null;
}
export type ColumnGetter = (rowId: number) => any;