diff --git a/jalhyd_branch b/jalhyd_branch index 22284ff354bd375daf96c4516cffb189fc611602..de50629b8fe9cf9d219fdf081f3ab2ecd5f9ecc4 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -32-ajout-de-l-outil-prebarrage +278-prebarrage-calculable-avec-champs-vides-cassiopee-nghyd-470 diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 8e4eaf26ccf55c6fd0bc1e4626e93d9943fddb6c..dc3d0900ac45821f76d76f09941e48008d3d8135 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -473,8 +473,9 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe this._isUIValid = false; if (! this._formulaire.calculateDisabled) { // all fieldsets must be valid + this._isUIValid = true; if (this._fieldsetComponents !== undefined) { - this._isUIValid = this._fieldsetComponents.reduce( + this._isUIValid = this._isUIValid && this._fieldsetComponents.reduce( // callback ( // accumulator (valeur précédente du résultat) @@ -514,10 +515,13 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe if (this._pabTableComponent !== undefined) { this._isUIValid = this._isUIValid && this._pabTableComponent.isValid; } - } - - if (this._pbSchemaComponent !== undefined) { - this._isUIValid = this._isUIValid && this._pbSchemaComponent.isValid; + if (this._pbSchemaComponent !== undefined) { + this._isUIValid = this._isUIValid && this._pbSchemaComponent.isValid; + } + if (this._formulaire.currentNub.calcType === CalculatorType.PreBarrage) { + const form: FormulairePrebarrage = this._formulaire as FormulairePrebarrage; + this._isUIValid = this._isUIValid && form.currentNub.check(); + } } } diff --git a/src/app/formulaire/definition/form-prebarrage.ts b/src/app/formulaire/definition/form-prebarrage.ts index 3a2c1ea7d0ba87d6c11e67c7a522aeee7554ae93..73b4df1c57061fdc65c6089d630d711ae8753a60 100644 --- a/src/app/formulaire/definition/form-prebarrage.ts +++ b/src/app/formulaire/definition/form-prebarrage.ts @@ -55,7 +55,7 @@ export class FormulairePrebarrage extends FormulaireFixedVar { public get results(): CalculatorResults[] { // ensure help links are propagated this._pbResults.helpLinks = this.helpLinks; - return [ this._pbResults ]; + return [this._pbResults]; } public get hasResults(): boolean { @@ -185,7 +185,7 @@ export class FormulairePrebarrage extends FormulaireFixedVar { */ private showFormElements(f: FormulaireDefinition) { // clear all kids except PbSchema - this._kids = [ this.kids[0] ]; + this._kids = [this.kids[0]]; for (const e of f.kids) { this.kids.push(e); } @@ -317,4 +317,19 @@ export class FormulairePrebarrage extends FormulaireFixedVar { this.refreshSchema(); } } + + /** + * Set value of all single parameters to undefined, except for the given parameter ids + */ + public emptyFields(except: string[] = [ "Cd0", "CdWS", "CdGR", "CdGRS", "CdCunge", "CdWR", "CdO", "CdT", "CdWSL" ]) { + // save current calculated param, as setting value on a CALC param will + // change its mode and choose another calculated param by default + const paramCalculated = this.currentNub.calculatedParam; + for (const p of this.currentNub.parameterIterator) { + if (! except.includes(p.symbol)) { + p.setValue(undefined); + } + } + this.currentNub.calculatedParam = paramCalculated; + } }