diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts index 3dc390d50f261a0dab352154f62a34000e46b885..c30e69123c3fdd550ca1706144355a280100c1a9 100644 --- a/src/app/components/generic-input/generic-input.component.ts +++ b/src/app/components/generic-input/generic-input.component.ts @@ -154,11 +154,14 @@ export abstract class GenericInputComponentDirective implements OnChanges { this.emitValidChanged(); } // répercussion des erreurs sur le Form angular, pour faire apparaître/disparaître les mat-error + // setTimeout(() => { // en cas de pb, décommenter le timeout if (b) { this.inputField.control.setErrors(null); } else { this.inputField.control.setErrors({ "incorrect": true }); } + // this.inputField.control.markAsTouched(); + // }, 100); } private validateModel(): boolean { diff --git a/src/app/components/ngparam-input/ngparam-input.component.ts b/src/app/components/ngparam-input/ngparam-input.component.ts index 2449f691efa1e7b2a0a98f4ab34b284107a801f5..781e29b15614cb04192292ed2c465c22c6939f95 100644 --- a/src/app/components/ngparam-input/ngparam-input.component.ts +++ b/src/app/components/ngparam-input/ngparam-input.component.ts @@ -2,7 +2,7 @@ import { Component, ChangeDetectorRef, OnDestroy, Input, ElementRef } from "@angular/core"; -import { Message, Observer } from "jalhyd"; +import { Message, MessageCode, Observer } from "jalhyd"; import { I18nService } from "../../services/internationalisation.service"; import { NgParameter } from "../../formulaire/elements/ngparam"; @@ -99,6 +99,9 @@ export class NgParamInputComponent extends GenericInputComponentDirective implem msg = "internal error, model undefined"; } else { try { + if (!this._paramDef.allowEmpty && v === undefined) { + throw new Message(MessageCode.ERROR_PARAMDEF_VALUE_UNDEFINED); + } this._paramDef.checkValue(v); valid = true; } catch (e) { @@ -148,6 +151,9 @@ export class NgParamInputComponent extends GenericInputComponentDirective implem } public ngOnDestroy() { + if (!this.isValid && this.getModelValue() !== undefined) { + this.setModelValue(this, undefined); + } this._paramDef.removeObserver(this); } }