gristlabs_grist-core/app/plugin/GristData.ts
Alex Hall ecb30eebb8 (core) Parsing multiple values in reflists, parsing refs without table data in client
Summary:
Added a new object type code `l` (for lookup) which can be used in user actions as a temporary cell value in ref[list] columns and is immediately converted to a row ID in the data engine. The value contains the original raw string (to be used as alt text), the column ID to lookup (typically the visible column) and one or more values to lookup.

For reflists, valueParser now tries parsing the string first as JSON, then as a CSV row, and applies the visible column parsed to each item.

Both ref and reflists columns no longer format the parsed value when there's no matching reference, the original unparsed string is used as alttext instead.

Test Plan: Added another table "Multi-References" to CopyPaste test. Made that table and the References table test with and without table data loaded in the browser.

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D3118
2021-11-09 14:41:04 +02:00

24 lines
589 B
TypeScript

// Letter codes for CellValue types encoded as [code, args...] tuples.
export const enum GristObjCode {
List = 'L',
LookUp = 'l',
Dict = 'O',
DateTime = 'D',
Date = 'd',
Skip = 'S',
Censored = 'C',
Reference = 'R',
ReferenceList = 'r',
Exception = 'E',
Pending = 'P',
Unmarshallable = 'U',
Versions = 'V',
}
export type CellValue = number|string|boolean|null|[GristObjCode, ...unknown[]];
export interface RowRecord {
id: number;
[colId: string]: CellValue;
}