Add matrix-group display for monthly/quarterly time-series fields in Stage 5

This commit is contained in:
Joel Brock
2026-05-09 21:29:21 -07:00
parent 082238d884
commit da3e48a874
4 changed files with 268 additions and 4 deletions

View File

@@ -91,6 +91,39 @@ export interface FieldConfig {
optionGroupId?: number;
}
/**
* A repeating group of fields that share period axes — e.g. monthly sales
* targets across M1..M12, or quarterly margin across Q1..Q4. Rendered as a
* compact HTML table: rows are metrics, columns are periods.
*
* Underlying data flow is unchanged: each cell is still a regular form
* field (registered with react-hook-form, mapped to its own Civi custom
* field). The matrix is purely a display reorganization. Fields referenced
* in a matrix are skipped from the section's main per-field grid so they
* don't render twice.
*/
export interface MatrixGroupConfig {
/** Unique id within the section. */
id: string;
/** Heading shown above the table. */
label: string;
/** Optional intro paragraph below the heading. */
intro?: string;
/** Period columns, in left-to-right order. */
cols: Array<{ key: string; label: string }>;
/**
* Metric rows. `fields` is an array of form-side field names (the same
* `name` used in FieldConfig), one per column, in `cols` order.
* `type` controls the input rendering for this row's cells (currency,
* percent, number, etc).
*/
rows: Array<{
label: string;
type: FieldType;
fields: string[];
}>;
}
export interface StageSectionConfig {
/** Stage rank, 0..5. Used by the conditional engine and the accordion. */
rank: number;
@@ -107,6 +140,12 @@ export interface StageSectionConfig {
*/
visibleWhen?: VisibilityRule;
fields: FieldConfig[];
/**
* Matrix groups rendered above the per-field grid. Fields referenced in
* any matrix are excluded from the per-field grid (so a Y1 monthly sales
* target doesn't appear both in the table and as a standalone field).
*/
matrixGroups?: MatrixGroupConfig[];
}
export interface FormConfig {