mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Polish and enable Reference List widget
Summary: Adds Reference List as a widget type. Reference List is similar to Choice List: multiple references can be added to each cell through a similar editor, and the individual references will always reflect their current value from the referenced table. Test Plan: Browser tests. Reviewers: dsagal Reviewed By: dsagal Subscribers: paulfitz, jarek, alexmojaki, dsagal Differential Revision: https://phab.getgrist.com/D2959
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { CellValue } from "app/common/DocActions";
|
||||
import { FilterState, makeFilterState } from "app/common/FilterState";
|
||||
import { decodeObject } from "app/plugin/objtypes";
|
||||
import { isList } from "./gristTypes";
|
||||
import { isList, isRefListType } from "./gristTypes";
|
||||
|
||||
export type ColumnFilterFunc = (value: CellValue) => boolean;
|
||||
|
||||
@@ -13,7 +13,7 @@ export function makeFilterFunc({ include, values }: FilterState,
|
||||
// For example, a TypeError in the formula column and the string '["E","TypeError"]' would be seen as the same.
|
||||
// TODO: This narrow corner case seems acceptable for now, but may be worth revisiting.
|
||||
return (val: CellValue) => {
|
||||
if (isList(val) && columnType === 'ChoiceList') {
|
||||
if (isList(val) && (columnType === 'ChoiceList' || isRefListType(String(columnType)))) {
|
||||
const list = decodeObject(val) as unknown[];
|
||||
return list.some(item => values.has(item as any) === include);
|
||||
}
|
||||
|
||||
@@ -329,6 +329,10 @@ export function getReferencedTableId(type: string) {
|
||||
return removePrefix(type, "Ref:") || removePrefix(type, "RefList:");
|
||||
}
|
||||
|
||||
export function isFullReferencingType(type: string) {
|
||||
return type.startsWith('Ref:') || type.startsWith('RefList:');
|
||||
export function isRefListType(type: string) {
|
||||
return type.startsWith('RefList:');
|
||||
}
|
||||
|
||||
export function isFullReferencingType(type: string) {
|
||||
return type.startsWith('Ref:') || isRefListType(type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user