From ede1823b32259e3f6fee81d72a43f4b6314ebfff Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Mon, 14 Jan 2019 16:34:44 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9solution=20bug:=20les=20param=C3=A8tres?= =?UTF-8?q?=20li=C3=A9s=20sont=20r=C3=A9cup=C3=A9r=C3=A9s=20correctement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + nettoyage code (tslint) --- .../field-set/field-set.component.html | 2 +- .../field-set/field-set.component.ts | 6 +- .../fieldset-container.component.html | 2 +- .../ngparam-input/ngparam-input.component.ts | 13 ++-- .../param-field-line.component.html | 4 +- .../param-field-line.component.ts | 76 ++++++++++--------- .../param-link/param-link.component.ts | 74 +++++++++--------- .../param-values/param-values.component.html | 2 +- .../param-values/param-values.component.ts | 48 ++++++------ .../param-values/value-list.component.ts | 10 +-- .../definition/form-def-fixedvar.ts | 5 +- .../formulaire/definition/form-definition.ts | 2 +- src/app/formulaire/ngparam.ts | 3 +- 13 files changed, 124 insertions(+), 123 deletions(-) diff --git a/src/app/components/field-set/field-set.component.html b/src/app/components/field-set/field-set.component.html index e52261b00..a372d6811 100644 --- a/src/app/components/field-set/field-set.component.html +++ b/src/app/components/field-set/field-set.component.html @@ -21,7 +21,7 @@ --> <ng-template ngFor let-p [ngForOf]="fields"> - <param-field-line *ngIf="isInputField(p)" [param]=p (onRadio)=onRadioClick($event) (onValid)=onParamLineValid() (inputChange)=onInputChange()> + <param-field-line *ngIf="isInputField(p)" [param]=p (onRadio)=onRadioClick($event) (valid)=onParamLineValid() (inputChange)=onInputChange()> </param-field-line> <select-field-line *ngIf="isSelectField(p)" [_select]=p> diff --git a/src/app/components/field-set/field-set.component.ts b/src/app/components/field-set/field-set.component.ts index 08679afc9..bacdb00a9 100644 --- a/src/app/components/field-set/field-set.component.ts +++ b/src/app/components/field-set/field-set.component.ts @@ -49,10 +49,10 @@ export class FieldSetComponent implements DoCheck { } public get title(): string { - if (this._fieldSet == undefined) { + if (! this._fieldSet) { return "fs undefined"; } - if (this._fieldSet.label == undefined) { + if (! this._fieldSet.label) { // @TODO allow "" ? return "label undefined"; } return this._fieldSet.label; @@ -234,7 +234,7 @@ export class FieldSetComponent implements DoCheck { private updateValidity() { this._isValid = false; - if (this._paramComponents != undefined) { + if (this._paramComponents) { this._isValid = this._paramComponents.reduce( // callback ( diff --git a/src/app/components/fieldset-container/fieldset-container.component.html b/src/app/components/fieldset-container/fieldset-container.component.html index 8655d7213..086ed2ba2 100644 --- a/src/app/components/fieldset-container/fieldset-container.component.html +++ b/src/app/components/fieldset-container/fieldset-container.component.html @@ -3,7 +3,7 @@ <h4 class="col">{{ title }}</h4> </div> - <field-set *ngFor="let fs of fieldsets" [fieldSet]=fs (onRadio)=onRadioClick($event) (onValid)=onFieldsetValid() (inputChange)=onInputChange() + <field-set *ngFor="let fs of fieldsets" [fieldSet]=fs (onRadio)=onRadioClick($event) (valid)=onFieldsetValid() (inputChange)=onInputChange() (addFieldset)=onAddFieldset($event) (removeFieldset)=onRemoveFieldset($event) (moveFieldsetUp)=onMoveFieldsetUp($event) (moveFieldsetDown)=onMoveFieldsetDown($event)> </field-set> diff --git a/src/app/components/ngparam-input/ngparam-input.component.ts b/src/app/components/ngparam-input/ngparam-input.component.ts index 1e8aea960..b02a87cf8 100644 --- a/src/app/components/ngparam-input/ngparam-input.component.ts +++ b/src/app/components/ngparam-input/ngparam-input.component.ts @@ -1,7 +1,6 @@ // cf. https://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html -import { Component, Input, forwardRef, OnInit, DoCheck, ChangeDetectorRef } from "@angular/core"; -import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl } from "@angular/forms"; +import { Component, ChangeDetectorRef, OnDestroy } from "@angular/core"; import { NumericalString, Message, Observer } from "jalhyd"; @@ -13,7 +12,7 @@ import { GenericInputComponent } from "../generic-input/generic-input.component" selector: "ngparam-input", templateUrl: "../generic-input/generic-input.component.html" }) -export class NgParamInputComponent extends GenericInputComponent implements Observer { +export class NgParamInputComponent extends GenericInputComponent implements Observer, OnDestroy { /** * paramètre géré */ @@ -35,7 +34,7 @@ export class NgParamInputComponent extends GenericInputComponent implements Obse * appelé avant le changement de modèle */ protected beforeSetModel() { - if (this._paramDef != undefined) { + if (this._paramDef) { this._paramDef.removeObserver(this); } } @@ -44,7 +43,7 @@ export class NgParamInputComponent extends GenericInputComponent implements Obse * appelé après le changement de modèle */ protected afterSetModel() { - if (this._paramDef != undefined) { + if (this._paramDef) { if (this._paramDef.isDefined) { this._tmp = this._paramDef.getValue(); } @@ -66,10 +65,10 @@ export class NgParamInputComponent extends GenericInputComponent implements Obse } protected validateModelValue(v: any): { isValid: boolean, message: string } { - let msg; + let msg: string; let valid = false; - if (this._paramDef == undefined) { + if (! this._paramDef) { msg = "internal error, model undefined"; } else { try { 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 9e20986da..b8d75ac73 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 @@ -37,7 +37,7 @@ </div> <!-- composant pour gérer le cas "paramètre à varier" (min-max/liste de valeurs) --> -<param-values *ngIf="isRadioVarChecked" [param]="_param" (onValid)=onParamValuesValid($event)></param-values> +<param-values *ngIf="isRadioVarChecked" [param]="param" (valid)=onParamValuesValid($event)></param-values> <!-- composant pour gérer le cas "paramètre lié" --> -<param-link *ngIf="isRadioLinkChecked" [param]="_param" (onValid)=onParamValuesValid($event)></param-link> \ No newline at end of file +<param-link *ngIf="isRadioLinkChecked" [param]="param" (valid)=onParamValuesValid($event)></param-link> \ No newline at end of file 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 fb0daa303..ab389e306 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 @@ -33,17 +33,17 @@ export class ParamFieldLineComponent implements OnChanges { constructor() { this.intlService = ServiceFactory.instance.internationalisationService; this._formService = ServiceFactory.instance.formulaireService; - this.onValid = new EventEmitter(); + this.valid = new EventEmitter(); this.inputChange = new EventEmitter(); } public get title(): string { let t = ""; - if (this._param.label != undefined) { - t = this._param.label; + if (this.param.label !== undefined) { + t = this.param.label; } - if (this._param.unit != undefined && this._param.unit != "") { - t = t + " (" + this._param.unit + ")"; + if (this.param.unit !== undefined && this.param.unit !== "") { + t = t + " (" + this.param.unit + ")"; } return t; } @@ -68,7 +68,7 @@ export class ParamFieldLineComponent implements OnChanges { * Parameter symbol (Q, Ks, B, ...) input attribute */ private get symbol(): string { - return this._param.symbol; + return this.param.symbol; } /** @@ -89,7 +89,7 @@ export class ParamFieldLineComponent implements OnChanges { * calcule l'état du radio "paramètre à calculer" */ private get radioCalCheck(): string { - if (this._param.radioState == ParamRadioConfig.CAL) { + if (this.param.radioState === ParamRadioConfig.CAL) { return "checked"; } return undefined; @@ -99,7 +99,7 @@ export class ParamFieldLineComponent implements OnChanges { * calcule l'état du radio "paramètre lié" */ private get radioLinkCheck(): string { - if (this._param.radioState == ParamRadioConfig.LINK) { + if (this.param.radioState === ParamRadioConfig.LINK) { return "checked"; } return undefined; @@ -109,39 +109,40 @@ export class ParamFieldLineComponent implements OnChanges { * retourne l'état du radio "paramètre fixé" sous forme booléenne */ public get isRadioFixChecked(): boolean { - return this._param.radioState == ParamRadioConfig.FIX; + return this.param.radioState === ParamRadioConfig.FIX; } /** * retourne l'état du radio "paramètre à varier" sous forme booléenne */ public get isRadioVarChecked(): boolean { - return this._param.radioState == ParamRadioConfig.VAR; + return this.param.radioState === ParamRadioConfig.VAR; } /** * retourne l'état du radio "paramètre lié" sous forme booléenne */ public get isRadioLinkChecked(): boolean { - return this._param.radioState == ParamRadioConfig.LINK; + return this.param.radioState === ParamRadioConfig.LINK; } /** * désactivation de tous les boutons radio si paramètre par défaut à "CAL" */ private get isDisabled(): boolean { - return this._param.isDefault && this._param.radioState == ParamRadioConfig.CAL; + return this.param.isDefault && this.param.radioState === ParamRadioConfig.CAL; } /** * désactivation du champ de saisie */ public get isInputDisabled(): boolean { - return this._param.radioState != ParamRadioConfig.FIX; + return this.param.radioState !== ParamRadioConfig.FIX; } + private get radioFixClass(): string { if (this.on) { - return this.radioFixCheck == undefined ? this.offClass : this.onClass; + return this.radioFixCheck ? this.onClass : this.offClass; } return ""; } @@ -151,7 +152,7 @@ export class ParamFieldLineComponent implements OnChanges { */ private get radioVarClass(): string { if (this.on) { - return this.radioVarCheck == undefined ? this.offClass : this.onClass; + return this.radioVarCheck ? this.onClass : this.offClass; } return ""; } @@ -161,7 +162,7 @@ export class ParamFieldLineComponent implements OnChanges { */ private get radioCalClass(): string { if (this.on) { - return this.radioCalCheck == undefined ? this.offClass : this.onClass; + return this.radioCalCheck ? this.onClass : this.offClass; } return ""; } @@ -171,7 +172,7 @@ export class ParamFieldLineComponent implements OnChanges { */ private get radioLinkClass(): string { if (this.on) { - return this.radioLinkCheck == undefined ? this.offClass : this.onClass; + return this.radioLinkCheck ? this.onClass : this.offClass; } return ""; } @@ -180,7 +181,7 @@ export class ParamFieldLineComponent implements OnChanges { * validité des saisies du composant */ public get isValid(): boolean { - switch (this._param.radioState) { + switch (this.param.radioState) { case ParamRadioConfig.FIX: return this._isInputValid; @@ -195,8 +196,9 @@ export class ParamFieldLineComponent implements OnChanges { public get formHasResults(): boolean { return ServiceFactory.instance.formulaireService.currentFormHasResults; } - @Input("param") - private _param: NgParameter; + + @Input() + private param: NgParameter; @ViewChild(NgParamInputComponent) private _ngParamInputComponent: NgParamInputComponent; @@ -205,7 +207,7 @@ export class ParamFieldLineComponent implements OnChanges { private _paramLinkComponent: ParamLinkComponent; @Output() - private onValid: EventEmitter<void>; + private valid: EventEmitter<void>; @Output() private inputChange: EventEmitter<void>; @@ -244,7 +246,7 @@ export class ParamFieldLineComponent implements OnChanges { * calcule la présence du radio "paramètre fixé" */ public hasRadioFix(): boolean { - switch (this._param.radioConfig) { + switch (this.param.radioConfig) { case ParamRadioConfig.FIX: return this.hasRadioLink(); @@ -257,7 +259,7 @@ export class ParamFieldLineComponent implements OnChanges { * calcule la présence du radio "paramètre à varier" */ public hasRadioVar(): boolean { - switch (this._param.radioConfig) { + switch (this.param.radioConfig) { case ParamRadioConfig.VAR: case ParamRadioConfig.CAL: return true; @@ -271,7 +273,7 @@ export class ParamFieldLineComponent implements OnChanges { * calcule la présence du radio "paramètre à calculer" */ public hasRadioCal(): boolean { - switch (this._param.radioConfig) { + switch (this.param.radioConfig) { case ParamRadioConfig.CAL: return true; @@ -287,14 +289,14 @@ export class ParamFieldLineComponent implements OnChanges { if (this._formService.formulaires.length > 0) { // au moins 2 calculettes ouvertes if (this._formService.formulaires.length > 1) { - return this._formService.filterLinkableValues(this._formService.getLinkableValues(this._param)).length > 0; + return this._formService.filterLinkableValues(this._formService.getLinkableValues(this.param)).length > 0; } // ou une seule calculette "ouvrages parallèles" - if (this._formService.formulaires[0].calculatorType == CalculatorType.ParallelStructure) { + if (this._formService.formulaires[0].calculatorType === CalculatorType.ParallelStructure) { const ps: ParallelStructure = this._formService.formulaires[0].currentSessionNub.nub as ParallelStructure; if (ps.structures.length > 1) { - return this._formService.filterLinkableValues(this._formService.getLinkableValues(this._param)).length > 0; + return this._formService.filterLinkableValues(this._formService.getLinkableValues(this.param)).length > 0; } } @@ -303,30 +305,30 @@ export class ParamFieldLineComponent implements OnChanges { } private onRadioClick(option: string) { - const oldValue = this._param.valueMode; + const oldValue = this.param.valueMode; switch (option) { case "fix": - const oldValueMode = this._param.valueMode; - this._param.valueMode = ParamValueMode.SINGLE; - this._param.setValue(this, this._param.paramDefinition.paramValues.singleValue); + const oldValueMode = this.param.valueMode; + this.param.valueMode = ParamValueMode.SINGLE; + this.param.setValue(this, this.param.paramDefinition.paramValues.singleValue); break; case "var": - this._param.valueMode = ParamValueMode.MINMAX; // min/max par défaut + this.param.valueMode = ParamValueMode.MINMAX; // min/max par défaut break; case "cal": - this._param.valueMode = ParamValueMode.CALCUL; + this.param.valueMode = ParamValueMode.CALCUL; break; case "link": - this._param.valueMode = ParamValueMode.LINK; + this.param.valueMode = ParamValueMode.LINK; break; } this.onRadio.emit({ - "param": this._param, + "param": this.param, "oldValueMode": oldValue }); @@ -338,7 +340,7 @@ export class ParamFieldLineComponent implements OnChanges { * émission d'un événement de validité */ private emitValidity() { - this.onValid.emit(); + this.valid.emit(); } /** @@ -366,7 +368,7 @@ export class ParamFieldLineComponent implements OnChanges { } public ngOnChanges() { - this._ngParamInputComponent.model = this._param; + this._ngParamInputComponent.model = this.param; this._ngParamInputComponent.showError = this.isRadioFixChecked; } diff --git a/src/app/components/param-link/param-link.component.ts b/src/app/components/param-link/param-link.component.ts index c6dfc0121..256558035 100644 --- a/src/app/components/param-link/param-link.component.ts +++ b/src/app/components/param-link/param-link.component.ts @@ -2,9 +2,8 @@ import { Component, Input, Output, EventEmitter, OnChanges, OnDestroy } from "@a import { NgParameter } from "../../formulaire/ngparam"; import { ServiceFactory } from "../../services/service-factory"; -import { ParamValueMode, Observer, ParamDefinition } from "jalhyd"; +import { ParamValueMode, Observer } from "jalhyd"; import { FormulaireService } from "../../services/formulaire/formulaire.service"; -import { FormulaireDefinition } from "../../formulaire/definition/form-definition"; @Component({ selector: "param-link", @@ -12,14 +11,14 @@ import { FormulaireDefinition } from "../../formulaire/definition/form-definitio }) export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { // paramètre géré (qui sera lié à une valeur, cad qui importe cette valeur) - @Input("param") - private _param: NgParameter; + @Input() + private param: NgParameter; @Output() - private onValid: EventEmitter<boolean>; + private valid: EventEmitter<boolean>; /** - * indice actuel du paramètre sélectionné dans la lsite + * indice actuel du paramètre sélectionné dans la liste */ private _currentIndex = -1; @@ -49,7 +48,7 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { private _formService: FormulaireService; constructor() { - this.onValid = new EventEmitter(); + this.valid = new EventEmitter(); this._formService = ServiceFactory.instance.formulaireService; this._formService.addObserver(this); } @@ -66,7 +65,7 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { * envoi d'un événement de validité */ private emitValidity() { - // this.onValid.emit(this._validList); + // this.valid.emit(this._validList); } /** @@ -74,14 +73,15 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { */ public onSelectLinkableParam(event: any) { const next = event.target.value; - - let i = 0; - for (const e of this._linkableParams) { - if (this._linkableParams[i].value.uid == next.value.uid) { - this.linkTo(i); - break; - } else { - i++; + if (next !== undefined && next !== "") { // opening the dropdown returns "" + let i = 0; + for (const e of this._linkableParams) { + if (this._linkableParams[i].value.uid === next.value.uid) { + this.linkTo(i); + break; + } else { + i++; + } } } } @@ -101,18 +101,6 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { return undefined; } - // // le paramètre est il déjà lié à une valeur ? si oui laquelle ? - // if(this._currentIndex === -1 && this._param.valueMode == ParamValueMode.LINK && this._linkableParams !== undefined) { - // let i = 0; - // for (const e of this._linkableParams) - // if (e.param.uid === this._param.paramDefinition.re) { - // this._currentIndex = i; - // break; - // } - // else - // i++; - // } - /** * attribut "label" d'une entrée du select des paramètres */ @@ -164,24 +152,36 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { this._currentIndex = index; const lp = this._linkableParams[index]; - this._param.linkToParameter(lp.nub, lp.name); + this.param.linkToParameter(lp.nub, lp.name); } } public updateParamList() { // liste des paramètres liables - if (this._param.valueMode === ParamValueMode.LINK) { - this._linkableParams = this._formService.filterLinkableValues(this._formService.getLinkableValues(this._param)); + if (this.param.valueMode === ParamValueMode.LINK) { + this._linkableParams = this._formService.filterLinkableValues(this._formService.getLinkableValues(this.param)); } else { this._linkableParams = []; } // initialisation de l'indice courant - if (this._linkableParams.length > 0) { if (this._currentIndex === -1) { - this.linkTo(0); + // le paramètre est il déjà lié à une valeur ? si oui laquelle ? + if (this.param.valueMode === ParamValueMode.LINK && this._linkableParams !== undefined) { + let i = 0; + for (const e of this._linkableParams) { + if (this.param.paramDefinition.paramValues.referencedNub + && e.nub.uid === this.param.paramDefinition.paramValues.referencedNub["_uid"]) { + this._currentIndex = i; + break; + } else { + i++; + } + } + } + this.linkTo(Math.max(this._currentIndex, 0)); // might still be -1 } this._message = undefined; } else { @@ -191,16 +191,16 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { } public ngOnChanges() { - if (this._param !== undefined) { - this._param.removeObserver(this); + if (this.param !== undefined) { + this.param.removeObserver(this); } - this._param.addObserver(this); + this.param.addObserver(this); this.updateParamList(); } public ngOnDestroy() { - this._param.removeObserver(this); + this.param.removeObserver(this); } // interface Observer diff --git a/src/app/components/param-values/param-values.component.html b/src/app/components/param-values/param-values.component.html index 51e847262..f4dc49687 100644 --- a/src/app/components/param-values/param-values.component.html +++ b/src/app/components/param-values/param-values.component.html @@ -15,7 +15,7 @@ <ngparam-max [title]="uitextValeurMaxi" (onChange)="onMaxChanged($event)"></ngparam-max> </div> <div *ngIf="isMinMax" class="col-12 col-sm-3"> - <ngparam-step [title]="uitextPasVariation" [param]=_param (onChange)="onStepChanged($event)"></ngparam-step> + <ngparam-step [title]="uitextPasVariation" [param]="param" (onChange)="onStepChanged($event)"></ngparam-step> </div> <div *ngIf="isList" class="col-12 col-sm-6"> diff --git a/src/app/components/param-values/param-values.component.ts b/src/app/components/param-values/param-values.component.ts index f31f9e28f..7a7431235 100644 --- a/src/app/components/param-values/param-values.component.ts +++ b/src/app/components/param-values/param-values.component.ts @@ -31,8 +31,8 @@ import { ValueListComponent } from "./value-list.component"; ] }) export class ParamValuesComponent extends BaseComponent implements AfterViewChecked { - @Input("param") - private _param: NgParameter; + @Input() + private param: NgParameter; private _valueModes = []; @@ -113,30 +113,30 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec this._doInitMinmax = false; // valeur pour min : celle déjà définie ou celle déduite de la valeur saisie - let min: number = this._param.minValue; + let min: number = this.param.minValue; if (min == undefined) { - min = this._param.getValue() / 2; + min = this.param.getValue() / 2; } // valeur pour max : celle déjà définie ou celle déduite de la valeur saisie - let max: number = this._param.maxValue; + let max: number = this.param.maxValue; if (max == undefined) { - max = this._param.getValue() * 2; + max = this.param.getValue() * 2; } - this._param.minValue = min; - this._minComponent.model = this._param; + this.param.minValue = min; + this._minComponent.model = this.param; - this._param.maxValue = max; - this._maxComponent.model = this._param; + this.param.maxValue = max; + this._maxComponent.model = this.param; // valeur du pas - let step = this._param.stepValue; + let step = this.param.stepValue; if (step == undefined) { step = (max - min) / 20; } - this._param.stepValue = step; - this._stepComponent.model = this._param; + this.param.stepValue = step; + this._stepComponent.model = this.param; this.validateAll(); @@ -155,17 +155,17 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec private initList() { if (this._doInitList && this._listComponent != undefined) { this._doInitList = false; - let l = this._param.valueList; + let l = this.param.valueList; if (l == undefined) { - if (this._param.isDefined) { - l = [this._param.getValue()]; + if (this.param.isDefined) { + l = [this.param.getValue()]; } else { l = []; } } - this._param.valueList = l; - this._listComponent.model = this._param; + this.param.valueList = l; + this._listComponent.model = this.param; } } @@ -191,7 +191,7 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec * envoi d'un événement de validité */ private emitValidity() { - switch (this._param.valueMode) { + switch (this.param.valueMode) { case ParamValueMode.LISTE: this.onValid.emit(this._validList); break; @@ -290,28 +290,28 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec * true si mode "liste de valeurs" */ public get isList(): boolean { - return this._param.valueMode === ParamValueMode.LISTE; + return this.param.valueMode === ParamValueMode.LISTE; } /** * true si mode "lié" */ public get isLink(): boolean { - return this._param.valueMode === ParamValueMode.LINK; + return this.param.valueMode === ParamValueMode.LINK; } /** * true si mode "min/max/pas" */ public get isMinMax(): boolean { - return this._param.valueMode === ParamValueMode.MINMAX; + return this.param.valueMode === ParamValueMode.MINMAX; } /** * valeur courante affichée dans le select min-max/list */ public get currentModeSelectLabel(): string { - return ParamValueMode[this._param.valueMode]; + return ParamValueMode[this.param.valueMode]; } /** @@ -335,7 +335,7 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec throw new Error("valeur " + next + " de ParamValueMode non prise en charge"); } - this._param.valueMode = next; + this.param.valueMode = next; } public get valueModes() { diff --git a/src/app/components/param-values/value-list.component.ts b/src/app/components/param-values/value-list.component.ts index d53e98013..542e770b6 100644 --- a/src/app/components/param-values/value-list.component.ts +++ b/src/app/components/param-values/value-list.component.ts @@ -22,14 +22,14 @@ export class ValueListComponent extends GenericInputComponent { } protected getModelValue(): any { - if (this._param == undefined) { + if (this._param === undefined || this._param === null) { return undefined; } return this._param.valueList; } protected setModelValue(sender: any, l: any) { - if (typeof (l) == "number") { + if (typeof (l) === "number") { this._param.valueList = []; this._param.valueList.push(l); } else { @@ -62,9 +62,9 @@ export class ValueListComponent extends GenericInputComponent { protected modelToUI(v: any): string { let res = ""; - if (v != undefined) { + if (v !== undefined && v !== null) { for (const e of v) { - if (res != "") { + if (res !== "") { res += ";"; } res += String(e); @@ -80,7 +80,7 @@ export class ValueListComponent extends GenericInputComponent { const tmp: string[] = ui.split(";"); let res = true; for (const v of tmp) { - const isnum = v != "" && (+v == +v); + const isnum = v !== "" && (+v === +v); res = res && isnum; if (!res) { break; diff --git a/src/app/formulaire/definition/form-def-fixedvar.ts b/src/app/formulaire/definition/form-def-fixedvar.ts index 0f2a0d045..a83d7839d 100644 --- a/src/app/formulaire/definition/form-def-fixedvar.ts +++ b/src/app/formulaire/definition/form-def-fixedvar.ts @@ -148,19 +148,18 @@ export class FormDefFixedVar { break; } } - if (newCal != undefined) { + if (newCal) { break; } } - if (newCal != undefined) { + if (newCal) { newCal.valueMode = ParamValueMode.CALCUL; } } } private logParams() { - console.log("----"); for (const fe of this._formBase.allFormElements) { if (fe instanceof NgParameter) { console.log(`${fe.paramDefinition.symbol} : ${ParamValueMode[fe.paramDefinition.valueMode]}`); diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index b18706b2a..ea579d10d 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -1,4 +1,4 @@ -import { CalculatorType, ComputeNodeType, Nub, ParamDefinition, SessionNub, Props, NubFactory, Observer } from "jalhyd"; +import { CalculatorType, ComputeNodeType, ParamDefinition, SessionNub, Props, Observer } from "jalhyd"; import { FormulaireElement } from "../formulaire-element"; import { NgParameter, ParamRadioConfig } from "../ngparam"; diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index c809ad2af..4ea578ea0 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -55,7 +55,7 @@ export class NgParameter extends InputField implements Observer { this._confId = id; } - private get _paramValues() { + public get _paramValues() { // @TODO remettre en private ! (debug) return this._paramDef.paramValues; } @@ -232,6 +232,7 @@ export class NgParameter extends InputField implements Observer { } this.valueMode = ParamValueMode.LINK; + // changement de lien this._paramDef.defineReference(n, ref); o = asObservable(this._paramDef.referencedObject); -- GitLab