(core) Implement UI for trigger formulas.

Summary:
- Implement UI with "Apply to new records" and "Apply on record changes"
  checkboxes, and options for selecting which changes to recalculate on.
- For consistency, always represent empty RefList as None
- Fix up generated SchemaTypes to remember that values are encoded.

Included test cases for the main planned use cases:
- Auto-filled UUID column
- Data cleaning
- NOW() formula for record's last-updated timestamp.
- Updates that depend on other columns.

Test Plan: Added a browser test.

Reviewers: jarek

Reviewed By: jarek

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D2885
This commit is contained in:
Dmitry S
2021-06-29 00:47:59 -04:00
parent e180641c7d
commit b537539b73
12 changed files with 372 additions and 53 deletions

View File

@@ -226,6 +226,17 @@ export function getGristType(pureType: string): string {
}
}
/**
* Enum for values of columns' recalcWhen property, corresponding to Python definitions in
* schema.py.
*/
export enum RecalcWhen {
DEFAULT = 0, // Calculate on new records or when any field in recalcDeps changes.
NEVER = 1, // Don't calculate automatically (but user can trigger manually)
MANUAL_UPDATES = 2, // Calculate on new records and on manual updates to any data field.
}
/**
* Converts SQL type strings produced by the Sequelize library into its corresponding
* Grist type. The list of types is based on an analysis of SQL type string outputs

View File

@@ -31,7 +31,7 @@ export const schema = {
summarySourceCol : "Ref:_grist_Tables_column",
displayCol : "Ref:_grist_Tables_column",
visibleCol : "Ref:_grist_Tables_column",
recalcWhen : "Text",
recalcWhen : "Int",
recalcDeps : "RefList:_grist_Tables_column",
},
@@ -204,8 +204,8 @@ export interface SchemaTypes {
summarySourceCol: number;
displayCol: number;
visibleCol: number;
recalcWhen: string;
recalcDeps: number[];
recalcWhen: number;
recalcDeps: ['L', ...number[]]|null;
};
"_grist_Imports": {