(core) Fixes date formatting in range filter when column is hidden

Summary:
Range filter value parser was broken when the column was hiden in the
widget. In that case the column filter get passed a column record instead
of a view field record. Hence, the diff fixes the issue by adding a
`.createValueParser()` method to column record (ColumnRec).

https://gristlabs.getgrist.com/doc/check-ins/p/12#a1.s19.r2239.c19

Test Plan: Diff adds new nbrowser test.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3731
pull/383/head
Cyprien P 1 year ago
parent 2a86cde474
commit 34b8dfa740

@ -10,6 +10,7 @@ import {
createVisibleColFormatterRaw,
FullFormatterArgs
} from 'app/common/ValueFormatter';
import {createParser} from 'app/common/ValueParser';
import * as ko from 'knockout';
// Column behavior type, used primarily in the UI.
@ -78,6 +79,8 @@ export interface ColumnRec extends IRowModel<"_grist_Tables_column"> {
// Helper which adds/removes/updates column's displayCol to match the formula.
saveDisplayFormula(formula: string): Promise<void>|undefined;
createValueParser(): (value: string) => any;
}
export function createColumnRec(this: ColumnRec, docModel: DocModel): void {
@ -142,6 +145,11 @@ export function createColumnRec(this: ColumnRec, docModel: DocModel): void {
this.formatter = ko.pureComputed(() => formatterForRec(this, this, docModel, 'full'));
this.createValueParser = function() {
const parser = createParser(docModel.docData, this.id.peek());
return parser.cleanParse.bind(parser);
};
this.behavior = ko.pureComputed(() => this.isEmpty() ? 'empty' : this.isFormula() ? 'formula' : 'data');
}

Loading…
Cancel
Save