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
this.unselect();
this.refresh();
this.clearResults();
this.calculatorComponent.showPBInputData = true;
}
public get uitextRemove() {
......
......@@ -46,31 +46,39 @@ 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 === "select_upstream_basin") {
// remove and recreate wall (easier for pointers consistency) but preserve UID
const uid = nub.uid;
const oldDownstreamBasin = nub.bassinAval;
pb.deleteChild(pb.findChildPosition(nub.uid));
const newWall = new PbCloison(newBasin, oldDownstreamBasin);
newWall.setUid(uid);
// copy structures
for (const s of nub.structures) {
newWall.addChild(s);
// update only if upstream basin changed (prevents updating on unwanted events)
if (newBasin?.uid !== nub.bassinAmont?.uid) {
// remove and recreate wall (easier for pointers consistency) but preserve UID
const uid = nub.uid;
const oldDownstreamBasin = nub.bassinAval;
pb.deleteChild(pb.findChildPosition(nub.uid));
const newWall = new PbCloison(newBasin, oldDownstreamBasin);
newWall.setUid(uid);
// 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") {
// remove and recreate wall (easier for pointers consistency) but preserve UID
const uid = nub.uid;
const oldUpstreamBasin = nub.bassinAmont;
pb.deleteChild(pb.findChildPosition(nub.uid));
const newWall = new PbCloison(oldUpstreamBasin, newBasin);
newWall.setUid(uid);
// copy structures
for (const s of nub.structures) {
newWall.addChild(s);
// update only if downstream basin changed (prevents updating on unwanted events)
if (newBasin?.uid !== nub.bassinAval?.uid) {
// remove and recreate wall (easier for pointers consistency) but preserve UID
const uid = nub.uid;
const oldUpstreamBasin = nub.bassinAmont;
pb.deleteChild(pb.findChildPosition(nub.uid));
const newWall = new PbCloison(oldUpstreamBasin, newBasin);
newWall.setUid(uid);
// 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({
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