From 47043f9435b3b07ea567634620205ec0a124cf5d Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Mon, 12 May 2025 10:01:34 -0400 Subject: conditionals --- .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx | 46 +++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx') diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx index e6db79339..1e54c0628 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx @@ -914,12 +914,30 @@ export class DocCreatorMenu extends ObservableReactComponent ); } + @observable private _newCondCache: Record = {}; + + getParams = (title: string, parameters?: Conditional): Conditional => { + if (parameters) return parameters; + + if (!this._newCondCache[title]) { + this._newCondCache[title] = observable({ + field: title, + operator: '=', + condition: '', + target: '', + attribute: '', + value: '' + }); + } + return this._newCondCache[title]; + }; + get dashboardContents() { const contentFieldTitles = this.fieldsInfos.filter(field => field.type !== TemplateFieldType.DATA).map(field => field.title).concat('Template'); const conditionForm = (title: string, parameters?: Conditional, empty: boolean = false) => { - const params: Conditional = parameters ?? this._currEditingConditional; + var params: Conditional = this.getParams(title, parameters); return (
@@ -937,31 +955,41 @@ export class DocCreatorMenu extends ObservableReactComponent className="form-row-textarea" onChange={e => runInAction(() => params.condition = e.target.value)} placeholder='value' - defaultValue={params.condition} + value={params.condition} />
then
- {params.target ?? 'Own'} + {params.target} {contentFieldTitles.map(fieldTitle =>
{params.target = fieldTitle}}>{fieldTitle === title ? 'Own' : fieldTitle}
)}
-