(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
This commit is contained in:
Cyprien P 2022-12-20 13:56:43 +01:00
parent 2a86cde474
commit 34b8dfa740

View File

@ -10,6 +10,7 @@ import {
createVisibleColFormatterRaw, createVisibleColFormatterRaw,
FullFormatterArgs FullFormatterArgs
} from 'app/common/ValueFormatter'; } from 'app/common/ValueFormatter';
import {createParser} from 'app/common/ValueParser';
import * as ko from 'knockout'; import * as ko from 'knockout';
// Column behavior type, used primarily in the UI. // 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. // Helper which adds/removes/updates column's displayCol to match the formula.
saveDisplayFormula(formula: string): Promise<void>|undefined; saveDisplayFormula(formula: string): Promise<void>|undefined;
createValueParser(): (value: string) => any;
} }
export function createColumnRec(this: ColumnRec, docModel: DocModel): void { 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.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'); this.behavior = ko.pureComputed(() => this.isEmpty() ? 'empty' : this.isFormula() ? 'formula' : 'data');
} }