diff --git a/src/app/components/select-model-field-line/select-model-field-line.component.ts b/src/app/components/select-model-field-line/select-model-field-line.component.ts index f8887783567e54a3f3b05808e368c3fa5709672d..fdf8af94968c63ab73d9bd3868727ece34db8fee 100644 --- a/src/app/components/select-model-field-line/select-model-field-line.component.ts +++ b/src/app/components/select-model-field-line/select-model-field-line.component.ts @@ -80,7 +80,7 @@ export class SelectModelFieldLineComponent implements OnInit { public async createModel() { const f = await this._formService.createFormulaire(this._select.calcType); this.router.navigate(["/calculator", f.uid]); - // on ajoute un ouvrage aux modulex de type "parallèle" + // on ajoute un ouvrage aux modules de type "parallèle" for (const e of f.allFormElements) { if (e instanceof FieldsetContainer) { e.addFromTemplate(0); diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index cf5fa11d2796a9312962e8a0abc890305485488a..dd679776531c4cf0cd40287f96d078e460df5b95 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -272,7 +272,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs break; case "template_container": - console.log("parsing template container !", conf); this.parse_template_container(conf, templates); break; diff --git a/src/app/formulaire/definition/form-pb-cloison.ts b/src/app/formulaire/definition/form-pb-cloison.ts index d448f6a99c6935ef2011221aa607c5ecec0e04eb..90ac294ecd70010c4774e85033b3eaff38795a8c 100644 --- a/src/app/formulaire/definition/form-pb-cloison.ts +++ b/src/app/formulaire/definition/form-pb-cloison.ts @@ -17,26 +17,18 @@ export class FormulairePbCloison extends FormulaireParallelStructure { this._downstreamBasinSelectId = this.getOption(json, "downstreamBasinSelectId"); } - protected completeParse(json: {}, firstNotif: boolean = true) { + protected completeParse(json: {}) { super.completeParse(json); if (this._upstreamBasinSelectId) { const sel = this.getFormulaireNodeById(this._upstreamBasinSelectId); if (sel) { sel.addObserver(this); - if (firstNotif) { - // force 1st observation - (sel as SelectFieldNub).notifySelectValueChanged(); - } } } if (this._downstreamBasinSelectId) { const sel = this.getFormulaireNodeById(this._downstreamBasinSelectId); if (sel) { sel.addObserver(this); - if (firstNotif) { - // force 1st observation - (sel as SelectFieldNub).notifySelectValueChanged(); - } } } } @@ -64,13 +56,23 @@ export class FormulairePbCloison extends FormulaireParallelStructure { // empty "" data.value.value should return undefined, which is good for amont/aval const newBasin = pb.findChild(data.value.value) as PbBassin; if (sender.id === this._upstreamBasinSelectId) { - nub.bassinAmont = newBasin; + // remove and recreate wall (easier for pointers consistency) + const oldDownstreamBasin = nub.bassinAval; + pb.deleteChild(pb.findChildPosition(nub.uid)); + const newWall = new PbCloison(newBasin, oldDownstreamBasin); + pb.addChild(newWall); + this.currentNub = newWall; } else if (sender.id === this._downstreamBasinSelectId) { - nub.bassinAval = newBasin; + // remove and recreate wall (easier for pointers consistency) + const oldUpstreamBasin = nub.bassinAmont; + pb.deleteChild(pb.findChildPosition(nub.uid)); + const newWall = new PbCloison(oldUpstreamBasin, newBasin); + pb.addChild(newWall); + this.currentNub = newWall; } this.notifyObservers({ action: "updateBasin", - value: nub.uid // node to select on the schema + value: this._currentNub.uid // node to select on the schema }, this); } }