Skip to content
Snippets Groups Projects
Commit 625530bc authored by Mathias Chouet's avatar Mathias Chouet Committed by mathias.chouet
Browse files

PreBarrage: move "standalone" basins

parent ff37917e
No related branches found
No related tags found
1 merge request!93Resolve "Ajout du module Prébarrage"
......@@ -21,13 +21,20 @@
{{ prefixedItemDescription }}
</span>
<button type="button" mat-icon-button color="primary" [disabled]="! enableCopyButton" (click)="onCopyClick()"
[title]="uitextCopy">
<mat-icon>content_copy</mat-icon>
</button>
[title]="uitextCopy">
<mat-icon>content_copy</mat-icon>
</button>
|
<button type="button" mat-icon-button color="primary" [disabled]="! enableRemoveButton" (click)="onRemoveClick()"
[title]="uitextRemove">
<mat-icon>delete</mat-icon>
</button>
<button type="button" mat-icon-button [disabled]="! enableUpButton" (click)="onMoveBasinUpClick()" [title]="uitextMoveBasinUp">
<mat-icon>arrow_upward</mat-icon>
</button>
<button type="button" mat-icon-button [disabled]="! enableDownButton" (click)="onMoveBasinDownClick()" [title]="uitextMoveBasinDown">
<mat-icon>arrow_downward</mat-icon>
</button>
<!--
|
<button type="button" mat-icon-button color="primary" (click)="exportAsSpreadsheet()"
......
......@@ -480,11 +480,64 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
});
}
public get uitextAddWall() {
return this.i18nService.localizeText("INFO_PB_ADD_WALL");
}
public get enableUpButton() {
return (
this._selectedItem instanceof PbBassin
&& this.findBasinPosition(this._selectedItem) !== 0
&& this.isStandaloneBasin(this._selectedItem)
);
}
public onMoveBasinUpClick() {
if (this._selectedItem instanceof PbBassin) {
this.model.moveBasin(this._selectedItem.uid, this.findBasinPosition(this._selectedItem) - 1);
}
this.refresh();
}
public get uitextMoveBasinUp() {
return this.i18nService.localizeText("INFO_PB_MOVE_BASIN_UP");
}
public get enableDownButton() {
return (
this._selectedItem instanceof PbBassin
&& this.findBasinPosition(this._selectedItem) !== 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.refresh();
}
public get uitextMoveBasinDown() {
return this.i18nService.localizeText("INFO_PB_MOVE_BASIN_DOWN");
}
/**
* Returns true if given basin is either connected to nothing, or only to
* river upstream or downstream
*/
private isStandaloneBasin(basin: PbBassin) {
return (
(
basin.cloisonsAmont.length === 0
|| basin.cloisonsAmont.map(c => c.bassinAmont).every(e => e === undefined)
) && (
basin.cloisonsAval.length === 0
|| basin.cloisonsAval.map(c => c.bassinAval).every(e => e === undefined)
)
);
}
/**
* Computes the global Pab validity : validity of every cell of every row
*/
......
......@@ -520,6 +520,8 @@
"INFO_PB_ADD_WALL": "Add new wall",
"INFO_PB_BASSIN_N": "Basin #",
"INFO_PB_CLOISON": "Wall",
"INFO_PB_MOVE_BASIN_UP": "Move basin up",
"INFO_PB_MOVE_BASIN_DOWN": "Move basin down",
"INFO_PB_NEW_WALL_SELECT_BASINS": "Select basins to connect",
"INFO_PB_NEW_WALL_UP_BASIN": "upstream basin",
"INFO_PB_NEW_WALL_DOWN_BASIN": "Downstream basin",
......
......@@ -521,6 +521,8 @@
"INFO_PB_ADD_WALL": "Ajouter une cloison",
"INFO_PB_BASSIN_N": "Bassin n°",
"INFO_PB_CLOISON": "Cloison",
"INFO_PB_MOVE_BASIN_UP": "Déplacer le bassin vers le haut",
"INFO_PB_MOVE_BASIN_DOWN": "Déplacer le bassin vers le bas",
"INFO_PB_NEW_WALL_SELECT_BASINS": "Choisir les bassins à connecter",
"INFO_PB_NEW_WALL_UP_BASIN": "Bassin amont",
"INFO_PB_NEW_WALL_DOWN_BASIN": "Bassin aval",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment