Skip to content
Snippets Groups Projects
Commit 3450cabd authored by mathias.chouet's avatar mathias.chouet
Browse files

Commandes pour cloner / ajouter des éléments, avec notifications

parent 8bc86d80
No related branches found
No related tags found
1 merge request!49Resolve "Ajout du module de calcul d'une passe à bassins"
...@@ -338,9 +338,9 @@ export class FieldSetComponent implements DoCheck { ...@@ -338,9 +338,9 @@ export class FieldSetComponent implements DoCheck {
} }
let msg: string; let msg: string;
if (this.childrenToAdd === 1) { if (this.childrenToAdd === 1) {
msg = this.i18nService.localizeText("INFO_FSC_FS_ADDED"); msg = this.i18nService.localizeText("INFO_DEVICE_ADDED");
} else { } else {
msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_ADDED_N_TIMES"), this.childrenToAdd); msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_ADDED_N_TIMES"), this.childrenToAdd);
} }
this.notifService.notify(msg); this.notifService.notify(msg);
this.childrenToAdd = 1; // reinit to avoid confusion this.childrenToAdd = 1; // reinit to avoid confusion
...@@ -359,9 +359,9 @@ export class FieldSetComponent implements DoCheck { ...@@ -359,9 +359,9 @@ export class FieldSetComponent implements DoCheck {
const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
let msg: string; let msg: string;
if (this.childrenToAdd === 1) { if (this.childrenToAdd === 1) {
msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_COPIED"), pos); msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_COPIED"), pos);
} else { } else {
msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_COPIED_N_TIMES"), pos, this.childrenToAdd); msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_COPIED_N_TIMES"), pos, this.childrenToAdd);
} }
this.notifService.notify(msg); this.notifService.notify(msg);
this.childrenToAdd = 1; // reinit to avoid confusion this.childrenToAdd = 1; // reinit to avoid confusion
...@@ -374,7 +374,7 @@ export class FieldSetComponent implements DoCheck { ...@@ -374,7 +374,7 @@ export class FieldSetComponent implements DoCheck {
const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
this.removeFieldset.emit(this._fieldSet); this.removeFieldset.emit(this._fieldSet);
this.notifService.notify( this.notifService.notify(
sprintf(this.i18nService.localizeText("INFO_FSC_FS_REMOVED"), pos) sprintf(this.i18nService.localizeText("INFO_DEVICE_REMOVED"), pos)
); );
} }
...@@ -385,7 +385,7 @@ export class FieldSetComponent implements DoCheck { ...@@ -385,7 +385,7 @@ export class FieldSetComponent implements DoCheck {
const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
this.moveFieldsetUp.emit(this._fieldSet); this.moveFieldsetUp.emit(this._fieldSet);
this.notifService.notify( this.notifService.notify(
sprintf(this.i18nService.localizeText("INFO_FSC_FS_MOVED"), pos) sprintf(this.i18nService.localizeText("INFO_DEVICE_MOVED"), pos)
); );
} }
...@@ -396,7 +396,7 @@ export class FieldSetComponent implements DoCheck { ...@@ -396,7 +396,7 @@ export class FieldSetComponent implements DoCheck {
const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
this.moveFieldsetDown.emit(this._fieldSet); this.moveFieldsetDown.emit(this._fieldSet);
this.notifService.notify( this.notifService.notify(
sprintf(this.i18nService.localizeText("INFO_FSC_FS_MOVED"), pos) sprintf(this.i18nService.localizeText("INFO_DEVICE_MOVED"), pos)
); );
} }
} }
...@@ -8,16 +8,19 @@ import { ...@@ -8,16 +8,19 @@ import {
PabCloisons, PabCloisons,
Props, Props,
CalculatorType, CalculatorType,
ParallelStructure,
LoiDebit, LoiDebit,
Cloisons, Cloisons,
Nub, Nub,
Structure Structure,
ParallelStructure
} from "jalhyd"; } from "jalhyd";
import { sprintf } from "sprintf-js";
import { I18nService } from "../../services/internationalisation/internationalisation.service"; import { I18nService } from "../../services/internationalisation/internationalisation.service";
import { FormulaireService } from "../../services/formulaire/formulaire.service"; import { FormulaireService } from "../../services/formulaire/formulaire.service";
import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; import { ApplicationSetupService } from "../../services/app-setup/app-setup.service";
import { NotificationsService } from "../../services/notifications/notifications.service";
import { PabTable } from "../../formulaire/pab-table"; import { PabTable } from "../../formulaire/pab-table";
import { DialogEditPabComponent } from "../dialog-edit-pab/dialog-edit-pab.component"; import { DialogEditPabComponent } from "../dialog-edit-pab/dialog-edit-pab.component";
...@@ -72,7 +75,8 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -72,7 +75,8 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
private i18nService: I18nService, private i18nService: I18nService,
private formService: FormulaireService, private formService: FormulaireService,
private editPabDialog: MatDialog, private editPabDialog: MatDialog,
private appSetupService: ApplicationSetupService private appSetupService: ApplicationSetupService,
private notifService: NotificationsService
) { ) {
this.selectedItems = []; this.selectedItems = [];
} }
...@@ -777,23 +781,61 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -777,23 +781,61 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
} }
public onAddClick() { public onAddClick() {
console.log("Add !!!"); // add default item
/* const newChild = undefined; for (let i = 0; i < this.childrenToAdd; i++) {
this.selectedItem.parent.addChild(newChild, this.selectedItem.findPositionInParent()); */ if (this.selectedItem instanceof Structure) {
/* for (let i = 0; i < this.childrenToAdd; i++) { // add new default device for wall parent
this.selectedItem.parent.addChild() const newDevice = Session.getInstance().createNub(
} */ new Props({
/* let msg: string; calcType: CalculatorType.Structure,
loiDebit: (this.selectedItem.parent as ParallelStructure).getDefaultLoiDebit()
})
);
this.selectedItem.parent.addChild(newDevice, this.selectedItem.findPositionInParent());
} else {
// add new default wall for PAB parent
const newWall = Session.getInstance().createNub(
new Props({
calcType: CalculatorType.Cloisons
})
);
// add new default device for new wall
const newDevice = Session.getInstance().createNub(
new Props({
calcType: CalculatorType.Structure,
loiDebit: (newWall as ParallelStructure).getDefaultLoiDebit()
})
);
newWall.addChild(newDevice);
this.model.addChild(newWall, this.selectedItem.findPositionInParent());
}
}
this.refresh();
// notify
const pos = this.selectedItem.findPositionInParent() + 1;
let msg: string;
if (this.childrenToAdd === 1) { if (this.childrenToAdd === 1) {
msg = this.i18nService.localizeText("INFO_FSC_FS_ADDED"); if (this.selectedItem instanceof Structure) {
msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_ADDED"), pos);
} else {
msg = sprintf(this.i18nService.localizeText("INFO_WALL_ADDED"), pos);
}
} else { } else {
msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_ADDED_N_TIMES"), this.childrenToAdd); if (this.selectedItem instanceof Structure) {
msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_ADDED_N_TIMES"), this.childrenToAdd);
} else {
msg = sprintf(this.i18nService.localizeText("INFO_WALL_ADDED_N_TIMES"), this.childrenToAdd);
}
} }
this.notifService.notify(msg); */ this.notifService.notify(msg);
this.childrenToAdd = 1; // reinit to avoid confusion this.childrenToAdd = 1; // reinit to avoid confusion
} }
public onCopyClick() { public onCopyClick() {
// cloned selected item
for (let i = 0; i < this.childrenToAdd; i++) { for (let i = 0; i < this.childrenToAdd; i++) {
const newChild = Session.getInstance().createNub( const newChild = Session.getInstance().createNub(
this.selectedItem.properties.clone(), this.selectedItem.properties.clone(),
...@@ -828,29 +870,58 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ...@@ -828,29 +870,58 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit {
); );
} }
this.refresh(); this.refresh();
/* const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
// notify
const pos = this.selectedItem.findPositionInParent() + 1;
let msg: string; let msg: string;
if (this.childrenToAdd === 1) { if (this.childrenToAdd === 1) {
msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_COPIED"), pos); if (this.selectedItem instanceof Structure) {
msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_COPIED"), pos);
} else {
msg = sprintf(this.i18nService.localizeText("INFO_WALL_COPIED"), pos);
}
} else { } else {
msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_COPIED_N_TIMES"), pos, this.childrenToAdd); if (this.selectedItem instanceof Structure) {
msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_COPIED_N_TIMES"), pos, this.childrenToAdd);
} else {
msg = sprintf(this.i18nService.localizeText("INFO_WALL_COPIED_N_TIMES"), pos, this.childrenToAdd);
}
} }
this.notifService.notify(msg); */ this.notifService.notify(msg);
this.childrenToAdd = 1; // reinit to avoid confusion this.childrenToAdd = 1; // reinit to avoid confusion
} }
public onMoveUpClick() { public onMoveUpClick() {
const pos = this.selectedItem.findPositionInParent() + 1;
this.selectedItem.parent.moveChildUp(this.selectedItem); this.selectedItem.parent.moveChildUp(this.selectedItem);
if (this.selectedItem instanceof Structure) {
this.notifService.notify(sprintf(this.i18nService.localizeText("INFO_DEVICE_MOVED"), pos));
} else {
this.notifService.notify(sprintf(this.i18nService.localizeText("INFO_WALL_MOVED"), pos));
}
this.refresh(); this.refresh();
} }
public onMoveDownClick() { public onMoveDownClick() {
const pos = this.selectedItem.findPositionInParent() + 1;
this.selectedItem.parent.moveChildDown(this.selectedItem); this.selectedItem.parent.moveChildDown(this.selectedItem);
if (this.selectedItem instanceof Structure) {
this.notifService.notify(sprintf(this.i18nService.localizeText("INFO_DEVICE_MOVED"), pos));
} else {
this.notifService.notify(sprintf(this.i18nService.localizeText("INFO_WALL_MOVED"), pos));
}
this.refresh(); this.refresh();
} }
public onRemoveClick() { public onRemoveClick() {
const pos = this.selectedItem.findPositionInParent() + 1;
this.selectedItem.parent.deleteChild(this.selectedItem.findPositionInParent()); this.selectedItem.parent.deleteChild(this.selectedItem.findPositionInParent());
if (this.selectedItem instanceof Structure) {
this.notifService.notify(sprintf(this.i18nService.localizeText("INFO_DEVICE_REMOVED"), pos));
} else {
this.notifService.notify(sprintf(this.i18nService.localizeText("INFO_WALL_REMOVED"), pos));
}
this.refresh(); this.refresh();
} }
......
...@@ -97,12 +97,18 @@ ...@@ -97,12 +97,18 @@
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_1": "Partially submerged", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_1": "Partially submerged",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Submerged", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Submerged",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Zero flow", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Zero flow",
"INFO_FSC_FS_ADDED": "1 device added", "INFO_DEVICE_ADDED": "1 device added",
"INFO_FSC_FS_ADDED_N_TIMES": "%s devices added", "INFO_DEVICE_ADDED_N_TIMES": "%s devices added",
"INFO_FSC_FS_COPIED": "Device #%s copied", "INFO_DEVICE_COPIED": "Device #%s copied",
"INFO_FSC_FS_COPIED_N_TIMES": "Device #%s copied %s times", "INFO_DEVICE_COPIED_N_TIMES": "Device #%s copied %s times",
"INFO_FSC_FS_MOVED": "Device #%s moved", "INFO_DEVICE_MOVED": "Device #%s moved",
"INFO_FSC_FS_REMOVED": "Device #%s removed", "INFO_DEVICE_REMOVED": "Device #%s removed",
"INFO_WALL_ADDED": "1 wall added",
"INFO_WALL_ADDED_N_TIMES": "%s walls added",
"INFO_WALL_COPIED": "Wall #%s copied",
"INFO_WALL_COPIED_N_TIMES": "Wall #%s copied %s times",
"INFO_WALL_MOVED": "Wall #%s moved",
"INFO_WALL_REMOVED": "Wall #%s removed",
"INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.",
"INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon",
"INFO_LIB_ALPHA": "Alpha coefficient", "INFO_LIB_ALPHA": "Alpha coefficient",
......
...@@ -97,12 +97,18 @@ ...@@ -97,12 +97,18 @@
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_1": "Partiellement noyé", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_1": "Partiellement noyé",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Noyé", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Noyé",
"INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Débit nul", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Débit nul",
"INFO_FSC_FS_ADDED": "1 ouvrage ajouté", "INFO_DEVICE_ADDED": "1 ouvrage ajouté",
"INFO_FSC_FS_ADDED_N_TIMES": "%s ouvrages ajoutés", "INFO_DEVICE_ADDED_N_TIMES": "%s ouvrages ajoutés",
"INFO_FSC_FS_COPIED": "Ouvrage n°%s copié", "INFO_DEVICE_COPIED": "Ouvrage n°%s copié",
"INFO_FSC_FS_COPIED_N_TIMES": "Ouvrage n°%s copié %s fois", "INFO_DEVICE_COPIED_N_TIMES": "Ouvrage n°%s copié %s fois",
"INFO_FSC_FS_MOVED": "Ouvrage n°%s déplacé", "INFO_DEVICE_MOVED": "Ouvrage n°%s déplacé",
"INFO_FSC_FS_REMOVED": "Ouvrage n°%s supprimé", "INFO_DEVICE_REMOVED": "Ouvrage n°%s supprimé",
"INFO_WALL_ADDED": "1 cloison ajoutée",
"INFO_WALL_ADDED_N_TIMES": "%s cloisons ajoutées",
"INFO_WALL_COPIED": "Cloison n°%s copiée",
"INFO_WALL_COPIED_N_TIMES": "Cloison n°%s copiée %s fois",
"INFO_WALL_MOVED": "Cloison n°%s déplacée",
"INFO_WALL_REMOVED": "Cloison n°%s supprimée",
"INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.",
"INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon",
"INFO_LIB_ALPHA": "Coefficient alpha", "INFO_LIB_ALPHA": "Coefficient alpha",
......
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