From 34b8dfa7409e999a2f70156e2af48d1de4d327c6 Mon Sep 17 00:00:00 2001 From: Cyprien P Date: Tue, 20 Dec 2022 13:56:43 +0100 Subject: [PATCH] (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 --- app/client/models/entities/ColumnRec.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/client/models/entities/ColumnRec.ts b/app/client/models/entities/ColumnRec.ts index 71c67f2a..39cde785 100644 --- a/app/client/models/entities/ColumnRec.ts +++ b/app/client/models/entities/ColumnRec.ts @@ -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|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'); }