diff --git a/src/app/components/pb-schema/pb-schema.component.ts b/src/app/components/pb-schema/pb-schema.component.ts index cd7ad1415ad9c8e27183d91a5423123ed31fb630..0dddab78b08f8ccded24d1421f06ae76c44c6185 100644 --- a/src/app/components/pb-schema/pb-schema.component.ts +++ b/src/app/components/pb-schema/pb-schema.component.ts @@ -266,12 +266,6 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni // store, to draw later sortedWalls.push(c); } - this.existingWalls[basinsPair]++; - // draw wall Node - def.push(`${c.uid}["${this.itemDesription(c)}"]`); // square edges - def.push(`class ${c.uid} wall;`); - // draw "arrow" with 2 lines - def.push(`${upstreamBasinId}---${c.uid}-->${downstreamBasinId}`); } // sort then draw walls sortedWalls.sort(this.triCloisonsGaucheDroite); @@ -382,17 +376,17 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni if (item instanceof PbCloison) { const upstreamBasinName = item.bassinAmont === undefined ? this.i18nService.localizeText("INFO_LIB_AMONT") - : "B" + (this.findBasinPosition(item.bassinAmont) + 1); + : "B" + (this.model.findBasinPosition(item.bassinAmont.uid) + 1); const downstreamBasinName = item.bassinAval === undefined ? this.i18nService.localizeText("INFO_LIB_AVAL") - : "B" + (this.findBasinPosition(item.bassinAval) + 1); + : "B" + (this.model.findBasinPosition(item.bassinAval.uid) + 1); desc = upstreamBasinName + "-" + downstreamBasinName; // if a similar wall already exists, suffix ! if (item.uid in this.wallsSuffixes) { desc += " (" + this.wallsSuffixes[item.uid] + ")"; } } else if (item instanceof PbBassin) { - desc = this.i18nService.localizeText("INFO_PB_BASSIN_N") + (this.findBasinPosition(item) + 1); + desc = this.i18nService.localizeText("INFO_PB_BASSIN_N") + (this.model.findBasinPosition(item.uid) + 1); } // else undefined return desc; } @@ -408,17 +402,6 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni }); } - private findBasinPosition(basin: PbBassin): number { - let i = 0; - for (const b of this.model.bassins) { - if (b === basin) { - break; - } - i++; - } - return i; - } - // at this time @Input data is supposed to be already populated public ngOnInit() { this.model = this.pbSchema.pb; @@ -508,14 +491,14 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni public get enableUpButton() { return ( this._selectedItem instanceof PbBassin - && this.findBasinPosition(this._selectedItem) !== 0 + && this.model.findBasinPosition(this._selectedItem.uid) !== 0 && this.isStandaloneBasin(this._selectedItem) ); } public onMoveBasinUpClick() { if (this._selectedItem instanceof PbBassin) { - this.model.moveBasin(this._selectedItem.uid, this.findBasinPosition(this._selectedItem) - 1); + this.model.moveBasin(this._selectedItem.uid, this.model.findBasinPosition(this._selectedItem.uid) - 1); } const basin = this._selectedItem; this.unselect(); @@ -530,14 +513,14 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni public get enableDownButton() { return ( this._selectedItem instanceof PbBassin - && this.findBasinPosition(this._selectedItem) !== this.model.bassins.length - 1 + && this.model.findBasinPosition(this._selectedItem.uid) !== this.model.bassins.length - 1 && this.isStandaloneBasin(this._selectedItem) ); } public onMoveBasinDownClick() { if (this._selectedItem instanceof PbBassin) { - this.model.moveBasin(this._selectedItem.uid, this.findBasinPosition(this._selectedItem) + 1); + this.model.moveBasin(this._selectedItem.uid, this.model.findBasinPosition(this._selectedItem.uid) + 1); } const basin = this._selectedItem; this.unselect();