Commit cf7bfec9 authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

Fix many problems in PreBarrage schema

do not replace walls when basins selectors value was not changed
when showing results, go back to input data after removing a wall or basin
Showing with 31 additions and 22 deletions
+31 -22
...@@ -337,6 +337,7 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni ...@@ -337,6 +337,7 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
this.unselect(); this.unselect();
this.refresh(); this.refresh();
this.clearResults(); this.clearResults();
this.calculatorComponent.showPBInputData = true;
} }
public get uitextRemove() { public get uitextRemove() {
......
...@@ -46,31 +46,39 @@ export class FormulairePbCloison extends FormulaireParallelStructure { ...@@ -46,31 +46,39 @@ export class FormulairePbCloison extends FormulaireParallelStructure {
// empty "" data.value.value should return undefined, which is good for amont/aval // empty "" data.value.value should return undefined, which is good for amont/aval
const newBasin = pb.findChild(data.value?.value) as PbBassin; const newBasin = pb.findChild(data.value?.value) as PbBassin;
if (sender.id === "select_upstream_basin") { if (sender.id === "select_upstream_basin") {
// remove and recreate wall (easier for pointers consistency) but preserve UID // update only if upstream basin changed (prevents updating on unwanted events)
const uid = nub.uid; if (newBasin?.uid !== nub.bassinAmont?.uid) {
const oldDownstreamBasin = nub.bassinAval; // remove and recreate wall (easier for pointers consistency) but preserve UID
pb.deleteChild(pb.findChildPosition(nub.uid)); const uid = nub.uid;
const newWall = new PbCloison(newBasin, oldDownstreamBasin); const oldDownstreamBasin = nub.bassinAval;
newWall.setUid(uid); pb.deleteChild(pb.findChildPosition(nub.uid));
// copy structures const newWall = new PbCloison(newBasin, oldDownstreamBasin);
for (const s of nub.structures) { newWall.setUid(uid);
newWall.addChild(s); // copy structures
for (const s of nub.structures) {
newWall.addChild(s);
}
pb.addChild(newWall);
this.currentNub = newWall;
this.reset();
} }
pb.addChild(newWall);
this.currentNub = newWall;
} else if (sender.id === "select_downstream_basin") { } else if (sender.id === "select_downstream_basin") {
// remove and recreate wall (easier for pointers consistency) but preserve UID // update only if downstream basin changed (prevents updating on unwanted events)
const uid = nub.uid; if (newBasin?.uid !== nub.bassinAval?.uid) {
const oldUpstreamBasin = nub.bassinAmont; // remove and recreate wall (easier for pointers consistency) but preserve UID
pb.deleteChild(pb.findChildPosition(nub.uid)); const uid = nub.uid;
const newWall = new PbCloison(oldUpstreamBasin, newBasin); const oldUpstreamBasin = nub.bassinAmont;
newWall.setUid(uid); pb.deleteChild(pb.findChildPosition(nub.uid));
// copy structures const newWall = new PbCloison(oldUpstreamBasin, newBasin);
for (const s of nub.structures) { newWall.setUid(uid);
newWall.addChild(s); // copy structures
for (const s of nub.structures) {
newWall.addChild(s);
}
pb.addChild(newWall);
this.currentNub = newWall;
this.reset();
} }
pb.addChild(newWall);
this.currentNub = newWall;
} }
this.notifyObservers({ this.notifyObservers({
action: "updateBasin", action: "updateBasin",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment