Skip to content
Snippets Groups Projects
Commit 117f1d12 authored by François Grand's avatar François Grand
Browse files

refactor : do not create a Nub to get results units

refs #590
parent 3d6323b8
No related branches found
No related tags found
2 merge requests!225Release v4.17.0,!195Resolve "Optimiser l'affichage des unités"
......@@ -58,6 +58,7 @@ import { FormulaireEspece } from "../formulaire/definition/form-espece";
import { FormulairePrebarrage } from "../formulaire/definition/form-prebarrage";
import { ServiceFactory } from "./service-factory";
import { FormulairePressureLoss } from "app/formulaire/definition/form-pressureloss";
import { getNubResultUnit } from "jalhyd";
@Injectable()
export class FormulaireService extends Observable {
......@@ -194,7 +195,7 @@ export class FormulaireService extends Observable {
* Returns variable name and unit from symbol
* @param calcType
* @param symbol
* @param forceUnit if given, will be used as nuit
* @param forceUnit if given, will be used as unit
*/
public expandVariableNameAndUnit(calcType: CalculatorType, symbol: string, forceUnit?: string): string {
let s = this.expandVariableName(calcType, symbol);
......@@ -217,16 +218,8 @@ export class FormulaireService extends Observable {
if (forceUnit) {
unit = forceUnit;
} else {
// create dummy Nub from CalcType just to get results units
let dummyNub: Nub;
try {
dummyNub = Session.getInstance().createNub(new Props({ "calcType": calcType }));
} catch (e) {
// silent fail
}
if (dummyNub?.resultsUnits && dummyNub.resultsUnits[symbol]) {
unit = dummyNub.resultsUnits[symbol];
} else {
unit = getNubResultUnit(calcType, symbol);
if (unit === undefined) {
// last chance: if unit cannot be read in model, use translation files
const unitKey = "UNIT_" + symbolBase;
if (langCache && langCache[unitKey] !== undefined) {
......
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