From 7eb7dab256689bb6f6dc20549623fa28dca7154c Mon Sep 17 00:00:00 2001 From: Mathias Chouet <mathias.chouet@irstea.fr> Date: Fri, 3 Apr 2020 14:58:21 +0200 Subject: [PATCH] Option in calculator config to disable calculation permanently --- .../generic-calculator/calculator.component.ts | 3 ++- src/app/formulaire/definition/form-definition.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index a72bd526e..327e20d79 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -442,7 +442,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe */ private updateUIValidity() { this._isUIValid = false; - + if (! this._formulaire.calculateDisabled) { if (this._fieldsetComponents !== undefined) { this._isUIValid = this._fieldsetComponents.reduce( // callback @@ -485,6 +485,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe this._isUIValid = this._isUIValid && this._pabTableComponent.isValid; } } + } public getElementStyleDisplay(id: string) { const isDisplayed: boolean = this._formulaire.isDisplayed(id); diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index 3cb94b538..1512cf77e 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -45,6 +45,9 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs /** aide en ligne pour les résultats */ protected _resultsHelpLinks: { [key: string]: string }; + /** set to true to definitely gray-out Calculate button */ + protected _calculateDisabled = false; + /** fichier de configuration */ private _jsonConfig: {}; @@ -71,6 +74,10 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs } } + public get calculateDisabled(): boolean { + return this._calculateDisabled; + } + public get specificLocalisation() { return this._specificLocalisation; } @@ -160,6 +167,9 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs } this._helpLink = json["help"]; this._resultsHelpLinks = json["resultsHelp"]; + if (json["calculateDisabled"] !== undefined) { + this._calculateDisabled = json["calculateDisabled"]; + } } /** called at the end of parseConfig() */ -- GitLab