An error occurred while loading the file. Please try again.
-
Dave Kuhlman authored50f2b2e7
import { Component, Input, ChangeDetectorRef } from "@angular/core";
import { NumericalString } from "jalhyd";
import { GenericInputComponent } from "../generic-input/generic-input.component";
import { InternationalisationService } from "../../services/internationalisation/internationalisation.service";
import { NgParameter } from "../../formulaire/ngparam";
@Component({
selector: "ngparam-min",
templateUrl: "../generic-input/generic-input.component.html"
})
export class NgParamMinComponent extends GenericInputComponent {
constructor(private intlService: InternationalisationService, cdRef: ChangeDetectorRef) {
super(cdRef);
}
/**
* paramètre géré
*/
private get _param(): NgParameter {
return this._model;
}
protected getModelValue(): any {
if (this._param == undefined)
return undefined;
return this._param.minValue;
}
protected setModelValue(sender: any, v: any) {
this._param.minValue = v;
}
protected validateModelValue(v: any): { isValid: boolean, message: string } {
let msg = undefined;
let valid = false;
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 };
}
protected modelToUI(v: any): string {
if (typeof (v) == "number")
return String(v);
return undefined;
}
protected validateUIValue(ui: string): { isValid: boolean, message: string } {
let valid: boolean = false;
let msg: string = undefined;
let v: NumericalString = new NumericalString(ui);
if (!v.isNumerical)
msg = "Veuillez entrer une valeur numérique";
else
valid = true;
return { isValid: valid, message: msg };
}
protected uiToModel(ui: string): any {
71727374
return +ui;
}
}