mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Suggest correct table when converting to RefList
Summary: RecordSets now have new encoding and rendering analogous to Records: `['r', 'Table', [1, 2, 3]]` and `Table[[1, 2, 3]]`. Test Plan: Added to nbrowser/TypeChange.ts. Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2987
This commit is contained in:
@@ -24,6 +24,7 @@ export const enum GristObjCode {
|
||||
Skip = 'S',
|
||||
Censored = 'C',
|
||||
Reference = 'R',
|
||||
ReferenceList = 'r',
|
||||
Exception = 'E',
|
||||
Pending = 'P',
|
||||
Unmarshallable = 'U',
|
||||
@@ -142,10 +143,34 @@ export function isCensored(value: CellValue): value is [GristObjCode.Censored] {
|
||||
/**
|
||||
* Returns whether a value (as received in a DocAction) represents a list.
|
||||
*/
|
||||
export function isList(value: CellValue): value is [GristObjCode.List, ...unknown[]] {
|
||||
export function isList(value: CellValue): value is [GristObjCode.List, ...CellValue[]] {
|
||||
return Array.isArray(value) && value[0] === GristObjCode.List;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a value (as received in a DocAction) represents a reference to a record.
|
||||
*/
|
||||
export function isReference(value: CellValue): value is [GristObjCode.Reference, string, number] {
|
||||
return Array.isArray(value) && value[0] === GristObjCode.Reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a value (as received in a DocAction) represents a reference list (RecordSet).
|
||||
*/
|
||||
export function isReferenceList(value: CellValue): value is [GristObjCode.ReferenceList, string, number[]] {
|
||||
return Array.isArray(value) && value[0] === GristObjCode.ReferenceList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a value (as received in a DocAction) represents a reference or reference list.
|
||||
*/
|
||||
export function isReferencing(value: CellValue):
|
||||
value is [GristObjCode.ReferenceList|GristObjCode.Reference, string, number[]|number]
|
||||
{
|
||||
return Array.isArray(value) &&
|
||||
(value[0] === GristObjCode.ReferenceList || value[0] === GristObjCode.Reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a value (as received in a DocAction) represents a list or is null,
|
||||
* which is a valid value for list types in grist.
|
||||
|
||||
Reference in New Issue
Block a user