mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add ChoiceList type, cell widget, and editor widget.
Summary: - Adds a new ChoiceList type, and widgets to view and edit it. - Store in SQLite as a JSON string - Support conversions between ChoiceList and other types Test Plan: Added browser tests, and a test for how these values are stored Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2803
This commit is contained in:
@@ -3,7 +3,8 @@ import isString = require('lodash/isString');
|
||||
|
||||
// tslint:disable:object-literal-key-quotes
|
||||
|
||||
export type GristType = 'Any' | 'Attachments' | 'Blob' | 'Bool' | 'Choice' | 'Date' | 'DateTime' |
|
||||
export type GristType = 'Any' | 'Attachments' | 'Blob' | 'Bool' | 'Choice' | 'ChoiceList' |
|
||||
'Date' | 'DateTime' |
|
||||
'Id' | 'Int' | 'ManualSortPos' | 'Numeric' | 'PositionNumber' | 'Ref' | 'RefList' | 'Text';
|
||||
|
||||
export type GristTypeInfo =
|
||||
@@ -41,6 +42,7 @@ const _defaultValues: {[key in GristType]: [CellValue, string]} = {
|
||||
// Bool is only supported by SQLite as 0 and 1 values.
|
||||
'Bool': [ false, "0" ],
|
||||
'Choice': [ '', "''" ],
|
||||
'ChoiceList': [ null, "NULL" ],
|
||||
'Date': [ null, "NULL" ],
|
||||
'DateTime': [ null, "NULL" ],
|
||||
'Id': [ 0, "0" ],
|
||||
@@ -187,7 +189,8 @@ const rightType: {[key in GristType]: (value: CellValue) => boolean} = {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
ChoiceList: isListOrNull,
|
||||
};
|
||||
|
||||
export function isRightType(type: string): undefined | ((value: CellValue, options?: any) => boolean) {
|
||||
|
||||
Reference in New Issue
Block a user