gristlabs_grist-core/app/common/ColumnGetters.ts
Jarosław Sadziński 3c72639e25 (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
2021-11-03 15:31:39 +01:00

30 lines
842 B
TypeScript

import { Sort } from 'app/common/SortSpec';
/**
*
* An interface for accessing the columns of a table by their
* ID in _grist_Tables_column, which is the ID used in sort specifications.
* Implementations of this interface can be supplied to SortFunc to
* sort the rows of a table according to such a specification.
*
*/
export interface ColumnGetters {
/**
*
* Takes a _grist_Tables_column ID and returns a function that maps
* rowIds to values for that column. Those values should be display
* values if available, drawn from a corresponding display column.
*
*/
getColGetter(spec: Sort.ColSpec): ColumnGetter | null;
/**
*
* Returns a getter for the manual sort column if it is available.
*
*/
getManualSortGetter(): ColumnGetter | null;
}
export type ColumnGetter = (rowId: number) => any;