diff --git a/src/app/calculators/macrorugo-compound/macrorugo-compound.config.json b/src/app/calculators/macrorugo-compound/macrorugo-compound.config.json index 6a05f9cc338251e6f60fdd4eac090ff5c2d063c6..0f7bd8eaba74a133b3751173f7fefbd6f61e5f90 100644 --- a/src/app/calculators/macrorugo-compound/macrorugo-compound.config.json +++ b/src/app/calculators/macrorugo-compound/macrorugo-compound.config.json @@ -33,12 +33,16 @@ "id": "select_pass_type", "type": "select", "source": "mrc_pass_type" - } + }, + "ZRL", + "ZRR", + "BR" ] }, { "type": "options", "idCal": "Q", + "apronTypeSelectId": "select_pass_type", "help": "pam/macrorugo-compound" } ] \ No newline at end of file diff --git a/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json b/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json index dd0ba5be3fb865ac9b8f7014bbf03fdedaa3bb51..93e85029b66068a3973582025bb89fe466a6b354 100644 --- a/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json +++ b/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json @@ -11,6 +11,9 @@ "PBD": "Diameter", "PBH": "Height", "Cd0": "Shape (1 for round, 2 for square)", + "ZRL": "Left apron elevation", + "ZRR": "Right apron elevation", + "BR": "Total width", "select_pass_type_0": "Multiple aprons", "select_pass_type_1": "Inclined apron" diff --git a/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json b/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json index dc9c6c7f33835002d0a9e5dfccb05bacceb620f0..aafd40280e1fd314648582f7f3d652b257aa115b 100644 --- a/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json +++ b/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json @@ -10,6 +10,9 @@ "PBD": "Diamètre", "PBH": "Hauteur", "Cd0": "Forme (1 pour rond, 2 pour carré)", + "ZRL": "Cote de radier gauche", + "ZRR": "Cote de radier droite", + "BR": "Largeur totale", "select_pass_type_0": "Radiers multiples", "select_pass_type_1": "Radier incliné" diff --git a/src/app/formulaire/definition/concrete/form-macrorugo-compound.ts b/src/app/formulaire/definition/concrete/form-macrorugo-compound.ts index 6a9404d8f931a5244849576152dfef93b95d923b..8eda5e7e6210fcc85ce373b3ff7ea6201a25bd1e 100644 --- a/src/app/formulaire/definition/concrete/form-macrorugo-compound.ts +++ b/src/app/formulaire/definition/concrete/form-macrorugo-compound.ts @@ -3,25 +3,63 @@ import { FormulaireBase } from "./form-base"; import { FormResultFixedVar } from "../form-result-fixedvar"; import { FormComputeFixedVar } from "../form-compute-fixedvar"; +import { IObservable } from 'jalhyd'; +import { FieldSet } from '../../fieldset'; /** * Formulaire pour les passes à macrorugosités complexes */ export class FormulaireMacrorugoCompound extends FormulaireBase { + /** id of select configuring apron type */ + private _apronTypeSelectId: string; + constructor() { super(); this._formResult = new FormResultFixedVar(this); // default properties - this._props["inclinedApron"] = "1"; + this._props["inclinedApron"] = false; // remove obsolete observer set by super() this.removeObserver(this._formCompute); this._formCompute = new FormComputeFixedVar(this, (this._formResult as FormResultFixedVar)); } + protected parseOptions(json: {}) { + super.parseOptions(json); + this._apronTypeSelectId = this.getOption(json, "apronTypeSelectId"); + } + /* public get pabNub(): Pab { return this.currentNub as Pab; } */ + + public afterParseFieldset(fs: FieldSet) { + // if Fieldset contains apron type selector + if (this._apronTypeSelectId) { + const sel = fs.getFormulaireNodeById(this._apronTypeSelectId); + if (sel) { + // on abonne le formulaire aux propriétés du FieldSet + fs.properties.addObserver(this); + } + } + } + + // interface Observer + + update(sender: IObservable, data: any) { + if (sender instanceof FieldSet && data.action === "propertyChange") { + switch (data.name) { + case "inclinedApron": + // reflect changes in GUI + for (const fs of this.allFieldsets) { + // show / hide dependent fields + fs.updateFields(); + } + this.reset(); + break; + } + } + } } diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index ac30f3e420ed4510e7e65bec8918d7667b202bf9..053d95f2f0be0b0856c0c11b269935d71741a46e 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -246,7 +246,6 @@ export class FieldSet extends FormulaireElement implements Observer { } const selectElement = selectField.getSelectedEntryFromValue(propVal); try { - console.log(`setting propval ${propVal} (propKey ${propertyKey}) on select ${selectId}`, selectElement, selectField); selectField.setValue(selectElement); } catch (e) { console.error(`setSelectValueFromProperty: cannot set value ${propVal} on <select> ${selectId}`); diff --git a/src/app/formulaire/select-field.ts b/src/app/formulaire/select-field.ts index a4ad51902b1b669d24775581995246bee8b412b3..bcf8cc69c8a7b30cf1d1de10aa07ee2ca8c75aa2 100644 --- a/src/app/formulaire/select-field.ts +++ b/src/app/formulaire/select-field.ts @@ -159,8 +159,8 @@ export class SelectField extends Field { break; case "mrc_pass_type": // macrorugo complexe: type de radier - this.addEntry(new SelectEntry(this._entriesBaseId + "0", "0")); - this.addEntry(new SelectEntry(this._entriesBaseId + "1", "1")); + this.addEntry(new SelectEntry(this._entriesBaseId + "0", false)); + this.addEntry(new SelectEntry(this._entriesBaseId + "1", true)); break; } }