mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-20 17:14:11 +00:00
7fe4423a6f
Summary: Existing filters are now moved out of fields and into a new metadata table for filters, and the client is updated to retrieve/update/save filters from the new table. This enables storing of filters for columns that don't have fields (notably, hidden columns). Test Plan: Browser and server tests. Reviewers: jarek Reviewed By: jarek Differential Revision: https://phab.getgrist.com/D3138
23 lines
956 B
TypeScript
23 lines
956 B
TypeScript
import {ColumnRec, DocModel, IRowModel, refRecord, ViewSectionRec} from 'app/client/models/DocModel';
|
|
import * as modelUtil from 'app/client/models/modelUtil';
|
|
import * as ko from 'knockout';
|
|
|
|
// Represents a column filter for a view section.
|
|
export interface FilterRec extends IRowModel<"_grist_Filters"> {
|
|
viewSection: ko.Computed<ViewSectionRec>;
|
|
column: ko.Computed<ColumnRec>;
|
|
|
|
// Observable for the parsed filter object.
|
|
activeFilter: modelUtil.CustomComputed<string>;
|
|
}
|
|
|
|
export function createFilterRec(this: FilterRec, docModel: DocModel): void {
|
|
this.viewSection = refRecord(docModel.viewSections, this.viewSectionRef);
|
|
this.column = refRecord(docModel.columns, this.colRef);
|
|
|
|
// Observable for the active filter that's initialized from the value saved to the server.
|
|
this.activeFilter = modelUtil.customComputed({
|
|
read: () => { const f = this.filter(); return f === 'null' ? '' : f; }, // To handle old empty filters.
|
|
});
|
|
}
|