diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index c481e906e0ab8251a6e6747e2043cd0257b11088..a4a0732ea8f6a486ed9d65e973645ed4721c3078 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -269,7 +269,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); } }