diff --git a/src/app/components/field-set/field-set.component.ts b/src/app/components/field-set/field-set.component.ts index 16fa303ad0638ca81d7ce36e47c1487330818651..74655a86a74bb196f3b69160b5d8f7baa8eb9381 100644 --- a/src/app/components/field-set/field-set.component.ts +++ b/src/app/components/field-set/field-set.component.ts @@ -338,9 +338,9 @@ export class FieldSetComponent implements DoCheck { } let msg: string; if (this.childrenToAdd === 1) { - msg = this.i18nService.localizeText("INFO_FSC_FS_ADDED"); + msg = this.i18nService.localizeText("INFO_DEVICE_ADDED"); } 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.childrenToAdd = 1; // reinit to avoid confusion @@ -359,9 +359,9 @@ export class FieldSetComponent implements DoCheck { const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; let msg: string; if (this.childrenToAdd === 1) { - msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_COPIED"), pos); + msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_COPIED"), pos); } 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.childrenToAdd = 1; // reinit to avoid confusion @@ -374,7 +374,7 @@ export class FieldSetComponent implements DoCheck { const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; this.removeFieldset.emit(this._fieldSet); 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 { const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; this.moveFieldsetUp.emit(this._fieldSet); 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 { const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; this.moveFieldsetDown.emit(this._fieldSet); this.notifService.notify( - sprintf(this.i18nService.localizeText("INFO_FSC_FS_MOVED"), pos) + sprintf(this.i18nService.localizeText("INFO_DEVICE_MOVED"), pos) ); } } diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index 104699b8a881c77a96091934b7ba57b7f422c02d..162b5f89dca50f1e4f05ebce2db76c5ab3de591e 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -8,16 +8,19 @@ import { PabCloisons, Props, CalculatorType, - ParallelStructure, LoiDebit, Cloisons, Nub, - Structure + Structure, + ParallelStructure } from "jalhyd"; + import { sprintf } from "sprintf-js"; + import { I18nService } from "../../services/internationalisation/internationalisation.service"; import { FormulaireService } from "../../services/formulaire/formulaire.service"; import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; +import { NotificationsService } from "../../services/notifications/notifications.service"; import { PabTable } from "../../formulaire/pab-table"; import { DialogEditPabComponent } from "../dialog-edit-pab/dialog-edit-pab.component"; @@ -72,7 +75,8 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { private i18nService: I18nService, private formService: FormulaireService, private editPabDialog: MatDialog, - private appSetupService: ApplicationSetupService + private appSetupService: ApplicationSetupService, + private notifService: NotificationsService ) { this.selectedItems = []; } @@ -777,23 +781,61 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { } public onAddClick() { - console.log("Add !!!"); - /* const newChild = undefined; - this.selectedItem.parent.addChild(newChild, this.selectedItem.findPositionInParent()); */ - /* for (let i = 0; i < this.childrenToAdd; i++) { - this.selectedItem.parent.addChild() - } */ - /* let msg: string; + // add default item + for (let i = 0; i < this.childrenToAdd; i++) { + if (this.selectedItem instanceof Structure) { + // add new default device for wall parent + const newDevice = Session.getInstance().createNub( + new Props({ + 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) { - 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 { - 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 } public onCopyClick() { + // cloned selected item for (let i = 0; i < this.childrenToAdd; i++) { const newChild = Session.getInstance().createNub( this.selectedItem.properties.clone(), @@ -828,29 +870,58 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { ); } this.refresh(); - /* const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; + + // notify + const pos = this.selectedItem.findPositionInParent() + 1; let msg: string; 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 { - 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 } public onMoveUpClick() { + const pos = this.selectedItem.findPositionInParent() + 1; 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(); } public onMoveDownClick() { + const pos = this.selectedItem.findPositionInParent() + 1; 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(); } public onRemoveClick() { + const pos = this.selectedItem.findPositionInParent() + 1; 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(); } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 966ed52a836da1f6ab696d255ed3ed528e32f459..ee5a7fd05fc65eff9e727d0d8f91341433080259 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -97,12 +97,18 @@ "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_1": "Partially submerged", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Submerged", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Zero flow", - "INFO_FSC_FS_ADDED": "1 device added", - "INFO_FSC_FS_ADDED_N_TIMES": "%s devices added", - "INFO_FSC_FS_COPIED": "Device #%s copied", - "INFO_FSC_FS_COPIED_N_TIMES": "Device #%s copied %s times", - "INFO_FSC_FS_MOVED": "Device #%s moved", - "INFO_FSC_FS_REMOVED": "Device #%s removed", + "INFO_DEVICE_ADDED": "1 device added", + "INFO_DEVICE_ADDED_N_TIMES": "%s devices added", + "INFO_DEVICE_COPIED": "Device #%s copied", + "INFO_DEVICE_COPIED_N_TIMES": "Device #%s copied %s times", + "INFO_DEVICE_MOVED": "Device #%s moved", + "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": "Lechapt-Calmon", "INFO_LIB_ALPHA": "Alpha coefficient", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 8c6f7c1d832dc343c6d647d67bb7715c67b37b24..095711c8c5e9046a01c7dbda1811918a2bd3c39f 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -97,12 +97,18 @@ "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_1": "Partiellement noyé", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Noyé", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Débit nul", - "INFO_FSC_FS_ADDED": "1 ouvrage ajouté", - "INFO_FSC_FS_ADDED_N_TIMES": "%s ouvrages ajoutés", - "INFO_FSC_FS_COPIED": "Ouvrage n°%s copié", - "INFO_FSC_FS_COPIED_N_TIMES": "Ouvrage n°%s copié %s fois", - "INFO_FSC_FS_MOVED": "Ouvrage n°%s déplacé", - "INFO_FSC_FS_REMOVED": "Ouvrage n°%s supprimé", + "INFO_DEVICE_ADDED": "1 ouvrage ajouté", + "INFO_DEVICE_ADDED_N_TIMES": "%s ouvrages ajoutés", + "INFO_DEVICE_COPIED": "Ouvrage n°%s copié", + "INFO_DEVICE_COPIED_N_TIMES": "Ouvrage n°%s copié %s fois", + "INFO_DEVICE_MOVED": "Ouvrage n°%s déplacé", + "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": "Lechapt-Calmon", "INFO_LIB_ALPHA": "Coefficient alpha",