diff --git a/jalhyd_branch b/jalhyd_branch index 1f7391f92b6a3792204e07e99f71f643cc35e7e1..3aff35fb15fd1e2bcdbd63e99674610916dd78a0 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -master +298-prebarrages-mettre-les-enfants-invalides-en-rouge-dans-le-schema-cassiopee-nghyd-484 diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 718ff08f5a873b395b553155be771e2e4b3d3a69..668a28eebfa6175685691ae92531960a424286ac 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -520,7 +520,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe } if (this._formulaire.currentNub.calcType === CalculatorType.PreBarrage) { const form: FormulairePrebarrage = this._formulaire as FormulairePrebarrage; - this._isUIValid = this._isUIValid && form.currentNub.check(); + this._isUIValid = this._isUIValid && form.currentNub.check().length === 0; } } } diff --git a/src/app/components/pb-schema/pb-schema.component.ts b/src/app/components/pb-schema/pb-schema.component.ts index cdbe3fad0932b9ebd36b8fc3ad8c692c166d987a..853cdd6cd32f5d716805df896a6763e511aab557 100644 --- a/src/app/components/pb-schema/pb-schema.component.ts +++ b/src/app/components/pb-schema/pb-schema.component.ts @@ -138,6 +138,7 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni } catch (e) { console.error(e); } + this.highlightErrorItems(null); } /** @@ -229,6 +230,8 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni def.push("classDef basin fill:#e0f3fb,stroke:#003A80;"); // irstea-ocean 50 / 500 def.push("classDef basin::first-line color:green,font-size:0.5em;"); def.push("classDef node-highlighted fill:#4DBBE9;"); // irstea-ocean (material "accent"), 300 + def.push("classDef node-error fill:#ec7430;"); // irstea-rouille (material "accent"), 400 + def.push("classDef node-highlighted-error fill:#d92f03;"); // irstea-rouille (material "accent"), 900 const sortedWalls: PbCloison[] = []; for (const c of this.model.children) { @@ -240,6 +243,7 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni sortedWalls.push(c); } } + // sort then draw walls sortedWalls.sort(this.triCloisonsGaucheDroite); for (const c of sortedWalls) { @@ -308,6 +312,7 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni } else { this._selectedItem = this.model.findChild(item.id); } + this.highlightErrorItems(item.id); // show proper form and hide results this.nodeSelected.emit({ node: this._selectedItem @@ -649,6 +654,29 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni }); } + private highlightErrorItems(selectedUid: string) { + this.nativeElement.querySelectorAll("g.node").forEach(item => { + item.classList.remove("node-error"); + item.classList.remove("node-highlighted-error"); + }); + const invalidUids: string[] = this.model.check(); + this.nativeElement.querySelectorAll("g.node").forEach(item => { + let itemId: string; + if ([this.upstreamId, this.downstreamId].includes(item.id)) { + itemId = this.model.uid; + } else { + itemId = item.id + } + if (invalidUids.includes(itemId)) { + if (item.id === selectedUid) { + item.classList.add("node-highlighted-error"); + } else { + item.classList.add("node-error"); + } + } + }); + } + private unselect() { // console.debug(`PbSchemaComponent.unselect()`); this._selectedItem = undefined;