(core) Preventing empty string update on any column.

Summary: When editor is opened on any column and closed without entering any value, the column is converted to a text column.

Test Plan: browser tests

Reviewers: alexmojaki

Reviewed By: alexmojaki

Differential Revision: https://phab.getgrist.com/D3211
This commit is contained in:
Jarosław Sadziński 2022-01-11 14:33:07 +01:00
parent 3facb2a7cd
commit 5a876976d5

View File

@ -32,6 +32,17 @@ export class ValueParser {
}
/**
* Same as basic Value parser, but will return null if a value is an empty string.
*/
class NullIfEmptyParser extends ValueParser {
public cleanParse(value: string): any {
if (value === "") {
return null;
}
return super.cleanParse(value);
}
}
export class NumericParser extends ValueParser {
private _parse: NumberParse;
@ -206,6 +217,7 @@ export class ReferenceListParser extends ReferenceParser {
}
export const valueParserClasses: { [type: string]: typeof ValueParser } = {
Any: NullIfEmptyParser,
Numeric: NumericParser,
Int: NumericParser,
Date: DateParser,