diff --git a/src/app/components/calculator-list/calculator-list.component.ts b/src/app/components/calculator-list/calculator-list.component.ts index dfbce4f92e9c27787eaa5b49a0f73478ca85981b..f05e933f0188edb8091ab220aeb57a3826a355bd 100644 --- a/src/app/components/calculator-list/calculator-list.component.ts +++ b/src/app/components/calculator-list/calculator-list.component.ts @@ -76,7 +76,7 @@ export class CalculatorListComponent implements OnInit { }; for (const t of unusedCalculators) { - if ( // those 2 sub-Nub types cannot be built outside a parent + if ( // those sub-Nub types cannot be built outside a parent t !== CalculatorType.Structure && t !== CalculatorType.Section && t !== CalculatorType.PabCloisons diff --git a/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.html b/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.html index 5e293865720bb633e1c9b7baac1643d7cbf2c8c3..de6505d96d9bfe006d011b5574be6854f1583ae2 100644 --- a/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.html +++ b/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.html @@ -17,7 +17,7 @@ <mat-icon>edit</mat-icon> </button> <button mat-icon-button *ngIf="entries.length === 0" (click)="createCloisons()"> - <mat-icon>add_circle_outline</mat-icon> + <mat-icon>add</mat-icon> </button> </div> diff --git a/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.ts b/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.ts index 3aa546880161f7c1dd54453cc8a32dfeab7c8be0..edfd03e33fcf607fad914bc35429248803f12ad6 100644 --- a/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.ts +++ b/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.ts @@ -41,7 +41,6 @@ export class SelectCloisonsFieldLineComponent implements OnInit { // called every time we navigate to the module ngOnInit(): void { - console.log("------------------------- SF dans le onInit", this._select.constructor.name); this._select.updateEntries(); } diff --git a/src/app/formulaire/definition/concrete/form-pab.ts b/src/app/formulaire/definition/concrete/form-pab.ts index 79a3192f4d7202efcdf9207164bf8b2bdd884d9f..59cd8f9988a9a401777ae08d70930530b559cda6 100644 --- a/src/app/formulaire/definition/concrete/form-pab.ts +++ b/src/app/formulaire/definition/concrete/form-pab.ts @@ -1,4 +1,4 @@ -import { Nub, Props, Session, PabCloisons, Pab } from "jalhyd"; +import { Nub, Props, Session, PabCloisons, Pab, Cloisons } from "jalhyd"; import { FormResultFixedVar } from "../form-result-fixedvar"; import { FieldsetContainer } from "../../fieldset-container"; @@ -32,16 +32,13 @@ export class FormulairePab extends FormulaireBase { return this._modeleCloisonsSelectId; } - private createPabCloisons(templ: FieldsetTemplate): Nub { - // !!! attention !!! - // Il doit y avoir cohérence dans le fichier de conf entre les valeurs defaultXXX et les valeurs possibles pour les select - // cad valeur par défaut du 1er select (type d'ouvrage), du 2ème (loi de débit). - // A terme, il faudrait analyser le fichier de conf (dépendances d'existence) pour déterminer automatiquement ces valeurs - + /** + * Creates a virgin PabCloisons when a new fieldset is added through the GUI, + * to ensure consistency; this object is not related to any Cloisons + */ + private createDummyPabCloisons(templ: FieldsetTemplate): Nub { const params = {}; params["calcType"] = templ.calcTypeFromConfig; - params["nodeType"] = templ.defaultNodeTypeFromConfig; - return this.createBassin(new Props(params)); } @@ -71,7 +68,7 @@ export class FormulairePab extends FormulaireBase { * @param params properties to build the new Nub (calcType, loiDebit...) */ protected replaceNub(sn: PabCloisons, params: Props): Nub { - const parent = (this.currentNub as PabCloisons); + const parent = (this.currentNub as Pab); const newBassin = this.createBassin(params); parent.replaceChildInplace(sn, newBassin); return newBassin; @@ -96,7 +93,7 @@ export class FormulairePab extends FormulaireBase { if (nub) { // use existing Nub (build interface based on model) n = nub; } else { - n = this.createPabCloisons(data["template"]); + n = this.createDummyPabCloisons(data["template"]); this.addPabCloisons(n as PabCloisons, after); } res.setNub(n, false); @@ -212,28 +209,40 @@ export class FormulairePab extends FormulaireBase { if (sender instanceof FieldsetContainer) { switch (data.action) { case "newFieldset": - console.log(">>>>>>>>> yeah new fieldset !", data); this.reset(); this.subscribeBasinFields(data["fieldset"]); } } else if (sender instanceof FieldSet && data.action === "propertyChange") { - console.log(">>>>>>>>> PAB property change !", data); switch (sender.id) { case "fs_bassin": - // @TODO set modelCloisons - - /* const props = sender.properties; - // ensure loiDebit is set - props.setPropValue("loiDebit", data.value); - this.adjustProperties(props, data["name"], data["value"]); - // replace Structure Nub - const newNub = this.replaceNub((sender.nub as Structure), props); - sender.setNub(newNub); - // treat the fieldset as new to re-subscribe to Nub properties change events - this.afterParseFieldset(sender); - this.reset(); */ + switch (data.name) { + case "modeleCloisons": + // change PabCloisons Nub property "modeleCloisons" and reinit it + // with new Cloisons values + const newModeleUID = sender.properties.getPropValue("modeleCloisons"); + sender.nub.properties.setPropValue("modeleCloisons", newModeleUID); + const cloisons = (Session.getInstance().findNubByUid(newModeleUID) as Cloisons); + (sender.nub as PabCloisons).initModelCloisons(cloisons); + // treat the fieldset as new to re-subscribe to Nub properties change events + this.afterParseFieldset(sender); + // this.reset(); + + // console.log(this.currentNub); + this.dumpPabStructure(this.currentNub as Pab); + break; + } break; } } } + + private dumpPabStructure(pab: Pab) { + console.log(`PAB: ${pab.uid}, ${pab.children.length} children`); + for (const c of pab.children) { + console.log( + ` * child: ${c.uid}, based on ${c.properties.getPropValue("modeleCloisons")}` + + ` (cote amont ${c.prms.Z1.singleValue}, longueur ${c.prms.LB.singleValue})` + ); + } + } } diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 41fd6a7acce5c4dd3bb2c0e7cd35e4c02c8978f1..797be11e576f88ee43c48d56903d1be19b972e88 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -378,7 +378,7 @@ export class FieldSet extends FormulaireElement implements Observer { case "select_target": // courbes de remous, variable à calculer this.setPropValue("varCalc", data.value.value); break; - case "select_modele_cloisons": // courbes de remous, variable à calculer + case "select_modele_cloisons": // passe à bassins, modèle de cloisons this.setPropValue("modeleCloisons", data.value.id); break; }