From 1cb7f6ffcf6c2e4b7d495b8451678bf45771f910 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 4 Jun 2019 10:22:55 +0200 Subject: [PATCH] Fix #222 --- .../field-set/field-set.component.ts | 36 +++++++++++++++++++ src/locale/messages.en.json | 8 ++++- src/locale/messages.fr.json | 6 ++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/app/components/field-set/field-set.component.ts b/src/app/components/field-set/field-set.component.ts index a2e401208..1a2a71700 100644 --- a/src/app/components/field-set/field-set.component.ts +++ b/src/app/components/field-set/field-set.component.ts @@ -10,6 +10,10 @@ import { SelectFieldModel } from "../../formulaire/select-field-model"; import { FormulairePab } from "../../formulaire/definition/concrete/form-pab"; import { SelectModelFieldLineComponent } from "../select-model-field-line/select-model-field-line.component"; import { FieldsetContainer } from "../../formulaire/fieldset-container"; +import { NotificationsService } from "../../services/notifications/notifications.service"; +import { I18nService } from "../../services/internationalisation/internationalisation.service"; + +import { sprintf } from "sprintf-js"; @Component({ selector: "field-set", @@ -140,6 +144,11 @@ export class FieldSetComponent implements DoCheck { @Output() protected tabPressed = new EventEmitter<any>(); + public constructor( + private notifService: NotificationsService, + private i18nService: I18nService + ) { } + private hasRadioFix(): boolean { if (this._fieldSet.hasInputs) { switch (this._fieldSet.getInput(0).radioConfig) { @@ -325,6 +334,13 @@ export class FieldSetComponent implements DoCheck { clone: false }); } + let msg: string; + if (this.childrenToAdd === 1) { + msg = this.i18nService.localizeText("INFO_FSC_FS_ADDED"); + } else { + msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_ADDED_N_TIMES"), this.childrenToAdd); + } + this.notifService.notify(msg); this.childrenToAdd = 1; // reinit to avoid confusion } @@ -338,6 +354,14 @@ export class FieldSetComponent implements DoCheck { clone: true }); } + 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); + } else { + msg = sprintf(this.i18nService.localizeText("INFO_FSC_FS_COPIED_N_TIMES"), pos, this.childrenToAdd); + } + this.notifService.notify(msg); this.childrenToAdd = 1; // reinit to avoid confusion } @@ -345,20 +369,32 @@ export class FieldSetComponent implements DoCheck { * clic sur le bouton supprimer */ private onRemoveClick() { + 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) + ); } /** * clic sur le bouton monter */ private onMoveUpClick() { + 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) + ); } /** * clic sur le bouton descendre */ private onMoveDownClick() { + 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) + ); } } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index b0c817f26..98f73af22 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -88,6 +88,12 @@ "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_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", "INFO_LIB_ALPHA": "Alpha coefficient", @@ -97,7 +103,7 @@ "INFO_LIB_BETA": "Beta coefficient", "INFO_LIB_BT": "Half opening of the triangle", "INFO_LIB_CD": "Discharge coefficient", - "INFO_LIB_CLOISON": "Cross wall n°", + "INFO_LIB_CLOISON": "Cross wall #", "INFO_LIB_CV": "Cv: Velocity coefficient", "INFO_LIB_CVQT": "CV.QT: Corrected discharge", "INFO_LIB_DH": "Fall", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 47a63e936..afca0043d 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -88,6 +88,12 @@ "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_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", "INFO_LIB_ALPHA": "Coefficient alpha", -- GitLab