From 228156af58b30471f3a4e7c528b72053837ff19b Mon Sep 17 00:00:00 2001 From: Jean-Pascal <jean-pascal.aubry@inrae.fr> Date: Wed, 27 Mar 2024 13:17:09 +0000 Subject: [PATCH 1/2] fix: emit validity when value mode is set to link Refs #665 --- .../param-link/param-link.component.ts | 87 ++++++++++--------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/src/app/components/param-link/param-link.component.ts b/src/app/components/param-link/param-link.component.ts index bf8f08cee..3d7578901 100644 --- a/src/app/components/param-link/param-link.component.ts +++ b/src/app/components/param-link/param-link.component.ts @@ -104,8 +104,13 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { public get currentLinkedParam(): LinkedValue { if (this._linkableParams !== undefined) { if (this._currentIndex !== -1 && this._currentIndex < this._linkableParams.length) { + this.change.emit ({ + action: "valid", + value: true, + }); return this._linkableParams[this._currentIndex]; } + } } @@ -182,47 +187,47 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { , (pos + 1) ); } else - // 2. Paramètre / résultat d'une section dans un Nub de type SectionNub - if (i.nub instanceof acSection) { - if (i.isResult()) { - // résultat de section - return `${preview} - ` + sprintf( - this.intlService.localizeText("INFO_LINKED_VALUE_SECTION_RESULT"), - s, c - ); - } else { - // paramètre de section - return `${preview} - ` + sprintf( - this.intlService.localizeText("INFO_LINKED_VALUE_SECTION"), - s, c - ); - } - } else - // 3. Résultat - if (i.isResult()) { - return `${preview} - ` + sprintf( - this.intlService.localizeText("INFO_LINKED_VALUE_RESULT"), - s, c - ); - } else - // 4. Résultat complémentaire - if (i.isExtraResult()) { - if (i.meta["result"]) { - // @TODO not used ? - return `${preview} - ` + sprintf( - this.intlService.localizeText("INFO_LINKED_VALUE_EXTRA_RESULT_OF"), - s, c, i.meta["result"] - ); - } else { - return `${preview} - ` + sprintf( - this.intlService.localizeText("INFO_LINKED_VALUE_EXTRA_RESULT"), - s, c - ); - } - } else { - // 5. Paramètre (cas général) - return `${preview} - ${s} (${c})`; - } + // 2. Paramètre / résultat d'une section dans un Nub de type SectionNub + if (i.nub instanceof acSection) { + if (i.isResult()) { + // résultat de section + return `${preview} - ` + sprintf( + this.intlService.localizeText("INFO_LINKED_VALUE_SECTION_RESULT"), + s, c + ); + } else { + // paramètre de section + return `${preview} - ` + sprintf( + this.intlService.localizeText("INFO_LINKED_VALUE_SECTION"), + s, c + ); + } + } else + // 3. Résultat + if (i.isResult()) { + return `${preview} - ` + sprintf( + this.intlService.localizeText("INFO_LINKED_VALUE_RESULT"), + s, c + ); + } else + // 4. Résultat complémentaire + if (i.isExtraResult()) { + if (i.meta["result"]) { + // @TODO not used ? + return `${preview} - ` + sprintf( + this.intlService.localizeText("INFO_LINKED_VALUE_EXTRA_RESULT_OF"), + s, c, i.meta["result"] + ); + } else { + return `${preview} - ` + sprintf( + this.intlService.localizeText("INFO_LINKED_VALUE_EXTRA_RESULT"), + s, c + ); + } + } else { + // 5. Paramètre (cas général) + return `${preview} - ${s} (${c})`; + } } /** -- GitLab From f3d77107826eec7b0484ce0fcb3cf49a1551403a Mon Sep 17 00:00:00 2001 From: Jean-Pascal <jean-pascal.aubry@inrae.fr> Date: Wed, 27 Mar 2024 13:18:39 +0000 Subject: [PATCH 2/2] fix: update model validity when value mode change Refs #665 --- src/app/components/ngparam-input/ngparam-input.component.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/components/ngparam-input/ngparam-input.component.ts b/src/app/components/ngparam-input/ngparam-input.component.ts index c5d6d9809..0947021ae 100644 --- a/src/app/components/ngparam-input/ngparam-input.component.ts +++ b/src/app/components/ngparam-input/ngparam-input.component.ts @@ -150,6 +150,11 @@ export class NgParamInputComponent extends GenericInputComponentDirective implem // changement de valueMode du paramètre ou de valeur à laquelle il est lié case "valueModeChange": + if (this._tmp !== data["value"]) { + this._tmp = data["value"]; + this.updateAndValidateUI(); + this.updateModelFromUI() + } case "valueLinkChange": if (this._tmp !== data["value"]) { this._tmp = data["value"]; -- GitLab