From 5f1900fc0746d74b0df7db8be64c506245835f4c Mon Sep 17 00:00:00 2001 From: "francois.grand" <francois.grand@irstea.fr> Date: Fri, 8 Jun 2018 15:52:45 +0200 Subject: [PATCH] =?UTF-8?q?=20#48=20composant=20ParamFieldLineComponent=20?= =?UTF-8?q?:=20ajout=20du=20bouton=20"li=C3=A9"=20(pour=20importer=20la=20?= =?UTF-8?q?valeur=20d'un=20autre=20param=C3=A8tre)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param-field-line.component.html | 6 +++ .../param-field-line.component.ts | 37 +++++++++++++++++++ src/app/formulaire/ngparam.ts | 10 ++++- src/locale/error_messages.en.json | 1 + src/locale/error_messages.fr.json | 1 + 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/app/components/param-field-line/param-field-line.component.html b/src/app/components/param-field-line/param-field-line.component.html index b50485252..67f7218c1 100644 --- a/src/app/components/param-field-line/param-field-line.component.html +++ b/src/app/components/param-field-line/param-field-line.component.html @@ -27,6 +27,12 @@ value="cal" (click)="onRadioClick('cal')" [checked]=radioCalCheck [disabled]=isDisabled id="radio_cal"> {{uitextParamCalculer}} </label> + + <!-- radio "lié" --> + <label *ngIf="hasRadioLink()" class="{{radioLinkClass}} h-75 px-3 py-3" [(ngModel)]="radioModel" mdbRadio="Right" name="radio_param_{{symbol}}" + value="link" (click)="onRadioClick('link')" [checked]=radioLinkCheck [disabled]=isDisabled id="radio_link"> + {{uitextParamLie}} + </label> </div> </div> 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 d43df61f3..68df687f3 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 @@ -5,6 +5,7 @@ import { NgParameter, ParamRadioConfig } from "../../formulaire/ngparam"; import { NgParamInputComponent } from "../ngparam-input/ngparam-input.component"; import { ServiceFactory } from "../../services/service-factory"; import { ParamValueMode } from "jalhyd"; +import { FormulaireService } from "../../services/formulaire/formulaire.service"; @Component({ selector: "param-field-line", @@ -51,8 +52,11 @@ export class ParamFieldLineComponent implements OnChanges { private intlService: InternationalisationService; + private _formService: FormulaireService; + constructor() { this.intlService = ServiceFactory.instance.internationalisationService; + this._formService = ServiceFactory.instance.formulaireService; this.onValid = new EventEmitter(); this.inputChange = new EventEmitter(); } @@ -78,6 +82,10 @@ export class ParamFieldLineComponent implements OnChanges { return this.intlService.localizeText("INFO_PARAMFIELD_PARAMCALCULER"); } + private get uitextParamLie() { + return this.intlService.localizeText("INFO_PARAMFIELD_PARAMLIE"); + } + /** * Parameter symbol (Q, Ks, B, ...) input attribute */ @@ -125,6 +133,13 @@ export class ParamFieldLineComponent implements OnChanges { } } + /** + * calcule la présence du radio "paramètre lié" (importé d'une autre calculette) + */ + private hasRadioLink(): boolean { + return this._formService.formulaires.length > 1; + } + /** * calcule l'état du radio "paramètre fixé" */ @@ -148,6 +163,15 @@ export class ParamFieldLineComponent implements OnChanges { return undefined; } + /** + * calcule l'état du radio "paramètre lié" + */ + private get radioLinkCheck(): string { + if (this._param.radioState == ParamRadioConfig.LINK) + return "checked"; + return undefined; + } + /** * retourne l'état du radio "paramètre fixé" sous forme booléenne */ @@ -185,6 +209,10 @@ export class ParamFieldLineComponent implements OnChanges { case "cal": this._param.valueMode = ParamValueMode.CALCUL; break; + + case "link": + this._param.valueMode = ParamValueMode.LINK; + break; } this.onRadio.emit({ @@ -240,6 +268,15 @@ export class ParamFieldLineComponent implements OnChanges { return ""; } + /** + * classe du radio "lié" + */ + private get radioLinkClass(): string { + if (this.on) + return this.radioLinkCheck == undefined ? this.offClass : this.onClass; + return ""; + } + /** * validité des saisies du composant */ diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index 552594bc4..aabda4d65 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -24,7 +24,12 @@ export enum ParamRadioConfig { /** * boutons radio "paramètre fixé", "paramètre à varier" et "paramètre à calculer" */ - CAL + CAL, + + /** + * boutons radio "paramètre fixé", "paramètre à varier" et "paramètre à calculer", "paramètre lié" + */ + LINK }; /** @@ -80,6 +85,9 @@ export class NgParameter extends InputField { case ParamValueMode.CALCUL: return ParamRadioConfig.CAL; + + case ParamValueMode.LINK: + return ParamRadioConfig.LINK; } } diff --git a/src/locale/error_messages.en.json b/src/locale/error_messages.en.json index f010427d9..985191346 100644 --- a/src/locale/error_messages.en.json +++ b/src/locale/error_messages.en.json @@ -33,6 +33,7 @@ "INFO_PARAMFIELD_PARAMFIXE": "Fixed", "INFO_PARAMFIELD_PARAMVARIER": "Vary", "INFO_PARAMFIELD_PARAMCALCULER": "Calculate", + "INFO_PARAMFIELD_PARAMLIE": "Link", "INFO_PARAMFIELD_VALEURMINI": "From minimum value", "INFO_PARAMFIELD_VALEURMAXI": "to maximum value", "INFO_PARAMFIELD_PASVARIATION": "with a variation step of:", diff --git a/src/locale/error_messages.fr.json b/src/locale/error_messages.fr.json index 69c3b8f87..4f7493d23 100644 --- a/src/locale/error_messages.fr.json +++ b/src/locale/error_messages.fr.json @@ -39,6 +39,7 @@ "INFO_PARAMFIELD_PARAMFIXE": "fixé", "INFO_PARAMFIELD_PARAMVARIER": "varier", "INFO_PARAMFIELD_PARAMCALCULER": "calculer", + "INFO_PARAMFIELD_PARAMLIE": "lié", "INFO_PARAMFIELD_VALEURMINI": "De la valeur minimum", "INFO_PARAMFIELD_VALEURMAXI": "à la valeur maximum", "INFO_PARAMFIELD_PASVARIATION": "avec un pas de :", -- GitLab