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

Improve #221

parent f4e946c7
No related branches found
No related tags found
1 merge request!57WIP: Resolve "Ajout du module "Passe à macro-rugosités complexe""
......@@ -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"
......
......@@ -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é"
......
......@@ -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)
);
......
......@@ -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),
......
......@@ -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() {
......
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) {
......
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)
);
......
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
/**
......
......@@ -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",
......
......@@ -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",
......
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