mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Value parsing for refs, parsing data entry for numbers
Summary: Handle reference columns in ViewFieldRec.valueParser. Extracted code for reuse from ReferenceEditor to look up values in the visible column. While I was at it, also extracted a bit of common code from ReferenceEditor and ReferenceListEditor into a new class ReferenceUtils. More refactoring could be done in this area but it's out of scope. Changed NTextEditor to use field.valueParser, which affects numeric and reference fields. In particular this means numbers are parsed on data entry, it doesn't change anything for references. Test Plan: Added more CopyPaste testing to test references. Tested entering slightly formatted numbers in NumberFormatting. Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3094
This commit is contained in:
@@ -159,6 +159,10 @@ export class TableData extends ActionDispatcher implements SkippableRows {
|
||||
return colData && index !== undefined ? colData.values[index] : undefined;
|
||||
}
|
||||
|
||||
public hasRowId(rowId: number): boolean {
|
||||
return this._rowMap.has(rowId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a column name, returns a function that takes a rowId and returns the value for that
|
||||
* column of that row. The returned function is faster than getValue() calls.
|
||||
|
||||
@@ -64,10 +64,11 @@ delete parsers.DateTime;
|
||||
|
||||
export function createParser(
|
||||
type: string, widgetOpts: FormatOptions, docSettings: DocumentSettings
|
||||
): ((value: string) => any) | undefined {
|
||||
): (value: string) => any {
|
||||
const cls = parsers[gristTypes.extractTypeFromColType(type)];
|
||||
if (cls) {
|
||||
const parser = new cls(type, widgetOpts, docSettings);
|
||||
return parser.cleanParse.bind(parser);
|
||||
}
|
||||
return value => value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user