(core) Conditional formatting rules

Summary:
Adding conditional formatting rules feature.

Each column can have multiple styling rules which are applied in order
when evaluated to a truthy value.

- The creator panel has a new section: Cell Style
- New user action AddEmptyRule for adding an empty rule
- New columns in _grist_Table_columns and fields

A new color picker will be introduced in a follow-up diff (as it is also
used in choice/choice list/filters).

Design document:
https://grist.quip.com/FVzfAgoO5xOF/Conditional-Formatting-Implementation-Design

Test Plan: new tests

Reviewers: georgegevoian

Reviewed By: georgegevoian

Subscribers: alexmojaki

Differential Revision: https://phab.getgrist.com/D3282
This commit is contained in:
Jarosław Sadziński
2022-03-22 14:41:11 +01:00
parent 96a34122a5
commit b1c3943bf4
25 changed files with 952 additions and 231 deletions

View File

@@ -341,3 +341,9 @@ export function isRefListType(type: string) {
export function isFullReferencingType(type: string) {
return type.startsWith('Ref:') || isRefListType(type);
}
export function isValidRuleValue(value: CellValue|undefined) {
// We want to strictly test if a value is boolean, when the value is 0 or 1 it might
// indicate other number in the future.
return value === null || typeof value === 'boolean';
}

View File

@@ -4,7 +4,7 @@ import { GristObjCode } from "app/plugin/GristData";
// tslint:disable:object-literal-key-quotes
export const SCHEMA_VERSION = 26;
export const SCHEMA_VERSION = 27;
export const schema = {
@@ -38,6 +38,7 @@ export const schema = {
summarySourceCol : "Ref:_grist_Tables_column",
displayCol : "Ref:_grist_Tables_column",
visibleCol : "Ref:_grist_Tables_column",
rules : "RefList:_grist_Tables_column",
recalcWhen : "Int",
recalcDeps : "RefList:_grist_Tables_column",
},
@@ -125,6 +126,7 @@ export const schema = {
displayCol : "Ref:_grist_Tables_column",
visibleCol : "Ref:_grist_Tables_column",
filter : "Text",
rules : "RefList:_grist_Tables_column",
},
"_grist_Validations": {
@@ -226,6 +228,7 @@ export interface SchemaTypes {
summarySourceCol: number;
displayCol: number;
visibleCol: number;
rules: [GristObjCode.List, ...number[]]|null;
recalcWhen: number;
recalcDeps: [GristObjCode.List, ...number[]]|null;
};
@@ -313,6 +316,7 @@ export interface SchemaTypes {
displayCol: number;
visibleCol: number;
filter: string;
rules: [GristObjCode.List, ...number[]]|null;
};
"_grist_Validations": {