From 83e9208767bf76b0493588a655df34398ec8ec82 Mon Sep 17 00:00:00 2001 From: Mathias Chouet <mathias.chouet@irstea.fr> Date: Mon, 22 Jun 2020 16:46:47 +0200 Subject: [PATCH] PreBarrage: move walls --- .../formulaire/definition/form-definition.ts | 1 - .../formulaire/definition/form-pb-cloison.ts | 26 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index c481e906e..a4a0732ea 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 d448f6a99..90ac294ec 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); } } -- GitLab