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 b504852524f154d58adcfce7ab77d1030ab30036..67f7218c1d5b7d14bcf1aae3313ed8358b8cfa31 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 d43df61f3c4f4a7bd72b86cee476ccf4f992d039..68df687f38b75fc745a27517f4a981572fca2e30 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 552594bc42c3db2db734a7d87c08b1c3fa49f523..aabda4d6525e709f8cd83384fec38c9fa04e1c78 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 f010427d9b99184f4cb50a6616c3fb84cfa07578..985191346b4255111ce457b26b637751507cef37 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 69c3b8f87818a462c62e51496a1492691a69e19f..4f7493d23d40be7cb8fc2faf3ae577e2c0b2f2c1 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 :",