Skip to content
Snippets Groups Projects
Commit 8c4e4132 authored by François Grand's avatar François Grand
Browse files

fix: SVG schema nodes not instantly displayed on error in case of invalid input in a fieldset

refs #544
parent 3761c39a
No related branches found
No related tags found
1 merge request!144Resolve "PréBarrages: les changements de couleur du schéma ne sont pas instantanées"
......@@ -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) {
......
......@@ -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) {
......
......@@ -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);
}
}
......@@ -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");
......
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