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

Fix #221 - differenciate and localize children type in different parallel structures

parent 95d51dc2
No related branches found
No related tags found
1 merge request!57WIP: Resolve "Ajout du module "Passe à macro-rugosités complexe""
......@@ -6,7 +6,6 @@ import { ParamFieldLineComponent } from "../param-field-line/param-field-line.co
import { Field } from "../../formulaire/field";
import { InputField } from "../../formulaire/input-field";
import { SelectField } from "../../formulaire/select-field";
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";
......@@ -15,6 +14,8 @@ import { I18nService } from "../../services/internationalisation/internationalis
import { sprintf } from "sprintf-js";
import { capitalize } from "jalhyd";
@Component({
selector: "field-set",
templateUrl: "./field-set.component.html",
......@@ -331,6 +332,20 @@ export class FieldSetComponent implements DoCheck {
return this.i18nService.localizeText("INFO_FIELDSET_MOVE_DOWN");
}
/**
* Returns the localized name for the children type of the current Nub
* @param plural if true, will return plural name
*/
private childName(plural: boolean = false) {
const type: string = this._fieldSet.nub.parent.childrenType;
console.log(`Child type for nub ${this._fieldSet.nub.constructor.name} : ${type}`);
let k = "INFO_CHILD_TYPE_" + type.toUpperCase();
if (plural) {
k += "_PLUR";
}
return this.i18nService.localizeText(k);
}
/**
* clic sur le bouton ajouter
*/
......@@ -343,9 +358,11 @@ export class FieldSetComponent implements DoCheck {
}
let msg: string;
if (this.childrenToAdd === 1) {
msg = this.i18nService.localizeText("INFO_DEVICE_ADDED");
const cns = this.childName();
msg = sprintf(this.i18nService.localizeText("INFO_STUFF_ADDED"), cns);
} else {
msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_ADDED_N_TIMES"), this.childrenToAdd);
const cnp = this.childName(true);
msg = sprintf(this.i18nService.localizeText("INFO_STUFF_ADDED_N_TIMES"), this.childrenToAdd, cnp);
}
this.notifService.notify(msg);
this.childrenToAdd = 1; // reinit to avoid confusion
......@@ -363,10 +380,11 @@ export class FieldSetComponent implements DoCheck {
}
const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
let msg: string;
const cns = capitalize(this.childName());
if (this.childrenToAdd === 1) {
msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_COPIED"), pos);
msg = sprintf(this.i18nService.localizeText("INFO_STUFF_COPIED"), cns, pos);
} else {
msg = sprintf(this.i18nService.localizeText("INFO_DEVICE_COPIED_N_TIMES"), pos, this.childrenToAdd);
msg = sprintf(this.i18nService.localizeText("INFO_STUFF_COPIED_N_TIMES"), cns, pos, this.childrenToAdd);
}
this.notifService.notify(msg);
this.childrenToAdd = 1; // reinit to avoid confusion
......@@ -378,8 +396,9 @@ export class FieldSetComponent implements DoCheck {
private onRemoveClick() {
const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
this.removeFieldset.emit(this._fieldSet);
const cns = capitalize(this.childName());
this.notifService.notify(
sprintf(this.i18nService.localizeText("INFO_DEVICE_REMOVED"), pos)
sprintf(this.i18nService.localizeText("INFO_STUFF_REMOVED"), cns, pos)
);
}
......@@ -389,8 +408,9 @@ export class FieldSetComponent implements DoCheck {
private onMoveUpClick() {
const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
this.moveFieldsetUp.emit(this._fieldSet);
const cns = capitalize(this.childName());
this.notifService.notify(
sprintf(this.i18nService.localizeText("INFO_DEVICE_MOVED"), pos)
sprintf(this.i18nService.localizeText("INFO_STUFF_MOVED"), cns, pos)
);
}
......@@ -400,8 +420,9 @@ export class FieldSetComponent implements DoCheck {
private onMoveDownClick() {
const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1;
this.moveFieldsetDown.emit(this._fieldSet);
const cns = capitalize(this.childName());
this.notifService.notify(
sprintf(this.i18nService.localizeText("INFO_DEVICE_MOVED"), pos)
sprintf(this.i18nService.localizeText("INFO_STUFF_MOVED"), cns, pos)
);
}
......
......@@ -142,8 +142,7 @@ export class FormulaireMacrorugoCompound extends FormulaireBase {
public removeFieldset(fs: FieldSet) {
if (fs.nub instanceof MacroRugo) {
// suppression du sous-nub dans le Nub parent
this.deleteNub(fs.nub);
this.mrcNub.deleteChild(fs.nub.findPositionInParent());
// suppression du fieldset
this.fieldsetContainer.removeFieldset(fs);
......
......@@ -123,6 +123,16 @@
"INFO_DEVICE_MOVED": "Device #%s moved",
"INFO_DEVICE_REMOVED": "Device #%s removed",
"INFO_DEVICES_REMOVED": "%s device(s) removed",
"INFO_STUFF_ADDED": "1 %s added",
"INFO_STUFF_ADDED_N_TIMES": "%s %s added",
"INFO_STUFF_COPIED": "%s #%s copied",
"INFO_STUFF_COPIED_N_TIMES": "%s #%s copied %s times",
"INFO_STUFF_MOVED": "%s #%s moved",
"INFO_STUFF_REMOVED": "%s #%s removed",
"INFO_CHILD_TYPE_STRUCTURE": "device",
"INFO_CHILD_TYPE_STRUCTURE_PLUR": "devices",
"INFO_CHILD_TYPE_MACRORUGO": "apron",
"INFO_CHILD_TYPE_MACRORUGO_PLUR": "aprons",
"INFO_FIELDSET_ADD": "Add",
"INFO_FIELDSET_COPY": "Copy",
"INFO_FIELDSET_REMOVE": "Remove",
......
......@@ -123,6 +123,16 @@
"INFO_DEVICE_MOVED": "Ouvrage n°%s déplacé",
"INFO_DEVICE_REMOVED": "Ouvrage n°%s supprimé",
"INFO_DEVICES_REMOVED": "%s ouvrage(s) supprimé(s)",
"INFO_STUFF_ADDED": "1 %s ajouté(e)",
"INFO_STUFF_ADDED_N_TIMES": "%s %s ajouté(e)s",
"INFO_STUFF_COPIED": "%s n°%s copié(e)",
"INFO_STUFF_COPIED_N_TIMES": "%s n°%s copié(e) %s fois",
"INFO_STUFF_MOVED": "%s n°%s déplacé(e)",
"INFO_STUFF_REMOVED": "%s n°%s supprimé(e)",
"INFO_CHILD_TYPE_STRUCTURE": "ouvrage",
"INFO_CHILD_TYPE_STRUCTURE_PLUR": "ouvrages",
"INFO_CHILD_TYPE_MACRORUGO": "radier",
"INFO_CHILD_TYPE_MACRORUGO_PLUR": "radiers",
"INFO_FIELDSET_ADD": "Ajouter",
"INFO_FIELDSET_COPY": "Copier",
"INFO_FIELDSET_REMOVE": "Supprimer",
......
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