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

Déplacement / suppression de cloison / ouvrage

Showing with 57 additions and 33 deletions
+57 -33
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"W": "Gate opening", "W": "Gate opening",
"ZRAM": "Bottom elevation", "ZRAM": "Bottom elevation",
"ZRMB": "Mid-basin elevation", "ZRMB": "Mid-basin elevation",
"h1": "Head",
"fs_bassin": "Basin", "fs_bassin": "Basin",
"fs_cloison_aval": "Downstream wall", "fs_cloison_aval": "Downstream wall",
"bassin_container": "Basins", "bassin_container": "Basins",
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"W": "Ouverture de vanne", "W": "Ouverture de vanne",
"ZRAM": "Cote de radier amont", "ZRAM": "Cote de radier amont",
"ZRMB": "Cote de radier mi-bassin", "ZRMB": "Cote de radier mi-bassin",
"h1": "Charge",
"fs_bassin": "Bassin", "fs_bassin": "Bassin",
"fs_cloison_aval": "Cloison aval", "fs_cloison_aval": "Cloison aval",
"bassin_container": "Bassins", "bassin_container": "Bassins",
......
...@@ -81,8 +81,8 @@ export class DialogEditPabComponent { ...@@ -81,8 +81,8 @@ export class DialogEditPabComponent {
this.dialogRef.close({ this.dialogRef.close({
action: this.varAction, action: this.varAction,
variable: this.variable, variable: this.variable,
value: this.valueToSet, value: Number(this.valueToSet),
delta: this.delta, delta: Number(this.delta),
variableDetails: this.findVariableDetails(this.variable) variableDetails: this.findVariableDetails(this.variable)
}); });
} }
......
...@@ -127,6 +127,7 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -127,6 +127,7 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
return undefined; return undefined;
} }
/** returns true if the cell / row has a selectable item */ /** returns true if the cell / row has a selectable item */
public isSelectable(cellOrRow: any): boolean { public isSelectable(cellOrRow: any): boolean {
return ( return (
...@@ -253,6 +254,14 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -253,6 +254,14 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
} }
} }
// quick getter for 1st selected item
public get selectedItem() {
if (this.selectedItems.length === 0) {
throw new Error("get selectedItem() : no item selected");
}
return this.selectedItems[0];
}
// prevents Firefox to display weird cell border when ctrl+clicking // prevents Firefox to display weird cell border when ctrl+clicking
public preventCtrlClickBorder($event) { public preventCtrlClickBorder($event) {
if ($event.ctrlKey) { if ($event.ctrlKey) {
...@@ -367,13 +376,13 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -367,13 +376,13 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
// ------------- FIN TEST -------------------- // ------------- FIN TEST --------------------
this.buildTable(); this.refresh();
} }
/** /**
* Builds the editable data grid from the Pab model * Builds the editable data grid from the Pab model
*/ */
private buildTable() { private refresh() {
const maxNbDevices = this.findMaxNumberOfDevices(); const maxNbDevices = this.findMaxNumberOfDevices();
// 0. build spanned headers over real columns // 0. build spanned headers over real columns
...@@ -671,7 +680,7 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -671,7 +680,7 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
public get selectionIsOneDevice() { public get selectionIsOneDevice() {
return ( return (
this.selectedItems.length === 1 this.selectedItems.length === 1
&& this.selectedItems[0] instanceof Structure && this.selectedItem instanceof Structure
); );
} }
...@@ -694,12 +703,16 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -694,12 +703,16 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
* Returns true if there is at least one selected item, * Returns true if there is at least one selected item,
* and all selected items are walls * and all selected items are walls
*/ */
private onlyWallsAreSelected() { private onlyWallsAreSelected(excludeDownwall: boolean = true) {
let ok = false; let ok = false;
if (this.selectedItems.length > 0) { if (this.selectedItems.length > 0) {
ok = true; ok = true;
for (const s of this.selectedItems) { for (const s of this.selectedItems) {
ok = ok && (s instanceof ParallelStructure); if (excludeDownwall) {
ok = ok && (s instanceof Cloisons);
} else {
ok = ok && (s instanceof ParallelStructure);
}
} }
} }
return ok; return ok;
...@@ -719,46 +732,54 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -719,46 +732,54 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
} }
public get enableAddButton() { public get enableAddButton() {
return this.selectedItems.length === 1; return (
this.selectedItems.length === 1
&& this.selectedItem.parent // exclude downwall
);
} }
public get enableCopyButton() { public get enableCopyButton() {
return this.selectedItems.length === 1; return (
this.selectedItems.length === 1
&& this.selectedItem.parent // exclude downwall
);
} }
public get enableUpButton() { public get enableUpButton() {
return this.selectedItems.length === 1; return (
this.selectedItems.length === 1
&& this.selectedItem.parent
&& this.selectedItem.findPositionInParent() !== 0
);
} }
public get enableDownButton() { public get enableDownButton() {
return this.selectedItems.length === 1; return (
this.selectedItems.length === 1
&& this.selectedItem.parent
&& this.selectedItem.findPositionInParent() < (this.selectedItem.parent.getChildren().length - 1)
);
} }
public get enableRemoveButton() { public get enableRemoveButton() {
return this.selectedItems.length === 1; return (
// return this.selectedItems.length > 0; // too dangerous ? or @TODO ask confirmation ? this.selectedItems.length === 1
&& this.selectedItem.parent
&& this.selectedItem.parent.getChildren().length > 1
);
} }
/** /**
* returns true if "many" objects are selected: either more than one object, * returns true if at least one object is selected
* or a wall that contains more than one device
*/ */
public get enableEditPabButton() { public get enableEditPabButton() {
return ( return this.selectedItems.length > 0;
this.selectedItems.length > 0
// too restrictive ?
/* this.selectedItems.length > 1
|| (
this.selectedItems.length > 0
&& this.selectedItems[0] instanceof ParallelStructure
&& this.selectedItems[0].getChildren().length > 1
) */
);
} }
public onAddClick() { public onAddClick() {
console.log("Add !!!"); console.log("Add !!!");
/* const newChild = undefined;
this.selectedItem.parent.addChild(newChild, this.selectedItem.findPositionInParent()); */
} }
public onCopyClick() { public onCopyClick() {
...@@ -766,15 +787,18 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -766,15 +787,18 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
} }
public onMoveUpClick() { public onMoveUpClick() {
console.log("Move up !!!"); this.selectedItem.parent.moveChildUp(this.selectedItem);
this.refresh();
} }
public onMoveDownClick() { public onMoveDownClick() {
console.log("Move down !!!"); this.selectedItem.parent.moveChildDown(this.selectedItem);
this.refresh();
} }
public onRemoveClick() { public onRemoveClick() {
console.log("Remove !!!"); this.selectedItem.parent.deleteChild(this.selectedItem.findPositionInParent());
this.refresh();
} }
// show modal dialog for values edition // show modal dialog for values edition
...@@ -868,8 +892,8 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -868,8 +892,8 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
// apply modifications // apply modifications
dialogRef.afterClosed().subscribe(result => { dialogRef.afterClosed().subscribe(result => {
if (result) { if (result) {
console.log("Apply values in parent !!", result.action, result.variable, result.value, /* console.log("Apply values in parent !!", result.action, result.variable, result.value,
result.delta, result.variableDetails); result.delta, result.variableDetails); */
switch (result.action) { switch (result.action) {
case "set-value": case "set-value":
for (const s of this.selectedItems) { for (const s of this.selectedItems) {
...@@ -900,7 +924,6 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -900,7 +924,6 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
(result.variableDetails.last - result.variableDetails.first) (result.variableDetails.last - result.variableDetails.first)
/ (result.variableDetails.occurrences - 1) / (result.variableDetails.occurrences - 1)
); );
console.log(">>>> step", step);
interpolatedValues.push(result.variableDetails.first); interpolatedValues.push(result.variableDetails.first);
let currentValue: number = result.variableDetails.first; let currentValue: number = result.variableDetails.first;
for (let i = 0; i < result.variableDetails.occurrences - 2; i++) { for (let i = 0; i < result.variableDetails.occurrences - 2; i++) {
...@@ -908,7 +931,6 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -908,7 +931,6 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
interpolatedValues.push(Number(currentValue.toFixed(nDigits))); interpolatedValues.push(Number(currentValue.toFixed(nDigits)));
} }
interpolatedValues.push(result.variableDetails.last); interpolatedValues.push(result.variableDetails.last);
console.log(">>>> interp. values", interpolatedValues);
// apply // apply
let idx = 0; let idx = 0;
for (const s of this.selectedItems) { for (const s of this.selectedItems) {
......
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