Commit 3aab1ff2 authored by Grand Francois's avatar Grand Francois
Browse files

feat: predam schema: enable copy icon for basins (except upstream/downstream)

refs #522
Showing with 21 additions and 13 deletions
+21 -13
......@@ -476,14 +476,21 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
}
public get enableCopyButton() {
return this.predamService.isWallSelected();
// disable copy for upstream/downstream basins
return this._selectedItem !== this.predamService.upstreamBassin;
}
/** Copies a wall */
/** Copies a wall or a basin */
public onCopyClick() {
const wallCopy: PbCloison = this.predamService.copySelectedWall(ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit);
let copy: PbCloison | PbBassin;
if (this._selectedItem instanceof PbCloison) {
copy = this.predamService.copySelectedWall(ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit);
}
else {
copy = this.predamService.copySelectedBasin(ServiceFactory.applicationSetupService.enableEmptyFieldsOnFormInit);
}
this.clearResults();
this.refreshWithSelection(wallCopy.uid);
this.refreshWithSelection(copy.uid);
this.calculatorComponent.showPBInputData = true;
}
......
......@@ -80,6 +80,14 @@ export class PrebarrageService {
return newBasin;
}
public copySelectedBasin(emptyFields: boolean): PbBassin {
const basin = this._selectedNub as PbBassin;
const basinCopy = new PbBassin(new PbBassinParams(20, 99, emptyFields));
basinCopy.loadObjectRepresentation(basin.objectRepresentation());
this._model.addChild(basinCopy);
return basinCopy;
}
public get hasBasins(): boolean {
return this._model.bassins.length > 0;
}
......@@ -140,8 +148,8 @@ export class PrebarrageService {
private moveBasinDown(uid: string) {
this._model.moveBasin(uid, this._model.findBasinPosition(uid) + 1);
}
public moveSelectedBasinDown(){
public moveSelectedBasinDown() {
const uid = this._selectedNub.uid;
this.moveBasinDown(uid);
}
......@@ -199,11 +207,4 @@ export class PrebarrageService {
return this.model.findChild(itemId);
}
}
/**
* @returns true if selected nub is a wall
*/
public isWallSelected(): boolean {
return (this._selectedNub !== undefined && this._selectedNub instanceof PbCloison);
}
}
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