diff --git a/src/app/calculators/espece/config.json b/src/app/calculators/espece/config.json index 8764eee37aad677a3b553070a19406b6d498e4c0..33f7af908a19a7536e0a13a3ab8161b9be0c254e 100644 --- a/src/app/calculators/espece/config.json +++ b/src/app/calculators/espece/config.json @@ -10,6 +10,12 @@ { "id": "PVMaxLim", "allowEmpty": true + }, + { + "id": "select_divingjetsupported", + "type": "select", + "property": "divingJetSupported", + "default": "NOT_SUPPORTED" } ] }, @@ -88,6 +94,7 @@ { "type": "options", "help": "verification/espece.html", + "selectIds": [ "select_divingjetsupported" ], "calculateDisabled": true } ] diff --git a/src/app/calculators/espece/en.json b/src/app/calculators/espece/en.json index cd76f2b623a76b64bd9608ee10006dddc2a4080e..0934829af65285e0d5d3e070e1ff81822f6ff22e 100644 --- a/src/app/calculators/espece/en.json +++ b/src/app/calculators/espece/en.json @@ -5,6 +5,11 @@ "fs_param_pam": "Rock-ramp fishpasses", "fs_param_par": "Humpback fishways", + "select_divingjetsupported": "Diving jets support", + + "DIVINGJETSUPPORTED_0": "Not supported", + "DIVINGJETSUPPORTED_1": "Supported", + "UNIT_DHMaxS": "m", "UNIT_DHMaxP": "m", "UNIT_BMin": "m", diff --git a/src/app/calculators/espece/fr.json b/src/app/calculators/espece/fr.json index b451dd4fd6e840cac558eb0a60158cbe4fd1ae05..9f8fc5034d8b5ea87d9600be3be2df25ef7755ff 100644 --- a/src/app/calculators/espece/fr.json +++ b/src/app/calculators/espece/fr.json @@ -5,6 +5,11 @@ "fs_param_pam": "Passes à macrorugosités", "fs_param_par": "Passes à ralentisseurs", + "select_divingjetsupported": "Support des jets plongeants", + + "DIVINGJETSUPPORTED_0": "Non supportés", + "DIVINGJETSUPPORTED_1": "Supportés", + "UNIT_DHMaxS": "m", "UNIT_DHMaxP": "m", "UNIT_BMin": "m", diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 0e35ac269afb4fb2a6c547406c835e117a6b2cbd..8a328a71eb872b094146b15f2637cd315821c8b2 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -1005,6 +1005,7 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe const form = this._formulaire as FormulaireFixedVar; const nub = (form.currentNub as Espece); nub.loadPredefinedSpecies(result.selected); + console.log("================ espèce chargée, refresh tout"); form.refreshFieldsets(); } }); diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts index 1af5e585973d9d08912d8f96b3d800ba67056179..3d9472e3b957f89f234c0c0cf8f9a49a02a28c50 100644 --- a/src/app/components/generic-input/generic-input.component.ts +++ b/src/app/components/generic-input/generic-input.component.ts @@ -18,25 +18,14 @@ import { ApplicationSetupService } from "../../services/app-setup.service"; */ @Directive() export abstract class GenericInputComponentDirective implements OnChanges { - /** - * entité mémoire gérée - */ - protected _model: NgParameter | FormulaireDefinition; // CalcName utilise un FormDefinition ici !? - /** - * flag de désactivation de l'input - */ - @Input() - private _inputDisabled = false; + /** entité mémoire gérée */ + protected _model: NgParameter | FormulaireDefinition; // CalcName utilise un FormDefinition ici !? - /** - * flag d'affichage du message d'erreur - */ + /** flag d'affichage du message d'erreur */ public showError = true; - /** - * id de l'input, utilisé notamment pour les tests - */ + /** id de l'input, utilisé notamment pour les tests */ public get inputId() { let id = "error-in-inputId"; if (this._model) { @@ -110,7 +99,11 @@ export abstract class GenericInputComponentDirective implements OnChanges { ) { } public get isDisabled(): boolean { - return this._inputDisabled; + if (this._model instanceof NgParameter) { + return this._model.disabled; + } else { + return false; + } } /** diff --git a/src/app/formulaire/definition/form-espece.ts b/src/app/formulaire/definition/form-espece.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c1893776a40edf7cb3d06af7531db092552830c --- /dev/null +++ b/src/app/formulaire/definition/form-espece.ts @@ -0,0 +1,46 @@ +import { IObservable, DivingJetSupport } from "jalhyd"; + +import { FormulaireFixedVar } from "./form-fixedvar"; +import { NgParameter } from "../elements/ngparam"; + +/** + * Formulaire pour les espèces (critères de franchissement) + */ +export class FormulaireEspece extends FormulaireFixedVar { + + protected completeParse(firstNotif: boolean = true) { + super.completeParse(firstNotif); + this.updateDivingJetCriteriaInputs(this.currentNub.properties.getPropValue("divingJetSupported")); + } + + /** + * Enable or disable inputs related to diving jet PAB criteria + */ + public updateDivingJetCriteriaInputs(supported: DivingJetSupport) { + const fsPABDivingJet = this.getFormulaireNodeById("fs_param_pab_p"); + if (fsPABDivingJet !== undefined) { + console.log("> got the fieldset"); + for (const e of fsPABDivingJet.allFormElements) { + if (e instanceof NgParameter) { + console.log(">> setting parameter disabled " + e.symbol + " to", supported === DivingJetSupport.NOT_SUPPORTED); + e.disabled = (supported === DivingJetSupport.NOT_SUPPORTED); + } + } + } + } + + // interface Observer + + public update(sender: IObservable, data: any) { + super.update(sender, data); + console.log("XXX property changed !!", sender.constructor.name, data); + if (data.action === "propertyChange") { + switch (data.name) { + case "divingJetSupported": + this.updateDivingJetCriteriaInputs(data.value); + this.reset(); + break; + } + } + } +} diff --git a/src/app/formulaire/definition/form-macrorugo-compound.ts b/src/app/formulaire/definition/form-macrorugo-compound.ts index 9ab7b18ddcd43414082dc1418fd20943eb969724..f04e6ccfe47b44d0ad032872a2737a080369c54e 100644 --- a/src/app/formulaire/definition/form-macrorugo-compound.ts +++ b/src/app/formulaire/definition/form-macrorugo-compound.ts @@ -57,7 +57,6 @@ export class FormulaireMacrorugoCompound extends FormulaireRepeatableFieldset { if (firstNotif) { this.updateApronState(this.currentNub.properties.getPropValue("inclinedApron")); } - this.helpLinks = this._resultsHelpLinks; } protected get fieldsetContainer(): FieldsetContainer { diff --git a/src/app/formulaire/definition/form-parallel-structures.ts b/src/app/formulaire/definition/form-parallel-structures.ts index 87b34793068efa0926d7155de54083cf800a08c3..eaffb9f336341df0784a4d83b56a6c08f43f09e1 100644 --- a/src/app/formulaire/definition/form-parallel-structures.ts +++ b/src/app/formulaire/definition/form-parallel-structures.ts @@ -95,7 +95,6 @@ export class FormulaireParallelStructure extends FormulaireRepeatableFieldset { protected completeParse(firstNotif: boolean = true) { super.completeParse(firstNotif); this.fieldsetContainer.addObserver(this); - this.helpLinks = this._resultsHelpLinks; } protected get fieldsetContainer(): FieldsetContainer { diff --git a/src/app/formulaire/definition/form-verificateur.ts b/src/app/formulaire/definition/form-verificateur.ts index 217298e80fac07cac3da8ad33ee31f97cc45391e..1f712ada6a1b1593f6de789246d5a6cd41327201 100644 --- a/src/app/formulaire/definition/form-verificateur.ts +++ b/src/app/formulaire/definition/form-verificateur.ts @@ -37,7 +37,7 @@ export class FormulaireVerificateur extends FormulaireFixedVar { } protected findPassVariatedParameters(): NgParameter[] { - let pvp = [] + let pvp = []; const passUid = this.verificateurNub.nubToVerify.uid; const passForm = ServiceFactory.formulaireService.getFormulaireFromNubId(passUid); pvp = passForm.getVariatedParameters(); diff --git a/src/app/formulaire/elements/ngparam.ts b/src/app/formulaire/elements/ngparam.ts index 063bd57960832a833c8511aa8f3b4f8bcc8d56fc..457e689763ece29e593941c39b831d4f07899aa2 100644 --- a/src/app/formulaire/elements/ngparam.ts +++ b/src/app/formulaire/elements/ngparam.ts @@ -31,11 +31,15 @@ export class NgParameter extends InputField implements Observer { private _allowEmpty = false; public unit: string; + public radioConfig: ParamRadioConfig; + public disabled: boolean; + constructor(private _paramDef: ParamDefinition, parent: FormulaireNode) { super(parent); this.radioConfig = this.radioState; + this.disabled = false; } /** diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index dac713d0531f9980a15f71bf49c616289ebe276c..71b4dee0c59376071bc40490c3c9f99476bfb89a 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -42,6 +42,7 @@ import { FormulaireFixedVar } from "../formulaire/definition/form-fixedvar"; import { FormulaireSection } from "../formulaire/definition/form-section"; import { FormulairePAR } from "../formulaire/definition/form-par"; import { FormulaireVerificateur } from "../formulaire/definition/form-verificateur"; +import { FormulaireEspece } from "../formulaire/definition/form-espece"; @Injectable() export class FormulaireService extends Observable { @@ -318,6 +319,10 @@ export class FormulaireService extends Observable { f = new FormulaireVerificateur(); break; + case CalculatorType.Espece: + f = new FormulaireEspece(); + break; + default: f = new FormulaireFixedVar(); } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index f50f324af8599134487d56e7fc2de76c701fa432..b91a4dcb79cdbcf31d023c34c9f8e21b94845f75 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -636,6 +636,10 @@ "WARNING_VERIF_MRC_YMIN_APRON_N": "Apron #%N%: water level %Y% too low (minimum: %minY%)", "INFO_VERIF_MRC_CROSSABLE_WIDTH": "Maximum crossable width is %width% m", "ERROR_VERIF_NO_PRESET": "This species group is not compatible with this pass type", + "ERROR_VERIF_PAB_DIVING_JET_NOT_SUPPORTED": "Wall #%N%: diving jet not supported", + "ERROR_VERIF_PAB_DIVING_JET_NOT_SUPPORTED_DW": "Downwall: diving jet not supported", + "WARNING_VERIF_PAB_DIVING_JET_NOT_SUPPORTED": "Wall #%NC%, structure %NS%: diving jet not supported", + "WARNING_VERIF_PAB_DIVING_JET_NOT_SUPPORTED_DW": "Downwall, structure %NS%: diving jet not supported", "ERROR_VERIF_PAB_DHMAX": "Wall #%N%: fall %DH% too high (maximum for surface jet: %maxDHS%, maximum for diving jet: %maxDHP%)", "ERROR_VERIF_PAB_DHMAX_DW": "Downwall: fall %DH% too high (maximum for surface jet: %maxDHS%, maximum for diving jet: %maxDHP%)", "ERROR_VERIF_PAB_DHMAX_JET": "Wall #%N%: fall %DH% too high for jet type ENUM_STRUCTUREJETTYPE_%jetType% (maximum: %maxDH%)", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index ca2bce694a3350009883667e1469b87d7f287698..5d4a10cffee3941c49117ffa131525d625d13a97 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -639,6 +639,10 @@ "WARNING_VERIF_MRC_YMIN_APRON_N": "Radier n°%N% : tirant d'eau %Y% insuffisant (minimum : %minY%)", "INFO_VERIF_MRC_CROSSABLE_WIDTH": "La largeur franchissable maximale est %width% m", "ERROR_VERIF_NO_PRESET": "Ce groupe d'espèces n'est pas compatible avec ce type de passe", + "ERROR_VERIF_PAB_DIVING_JET_NOT_SUPPORTED": "Cloison n°%N% : jet plongeant non supporté", + "ERROR_VERIF_PAB_DIVING_JET_NOT_SUPPORTED_DW": "Cloison aval : jet plongeant non supporté", + "WARNING_VERIF_PAB_DIVING_JET_NOT_SUPPORTED": "Cloison n°%NC%, ouvrage %NS% : jet plongeant non supporté", + "WARNING_VERIF_PAB_DIVING_JET_NOT_SUPPORTED_DW": "Cloison aval, ouvrage %NS% : jet plongeant non supporté", "ERROR_VERIF_PAB_DHMAX": "Cloison n°%N% : chute %DH% trop importante (maximum pour jet de surface : %maxDHS%, maximum pour jet plongeant : %maxDHP%)", "ERROR_VERIF_PAB_DHMAX_DW": "Cloison aval : chute %DH% trop importante (maximum pour jet de surface : %maxDHS%, maximum pour jet plongeant : %maxDHP%)", "ERROR_VERIF_PAB_DHMAX_JET": "Cloison n°%N% : chute %DH% trop importante pour le jet ENUM_STRUCTUREJETTYPE_%jetType% (maximum : %maxDH%)",