diff --git a/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json b/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json index 5a0c150cf9c02233b8d5abd537fc412bc73ea4d8..635eddb02d230554fcad691225d7e31a12c80108 100644 --- a/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json +++ b/src/app/calculators/macrorugo-compound/macrorugo-compound.en.json @@ -18,6 +18,7 @@ "BR": "Total width", "ZF1": "Apron elevation", "B": "Width", + "xCenter": "Mid-apron abscissa", "select_pass_type_0": "Multiple aprons", "select_pass_type_1": "Inclined apron" diff --git a/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json b/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json index 3bd851bf0359aa43851601ec6c23c903d6871146..c1999b7e5ec944fc6d435349606972bdeee00d47 100644 --- a/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json +++ b/src/app/calculators/macrorugo-compound/macrorugo-compound.fr.json @@ -18,6 +18,7 @@ "BR": "Largeur totale", "ZF1": "Cote de radier", "B": "Largeur", + "xCenter": "Abscisse du milieu du radier", "select_pass_type_0": "Radiers multiples", "select_pass_type_1": "Radier incliné" diff --git a/src/app/components/field-set/field-set.component.ts b/src/app/components/field-set/field-set.component.ts index e083be328855ac1108b0d4db1e0bbfe7e8058846..45601ca85c8dba22b59483725e2719d142a97c12 100644 --- a/src/app/components/field-set/field-set.component.ts +++ b/src/app/components/field-set/field-set.component.ts @@ -332,20 +332,6 @@ 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 */ @@ -358,10 +344,10 @@ export class FieldSetComponent implements DoCheck { } let msg: string; if (this.childrenToAdd === 1) { - const cns = this.childName(); + const cns = this.i18nService.childName(this._fieldSet.nub.parent); msg = sprintf(this.i18nService.localizeText("INFO_STUFF_ADDED"), cns); } else { - const cnp = this.childName(true); + const cnp = this.i18nService.childName(this._fieldSet.nub.parent, true); msg = sprintf(this.i18nService.localizeText("INFO_STUFF_ADDED_N_TIMES"), this.childrenToAdd, cnp); } this.notifService.notify(msg); @@ -380,7 +366,7 @@ export class FieldSetComponent implements DoCheck { } const pos = (this._fieldSet.parent as FieldsetContainer).getFieldsetPosition(this._fieldSet) + 1; let msg: string; - const cns = capitalize(this.childName()); + const cns = capitalize(this.i18nService.childName(this._fieldSet.nub.parent)); if (this.childrenToAdd === 1) { msg = sprintf(this.i18nService.localizeText("INFO_STUFF_COPIED"), cns, pos); } else { @@ -396,7 +382,7 @@ 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()); + const cns = capitalize(this.i18nService.childName(this._fieldSet.nub.parent)); this.notifService.notify( sprintf(this.i18nService.localizeText("INFO_STUFF_REMOVED"), cns, pos) ); @@ -408,7 +394,7 @@ 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()); + const cns = capitalize(this.i18nService.childName(this._fieldSet.nub.parent)); this.notifService.notify( sprintf(this.i18nService.localizeText("INFO_STUFF_MOVED"), cns, pos) ); @@ -420,7 +406,7 @@ 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()); + const cns = capitalize(this.i18nService.childName(this._fieldSet.nub.parent)); this.notifService.notify( sprintf(this.i18nService.localizeText("INFO_STUFF_MOVED"), cns, pos) ); diff --git a/src/app/components/fixedvar-results/fixed-results.component.ts b/src/app/components/fixedvar-results/fixed-results.component.ts index 6a38cb84eb649a562e81824f6f98a479291ab40a..411f4f8338115f21f27c770031b99189087d4d37 100644 --- a/src/app/components/fixedvar-results/fixed-results.component.ts +++ b/src/app/components/fixedvar-results/fixed-results.component.ts @@ -5,10 +5,14 @@ import { NgParameter } from "../../formulaire/ngparam"; import { CalculatorResults } from "../../results/calculator-results"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; -import * as XLSX from "xlsx"; -import { Structure } from "jalhyd"; import { FormulaireService } from "../../services/formulaire/formulaire.service"; +import { Structure, Nub, capitalize } from "jalhyd"; + +import * as XLSX from "xlsx"; + +import { sprintf } from "sprintf-js"; + @Component({ selector: "fixed-results", templateUrl: "./fixed-results.component.html", @@ -122,8 +126,9 @@ export class FixedResultsComponent { if (sn.parent) { ct = sn.parent.calcType; } + const cn = capitalize(this.intlService.childName(sn)); data.push({ - label: this.intlService.localizeText("INFO_OUVRAGE_N") + label: sprintf(this.intlService.localizeText("INFO_STUFF_N"), cn) + (c.findPositionInParent() + 1) + " : " + this.formService.expandVariableNameAndUnit(ct, k), value: this.intlService.formatResult(k, er), diff --git a/src/app/formulaire/definition/form-compute-fixedvar.ts b/src/app/formulaire/definition/form-compute-fixedvar.ts index 00d5793b3e0b26a34340904c1e2e504c371b8b3e..ede113a8f4642f79c55cabad5847cbcd634f4f8f 100644 --- a/src/app/formulaire/definition/form-compute-fixedvar.ts +++ b/src/app/formulaire/definition/form-compute-fixedvar.ts @@ -29,7 +29,12 @@ export class FormComputeFixedVar extends FormCompute { } private getComputedParameter(): NgParameter { - return this._formBase.getDisplayedParamFromState(ParamRadioConfig.CAL); + const cpd = this._formBase.currentNub.calculatedParam; + let ngparam = this._formBase.getParamFromSymbol(cpd.symbol); + if (ngparam === undefined) { // calculated parameter is not displayed on screen + ngparam = new NgParameter(cpd, this._formBase); + } + return ngparam; } protected compute() { diff --git a/src/app/results/calculator-results.ts b/src/app/results/calculator-results.ts index 36f23984c93504e36b34a31fa7ff71ff3db16189..0fcc1c0901c576fa9c3a357d30d12044cd94fa93 100644 --- a/src/app/results/calculator-results.ts +++ b/src/app/results/calculator-results.ts @@ -1,11 +1,13 @@ +import { Nub, capitalize } from "jalhyd"; + import { NgParameter } from "../formulaire/ngparam"; -import { Nub } from "jalhyd"; import { ServiceFactory } from "../services/service-factory"; +import { sprintf } from "sprintf-js"; + export abstract class CalculatorResults { /** - * * @param p parameter to generate label for * @param displaySymbol if true, will prefix label with parameter symbol (ex: "ZDV") * @param referenceNub if given, will detect if parameter belongs to a child of this reference Nub, and @@ -18,10 +20,11 @@ export abstract class CalculatorResults { if (referenceNub) { const children = referenceNub.getChildren(); const parameterNub = p.paramDefinition.parentNub; + const cn = capitalize(ServiceFactory.instance.i18nService.childName(parameterNub)); if (children.includes(parameterNub)) { isChildParam = true; const pos = parameterNub.findPositionInParent() + 1; - res = ServiceFactory.instance.i18nService.localizeText("INFO_OUVRAGE_N") + pos + " : "; + res = sprintf(ServiceFactory.instance.i18nService.localizeText("INFO_OUVRAGE_N"), cn) + pos + " : "; } } if (displaySymbol && ! isChildParam) { diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts index a3823065caa4db96c3939c878bbf3f37387fa36d..f0354dad793c8b6e328e3f7b0cca0ca953abbc63 100644 --- a/src/app/results/var-results.ts +++ b/src/app/results/var-results.ts @@ -1,11 +1,13 @@ import { CalculatorResults } from "./calculator-results"; import { CalculatedParamResults } from "./param-calc-results"; import { NgParameter } from "../formulaire/ngparam"; -import { ResultElement, ParamFamily } from "jalhyd"; +import { ResultElement, ParamFamily, capitalize } from "jalhyd"; import { ServiceFactory } from "../services/service-factory"; import { PlottableData } from "./plottable-data"; import { GraphType } from "./graph-type"; +import { sprintf } from "sprintf-js"; + export class VarResults extends CalculatedParamResults implements PlottableData { /** * paramètres variés @@ -132,7 +134,8 @@ export class VarResults extends CalculatedParamResults implements PlottableData const pos = +match[1]; ct = sn.getChildren()[pos].calcType; symbol = match[2]; - ret += ServiceFactory.instance.i18nService.localizeText("INFO_OUVRAGE_N") + (pos + 1) + " : "; + const cn = capitalize(ServiceFactory.instance.i18nService.childName(sn)); + ret += sprintf(ServiceFactory.instance.i18nService.localizeText("INFO_STUFF_N"), cn) + (pos + 1) + " : "; } ret += ServiceFactory.instance.formulaireService.expandVariableNameAndUnit(ct, symbol); return ret; @@ -360,10 +363,11 @@ export class VarResults extends CalculatedParamResults implements PlottableData // entêtes des résultats des enfants for (const c of sn.getChildren()) { if (c.result) { + const cn = capitalize(ServiceFactory.instance.i18nService.childName(sn)); // using latest ResultElement; results count / types are supposed to be the same on every iteration for (const k of c.result.resultElement.keys) { this._resultHeaders.push( - ServiceFactory.instance.i18nService.localizeText("INFO_OUVRAGE_N") + sprintf(ServiceFactory.instance.i18nService.localizeText("INFO_STUFF_N"), cn) + (c.findPositionInParent() + 1) + " : " + ServiceFactory.instance.formulaireService.expandVariableNameAndUnit(c.calcType, k) ); diff --git a/src/app/services/internationalisation/internationalisation.service.ts b/src/app/services/internationalisation/internationalisation.service.ts index 7590f251dc3410941b9a04f7e86204ec92d69636..23621adbe0ffaa70384e566b6094dc63e2b03c6e 100644 --- a/src/app/services/internationalisation/internationalisation.service.ts +++ b/src/app/services/internationalisation/internationalisation.service.ts @@ -1,6 +1,6 @@ import { Injectable, isDevMode } from "@angular/core"; -import { Message, MessageCode, Observable, Observer, CalculatorType, LoiDebit } from "jalhyd"; +import { Message, MessageCode, Observable, Observer, CalculatorType, LoiDebit, Nub } from "jalhyd"; import { StringMap } from "../../stringmap"; import { ApplicationSetupService } from "../app-setup/app-setup.service"; @@ -201,6 +201,19 @@ export class I18nService extends Observable implements Observer { return value.toFixed(nDigits); } + /** + * Returns the localized name for the children type of the current Nub + * @param plural if true, will return plural name + */ + public childName(nub: Nub, plural: boolean = false) { + const type: string = nub.childrenType; + let k = "INFO_CHILD_TYPE_" + type.toUpperCase(); + if (plural) { + k += "_PLUR"; + } + return this.localizeText(k); + } + // interface Observer /** diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 4a82cf001f820829bdb0bc33d08be21ad6847a80..2a22bfec4f7bebded07d452c98d64832a21e54c0 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -129,6 +129,7 @@ "INFO_STUFF_COPIED_N_TIMES": "%s #%s copied %s times", "INFO_STUFF_MOVED": "%s #%s moved", "INFO_STUFF_REMOVED": "%s #%s removed", + "INFO_STUFF_N": "%s #", "INFO_CHILD_TYPE_STRUCTURE": "device", "INFO_CHILD_TYPE_STRUCTURE_PLUR": "devices", "INFO_CHILD_TYPE_MACRORUGO": "apron", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index f60e1d225dfa647463226d7ed9c5c66206a6e2c2..7155a166c943a663b5293115fefde1ceb7d45522 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -129,6 +129,7 @@ "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_STUFF_N": "%s n°", "INFO_CHILD_TYPE_STRUCTURE": "ouvrage", "INFO_CHILD_TYPE_STRUCTURE_PLUR": "ouvrages", "INFO_CHILD_TYPE_MACRORUGO": "radier",