mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(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:
@@ -36,6 +36,8 @@ import {createValidationRec, ValidationRec} from 'app/client/models/entities/Val
|
||||
import {createViewFieldRec, ViewFieldRec} from 'app/client/models/entities/ViewFieldRec';
|
||||
import {createViewRec, ViewRec} from 'app/client/models/entities/ViewRec';
|
||||
import {createViewSectionRec, ViewSectionRec} from 'app/client/models/entities/ViewSectionRec';
|
||||
import {GristObjCode} from 'app/plugin/GristData';
|
||||
import {decodeObject} from 'app/plugin/objtypes';
|
||||
|
||||
// Re-export all the entity types available. The recommended usage is like this:
|
||||
// import {ColumnRec, ViewFieldRec} from 'app/client/models/DocModel';
|
||||
@@ -95,6 +97,24 @@ export function refRecord<TRow extends MetaRowModel>(
|
||||
return ko.pureComputed(() => tableModel.getRowModel(rowIdObs() || 0, true));
|
||||
}
|
||||
|
||||
type RefListValue = [GristObjCode.List, ...number[]]|null;
|
||||
/**
|
||||
* Returns an observable with a list of records from another table, selected using RefList column.
|
||||
* @param {TableModel} tableModel: The model for the table to return a record from.
|
||||
* @param {ko.observable} rowsIdObs: An observable with a RefList value.
|
||||
*/
|
||||
export function refListRecords<TRow extends MetaRowModel>(
|
||||
tableModel: MetaTableModel<TRow>, rowsIdObs: ko.Observable<RefListValue>|ko.Computed<RefListValue>
|
||||
) {
|
||||
return ko.pureComputed(() => {
|
||||
const ids = decodeObject(rowsIdObs()) as number[]|null;
|
||||
if (!Array.isArray(ids)) {
|
||||
return [];
|
||||
}
|
||||
return ids.map(id => tableModel.getRowModel(id, true));
|
||||
});
|
||||
}
|
||||
|
||||
// Use an alias for brevity.
|
||||
type MTM<RowModel extends MetaRowModel> = MetaTableModel<RowModel>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user