From 04c6c29bc11a4b22e0f93109970dbfda170d244a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Wed, 18 May 2022 16:21:04 +0200 Subject: [PATCH] feat: always open parameter variation configuration dialog when clicking on "var" button refs #537 --- .../param-field-line/param-field-line.component.ts | 12 ++++++++---- .../param-values/param-values.component.ts | 8 -------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/app/components/param-field-line/param-field-line.component.ts b/src/app/components/param-field-line/param-field-line.component.ts index 1cb5750c7..071aa1fd9 100644 --- a/src/app/components/param-field-line/param-field-line.component.ts +++ b/src/app/components/param-field-line/param-field-line.component.ts @@ -256,10 +256,14 @@ export class ParamFieldLineComponent implements OnChanges { if (oldValueMode !== ParamValueMode.MINMAX && oldValueMode !== ParamValueMode.LISTE) { this.param.valueMode = ParamValueMode.MINMAX; // min/max par défaut } - if (this._paramValuesComponent) { - // re-open modal when clicking the "var" mode button again (PoLS) - this._paramValuesComponent.openDialog(); - } + + // let framework create ParamValuesComponent instance and open dialog + setTimeout(() => { + if (this._paramValuesComponent) { + // re-open modal when clicking the "var" mode button again (PoLS) + this._paramValuesComponent.openDialog(); + } + }, 100); break; case "cal": diff --git a/src/app/components/param-values/param-values.component.ts b/src/app/components/param-values/param-values.component.ts index 05738ddc4..eeb36a21d 100644 --- a/src/app/components/param-values/param-values.component.ts +++ b/src/app/components/param-values/param-values.component.ts @@ -76,14 +76,6 @@ export class ParamValuesComponent implements AfterViewInit, Observer { } public ngAfterViewInit() { - // open dialog when switching to this mode, but only the first time this component is built, - // otherwise switching back from another calc tab will trigger the dialog again - if (this.param.valueMode === ParamValueMode.MINMAX && this.param.minValue === undefined) { - // use Promise trick to introduce a pseudo-timeout and avoid ExpressionChangedAfterItHasBeenCheckedError - Promise.resolve().then(() => { - this.openDialog(); - }); - } // subscribe to parameter values change (through dialog actions) this.param.addObserver(this); } -- GitLab