diff --git a/src/app/components/ngparam-input/ngparam-input.component.ts b/src/app/components/ngparam-input/ngparam-input.component.ts index 7da3bf7bacb80564a594aaa67c52e901ffe9ef93..9b5939134c44c75ab74929fa5afc2e04ac9c44b4 100644 --- a/src/app/components/ngparam-input/ngparam-input.component.ts +++ b/src/app/components/ngparam-input/ngparam-input.component.ts @@ -69,16 +69,19 @@ export class NgParamInputComponent extends GenericInputComponent implements Obse let msg = undefined; let valid = false; - try { - this._paramDef.checkValue(v); - valid = true; - } - catch (e) { - if (e instanceof Message) - msg = this.intlService.localizeMessage(e); - else - msg = "invalid value"; - } + if (this._paramDef == undefined) + msg = "internal error, model undefined"; + else + try { + this._paramDef.checkValue(v); + valid = true; + } + catch (e) { + if (e instanceof Message) + msg = this.intlService.localizeMessage(e); + else + msg = "invalid value"; + } return { isValid: valid, message: msg }; } diff --git a/src/app/components/param-values/ngparam-max.component.ts b/src/app/components/param-values/ngparam-max.component.ts index 2c7f5796272fe6589a2b8f64da6eecb4aa8bab9b..f6cbbbeaad606a29534d9e0e4464d1d4c4ef302d 100644 --- a/src/app/components/param-values/ngparam-max.component.ts +++ b/src/app/components/param-values/ngparam-max.component.ts @@ -23,6 +23,8 @@ export class NgParamMaxComponent extends GenericInputComponent { } protected getModelValue(): any { + if (this._param == undefined) + return undefined; return this._param.maxValue; } @@ -34,10 +36,14 @@ export class NgParamMaxComponent extends GenericInputComponent { let msg = undefined; let valid = false; - if (!this._param.checkMax(v)) - msg = "La valeur n'est pas dans ]" + this._param.minValue + " , " + this._param.domain.maxValue + "]"; - else - valid = true; + if (this._param == undefined) + msg = "internal error, model undefined"; + else { + if (!this._param.checkMax(v)) + msg = "La valeur n'est pas dans ]" + this._param.minValue + " , " + this._param.domain.maxValue + "]"; + else + valid = true; + } return { isValid: valid, message: msg }; } diff --git a/src/app/components/param-values/ngparam-min.component.ts b/src/app/components/param-values/ngparam-min.component.ts index 2dbf96567f9145d028c072880c58ca77d71871d0..cd00396c1899ee7f42deeb0eb795b6b9953804e8 100644 --- a/src/app/components/param-values/ngparam-min.component.ts +++ b/src/app/components/param-values/ngparam-min.component.ts @@ -23,6 +23,8 @@ export class NgParamMinComponent extends GenericInputComponent { } protected getModelValue(): any { + if (this._param == undefined) + return undefined; return this._param.minValue; } @@ -34,10 +36,14 @@ export class NgParamMinComponent extends GenericInputComponent { let msg = undefined; let valid = false; - if (!this._param.checkMin(v)) - msg = "La valeur n'est pas dans [" + this._param.domain.minValue + " , " + this._param.maxValue + "["; - else - valid = true; + if (this._param == undefined) + msg = "internal error, model undefined"; + else { + if (!this._param.checkMin(v)) + msg = "La valeur n'est pas dans [" + this._param.domain.minValue + " , " + this._param.maxValue + "["; + else + valid = true; + } return { isValid: valid, message: msg }; } diff --git a/src/app/components/param-values/ngparam-step.component.ts b/src/app/components/param-values/ngparam-step.component.ts index 38c9a949867c06b6b625b1ee627c0a48963b9cc6..3825d5280be572d00466d63928d8c399412533d4 100644 --- a/src/app/components/param-values/ngparam-step.component.ts +++ b/src/app/components/param-values/ngparam-step.component.ts @@ -23,6 +23,8 @@ export class NgParamStepComponent extends GenericInputComponent { } protected getModelValue(): any { + if (this._param == undefined) + return undefined; return this._param.stepValue; } @@ -34,18 +36,22 @@ export class NgParamStepComponent extends GenericInputComponent { let msg = undefined; let valid = false; - if (this._param.isMinMaxValid) { - if (!this._param.checkStep(v)) { - msg = "La valeur n'est pas dans " + this._param.stepRefValue.toString(); - } - else { - valid = v > 0; - if (!valid) - msg = "La valeur ne peut pas être <= 0"; + if (this._param == undefined) + msg = "internal error, model undefined"; + else { + if (this._param.isMinMaxValid) { + if (!this._param.checkStep(v)) { + msg = "La valeur n'est pas dans " + this._param.stepRefValue.toString(); + } + else { + valid = v > 0; + if (!valid) + msg = "La valeur ne peut pas être <= 0"; + } } + else + msg = "Veuillez corriger le min/max"; } - else - msg = "Veuillez corriger le min/max"; return { isValid: valid, message: msg }; } diff --git a/src/app/components/param-values/param-values.component.ts b/src/app/components/param-values/param-values.component.ts index 360865d3e0a94398f45a30589d16645fa6029677..8ec032838f757a9982acd1939fafc05a476ed9ee 100644 --- a/src/app/components/param-values/param-values.component.ts +++ b/src/app/components/param-values/param-values.component.ts @@ -60,10 +60,15 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec private _validList: boolean = false; /** - * flag signalant qu'on a sélectionné le mode "liste" et qu'il faut initialiser le composant ValueListComponent + * flag signalant qu'il faut initialiser le composant ValueListComponent (par ex quand on a sélectionné le mode "liste") */ private _doInitList: boolean = false; + /** + * flag signalant qu'il faut initialiser les composants min/max/pas + */ + private _doInitMinmax: boolean = false; + /** * composant de saisie du minimum */ @@ -102,7 +107,9 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec * init des champs min/max/pas */ private initMinMaxStep() { - if (this.isMinMax) { + if (this.isMinMax && this._doInitMinmax) { + 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; if (min == undefined) @@ -253,13 +260,6 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec } } - /** - * appelé au 1er affichage du composant - */ - protected afterFirstViewChecked() { - this.initMinMaxStep(); - } - private get uitextValeurMini() { return this.intlService.localizeText("INFO_PARAMFIELD_VALEURMINI"); } @@ -299,16 +299,37 @@ export class ParamValuesComponent extends BaseComponent implements AfterViewChec private onSelectValueMode(event: any) { const next = event.target.value; - // on a sélectionné "liste" ? - if (this._param.valueMode != ParamValueMode.LISTE && next == ParamValueMode.LISTE) - this._doInitList = true; + switch (next) { + // on a sélectionné "min/max" ? + case ParamValueMode.MINMAX: + this._doInitMinmax = true; + break; + + // on a sélectionné "liste" ? + case ParamValueMode.LISTE: + this._doInitList = true; + break; + + default: + throw "valeur " + next + " de ParamValueMode non prise en charge"; + } this._param.valueMode = next; - this.validateAll(); + } + + /** + * appelé au 1er affichage du composant + */ + protected afterFirstViewChecked() { + if (this.isMinMax) + this._doInitMinmax = true; + else + this._doInitList = true; } ngAfterViewChecked() { super.ngAfterViewChecked(); + this.initMinMaxStep(); this.initList(); } } diff --git a/src/app/components/param-values/value-list.component.ts b/src/app/components/param-values/value-list.component.ts index bfd68b8b59c77b81108a659be6e899b917598c9e..2286d317e256af2e408c6495f276d1ea9d81bd53 100644 --- a/src/app/components/param-values/value-list.component.ts +++ b/src/app/components/param-values/value-list.component.ts @@ -22,6 +22,8 @@ export class ValueListComponent extends GenericInputComponent { } protected getModelValue(): any { + if (this._param == undefined) + return undefined; return this._param.valueList; }