diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 9650543c6a0add5f27c5b2c5bb7aa61ea0e44f64..859463c39286f998307bbc00116fb818bf38b89a 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -526,6 +526,9 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe this._isUIValid = this._isUIValid && form.checkParameters().length === 0; } } + + // update prébarrage schema validity + this._pbSchemaComponent.updateItemsValidity(); } public getElementStyleDisplay(id: string) { diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts index 3dc390d50f261a0dab352154f62a34000e46b885..444127f7f9a1cecc74a2b3ecd9192ac71ec3f593 100644 --- a/src/app/components/generic-input/generic-input.component.ts +++ b/src/app/components/generic-input/generic-input.component.ts @@ -131,7 +131,7 @@ export abstract class GenericInputComponentDirective implements OnChanges { return this._isValidUI && this._isValidModel; } - private setUIValid(b: boolean) { + protected setUIValid(b: boolean) { const old = this.isValid; this._isValidUI = b; if (this.isValid !== old) { @@ -147,7 +147,7 @@ export abstract class GenericInputComponentDirective implements OnChanges { return isValid; } - private setModelValid(b: boolean) { + protected setModelValid(b: boolean) { const old = this.isValid; this._isValidModel = b; if (this.isValid !== old) { diff --git a/src/app/components/ngparam-input/ngparam-input.component.ts b/src/app/components/ngparam-input/ngparam-input.component.ts index 2449f691efa1e7b2a0a98f4ab34b284107a801f5..581886d3a2597a6543539ba1749e016054e2334b 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) { // from nghyd#501 commit 425ae8fa + throw new Message(MessageCode.ERROR_PARAMDEF_VALUE_UNDEFINED); + } this._paramDef.checkValue(v); valid = true; } catch (e) { @@ -113,6 +116,26 @@ export class NgParamInputComponent extends GenericInputComponentDirective implem return { isValid: valid, message: msg }; } + private undefineModel() { + if (this.getModelValue() !== undefined) { + this.setModelValue(this, undefined); + } + } + + protected setModelValid(b: boolean) { + if (!b) { + this.undefineModel(); + } + super.setModelValid(b); + } + + protected setUIValid(b: boolean) { + if (!b) { + this.undefineModel(); + } + super.setUIValid(b); + } + public update(sender: any, data: any): void { switch (data["action"]) { case "ngparamAfterValue": @@ -148,6 +171,7 @@ export class NgParamInputComponent extends GenericInputComponentDirective implem } public ngOnDestroy() { + // résoudre le conflit en supprimant le code ajouté cad ne conserver que removeObserver() this._paramDef.removeObserver(this); } } diff --git a/src/app/components/pb-schema/pb-schema.component.ts b/src/app/components/pb-schema/pb-schema.component.ts index bfc4978881940f7defe818c4cd2c9023e279ee22..425b1ba882a0b7956e1475ab01e3e7347eb423a4 100644 --- a/src/app/components/pb-schema/pb-schema.component.ts +++ b/src/app/components/pb-schema/pb-schema.component.ts @@ -655,6 +655,13 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni } } + /** + * update all items validity rendering + */ + public updateItemsValidity() { + this.highlightErrorItems(this._selectedItem?.uid); + } + private clearHighlightedItems() { this.nativeElement.querySelectorAll("g.node").forEach(item => { item.classList.remove("node-highlighted");