Skip to content
Snippets Groups Projects
Commit 2fc234ce authored by francois.grand's avatar francois.grand
Browse files

closes #62

parent 14fc02a5
No related branches found
No related tags found
No related merge requests found
......@@ -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 };
}
......
......@@ -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 };
}
......
......@@ -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 };
}
......
......@@ -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 };
}
......
......@@ -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();
}
}
......@@ -22,6 +22,8 @@ export class ValueListComponent extends GenericInputComponent {
}
protected getModelValue(): any {
if (this._param == undefined)
return undefined;
return this._param.valueList;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment