Skip to content
Snippets Groups Projects
Commit dcca9015 authored by Dorchies David's avatar Dorchies David
Browse files

Merge branch...

Merge branch '581-prebarrages-nom-des-bassins-non-definis-quand-on-selectionne-une-cloison' into 'devel'

Resolve "prébarrages : nom des bassins non définis quand on sélectionne une cloison"

Closes #581

See merge request !187
parents dbfeba3c abcd7d4e
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!187Resolve "prébarrages : nom des bassins non définis quand on sélectionne une cloison"
Pipeline #140030 passed
......@@ -12,12 +12,17 @@ export class SelectEntry {
/**
* texte affiché pour cette entrée
*/
public label: string;
private _label: string;
/**
* informations (code, symbole, ...) de traduction
*/
private _intlInfo: any;
constructor(id: string, val: any, lbl?: string) {
this._id = id;
this._value = val;
this.label = lbl; // redéfini par SelectField.updateLocalisation() plus tard
this._label = lbl;
}
get id(): string {
......@@ -27,4 +32,20 @@ export class SelectEntry {
get value(): any {
return this._value;
}
get label(): string {
return this._label;
}
set label(l: string) {
this._label = l;
}
public get intlInfo(): any {
return this._intlInfo;
}
public set intlInfo(i: any) {
this._intlInfo = i;
}
}
......@@ -7,7 +7,7 @@ import { SelectField } from "./select-field";
"id": "select_downstream_basin",
"type": "select_custom",
"source": "downstream_basin"
*/
*/
// PbCloisons, bassin aval
export class SelectFieldDownstreamBasin extends SelectField {
......@@ -19,27 +19,30 @@ export class SelectFieldDownstreamBasin extends SelectField {
for (const b of preBarrageD.bassins) {
const pos = b.findPositionInParent();
if (posUb === undefined || pos > posUb) {
this.addEntry(
new SelectEntry(
this._entriesBaseId + b.uid,
b.uid,
ServiceFactory.i18nService.localizeMessage(b.description)
)
);
const e = new SelectEntry(this._entriesBaseId + b.uid, b.uid);
e.intlInfo = b.description;
this.addEntry(e);
}
}
// river downstream
this.addEntry(
new SelectEntry(
this._entriesBaseId + "none",
undefined,
ServiceFactory.i18nService.localizeText("INFO_LIB_AVAL")
)
);
const e = new SelectEntry(this._entriesBaseId + "none", undefined);
e.intlInfo = "INFO_LIB_AVAL";
this.addEntry(e);
}
protected initSelectedValue() {
const db = (this.nub as PbCloison).bassinAval;
this.setValueFromId(this._entriesBaseId + (db ? db.uid : "none"));
}
public updateLocalisation() {
for (const e of this._entries) {
if (e.id === this._entriesBaseId + "none") {
e.label = ServiceFactory.i18nService.localizeText(e.intlInfo)
}
else {
e.label = ServiceFactory.i18nService.localizeMessage(e.intlInfo)
}
}
}
}
......@@ -24,27 +24,16 @@ export class SelectFieldSpeciesList extends SelectField {
const especeNubs = Session.getInstance().getAllNubs().filter((element) => element.calcType === CalculatorType.Espece);
for (const en of especeNubs) {
const form = ServiceFactory.formulaireService.getFormulaireFromNubId(en.uid);
this.addEntry(
new SelectEntry(
this._entriesBaseId + en.uid,
en.uid,
sprintf(
ServiceFactory.i18nService.localizeText("INFO_VERIFICATEUR_CUSTOM_SPECIES"),
form ? form.calculatorName : "*** form not loaded yet ***"
)
)
);
const e = new SelectEntry(this._entriesBaseId + en.uid, en.uid);
e.intlInfo = { "isnub": true, "code": "INFO_VERIFICATEUR_CUSTOM_SPECIES", "id": en.uid };
this.addEntry(e);
}
// add all FishSpecies
for (let j = 1; j < Object.keys(FishSpecies).length / 2; j++) { // exclude "0" (SPECIES_CUSTOM)
const spgId = FishSpecies[j].substring(FishSpecies[j].lastIndexOf("_") + 1);
this.addEntry(
new SelectEntry(
this._entriesBaseId + spgId,
FishSpecies[j],
ServiceFactory.i18nService.localizeText("INFO_ENUM_" + FishSpecies[j])
)
);
const e = new SelectEntry(this._entriesBaseId + spgId, FishSpecies[j]);
e.intlInfo = { "isnub": false, "code": FishSpecies[j] }
this.addEntry(e);
}
}
......@@ -61,5 +50,19 @@ export class SelectFieldSpeciesList extends SelectField {
public updateLocalisation() {
// do not override localisation done in populate()
// ie. avoid what is done by SelectField.updateLocalisation()
for (const e of this._entries) {
if (e.intlInfo.isnub) {
const id = e.intlInfo.id;
const form = ServiceFactory.formulaireService.getFormulaireFromNubId(id);
e.label = sprintf(
ServiceFactory.i18nService.localizeText(e.intlInfo.code),
form ? form.calculatorName : "*** form not loaded yet ***"
);
}
else {
e.label = ServiceFactory.i18nService.localizeText("INFO_ENUM_" + e.intlInfo.code);
}
}
}
}
......@@ -15,25 +15,19 @@ export class SelectFieldUpstreamBasin extends SelectField {
const pbWallU = this.parentForm.currentNub as PbCloison;
const preBarrageU = pbWallU.parent as PreBarrage;
const posDb = pbWallU.bassinAval?.findPositionInParent();
// river upstream
this.addEntry(
new SelectEntry(
this._entriesBaseId + "none",
undefined,
ServiceFactory.i18nService.localizeText("INFO_LIB_AMONT")
)
);
const e = new SelectEntry(this._entriesBaseId + "none", undefined);
e.intlInfo = "INFO_LIB_AMONT";
this.addEntry(e);
// all available basins, depending on current downstream basin
for (const b of preBarrageU.bassins) {
const pos = b.findPositionInParent();
if (posDb === undefined || pos < posDb) {
this.addEntry(
new SelectEntry(
this._entriesBaseId + b.uid,
b.uid,
ServiceFactory.i18nService.localizeMessage(b.description)
)
);
const e = new SelectEntry(this._entriesBaseId + b.uid, b.uid);
e.intlInfo = b.description;
this.addEntry(e);
}
}
}
......@@ -42,4 +36,14 @@ export class SelectFieldUpstreamBasin extends SelectField {
const ub = (this.nub as PbCloison).bassinAmont;
this.setValueFromId(this._entriesBaseId + (ub ? ub.uid : "none"));
}
public updateLocalisation() {
for (const e of this._entries) {
if (e.id === this._entriesBaseId + "none") {
e.label = ServiceFactory.i18nService.localizeText(e.intlInfo);
} else {
e.label = ServiceFactory.i18nService.localizeMessage(e.intlInfo);
}
}
}
}
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