mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
Adding sort order for filters
This commit is contained in:
@@ -230,9 +230,14 @@ export function formatterForRec(
|
||||
return func(args);
|
||||
}
|
||||
|
||||
export function labelsOrder(a: ColumnRec, b: ColumnRec): number {
|
||||
const left = a.label.peek().toLowerCase();
|
||||
const right = b.label.peek().toLowerCase();
|
||||
type ColumnInfo = {label: string}|{label: ko.Observable<string>};
|
||||
function peekLabel(info: ColumnInfo): string {
|
||||
return typeof info.label === 'string' ? info.label : info.label.peek();
|
||||
}
|
||||
|
||||
export function labelsOrder(a: ColumnInfo, b: ColumnInfo): number {
|
||||
const left = peekLabel(a).toLowerCase();
|
||||
const right = peekLabel(b).toLowerCase();
|
||||
|
||||
// Order is as follows:
|
||||
// - First columns with normal labels starting with a letter.
|
||||
|
||||
@@ -521,7 +521,7 @@ export function createViewSectionRec(this: ViewSectionRec, docModel: DocModel):
|
||||
const savedFiltersByColRef = new Map(this._savedFilters().all().map(f => [f.colRef(), f]));
|
||||
const viewFieldsByColRef = new Map(this.viewFields().all().map(f => [f.origCol().getRowId(), f]));
|
||||
|
||||
return this.columns().map(column => {
|
||||
return [...this.columns()].sort(labelsOrder).map(column => {
|
||||
const savedFilter = savedFiltersByColRef.get(column.origColRef());
|
||||
// Initialize with a saved filter, if one exists. Otherwise, use a blank filter.
|
||||
const filter = modelUtil.customComputed({
|
||||
|
||||
Reference in New Issue
Block a user