Skip to content
Snippets Groups Projects
Commit 2c4251c5 authored by francois.grand's avatar francois.grand
Browse files

#43 FieldsetTemplate : ajout de...

 #43 FieldsetTemplate : ajout de defaultStructTypeFromConfig/defaultLoiDebitFromConfig, implémentation de calcTypeFromConfig/defaultNodeTypeFromConfig sur le même modèle.
- FieldSet : suppression de defaultProps()/makeDefaultProps()
parent 143875c9
No related branches found
No related tags found
1 merge request!21Resolve "Ajout de la calculette "Dever""
......@@ -40,11 +40,17 @@ export class FormulaireParallelStructure extends FormulaireDefinition {
}
private createStructNub(templ: FieldsetTemplate): SessionNub {
// valeurs par défaut de CalculatorType, ComputeNodeType, StructureType, LoiDebit
// !!! attention !!! pour l'instant, il doit y avoir cohérence entre ces valeurs et celles du fichier de conf
// !!! attention !!!
// Il doit y avoir cohérence dans le fichier de conf entre les valeurs defaultXXX et les valeurs possibles pour les select
// cad valeur par défaut du 1er select (type d'ouvrage), du 2ème (loi de débit).
// A terme, il faudrait analyser le fichier de conf (dépendances d'existence) pour déterminer automatiquement ces valeurs
const params = FieldSet.makeDefaultProps(templ.calcTypeFromConfig, templ.defaultNodeTypeFromConfig);
const params = {};
params["calcType"] = templ.calcTypeFromConfig;
params["nodeType"] = templ.defaultNodeTypeFromConfig;
params["structureType"] = templ.defaultStructTypeFromConfig;
params["loiDebit"] = templ.defaultLoiDebitFromConfig;
return this.createSessionNub(params);
}
......
import { FieldSet } from "./fieldset";
import { CalculatorType, ComputeNodeType } from "jalhyd";
import { CalculatorType, ComputeNodeType, StructureType, LoiDebit } from "jalhyd";
import { FormulaireDefinition } from "./definition/form-definition";
import { FieldsetContainer } from "./fieldset-container";
......@@ -15,27 +15,23 @@ export class FieldsetTemplate {
}
public get calcTypeFromConfig(): CalculatorType {
for (const k in this._jsonConfig) {
if (k === "calcType") {
const ct: string = this._jsonConfig[k];
var calcType: CalculatorType = CalculatorType[ct];
break;
}
}
return calcType;
const ct: string = this._jsonConfig["calcType"];
return CalculatorType[ct];
}
public get defaultNodeTypeFromConfig(): ComputeNodeType {
for (const k in this._jsonConfig) {
if (k === "defaultNodeType") {
const nt: string = this._jsonConfig[k];
var nodeType: ComputeNodeType = ComputeNodeType[nt];
break;
}
}
return nodeType;
const nt: string = this._jsonConfig["defaultNodeType"];
return ComputeNodeType[nt];
}
public get defaultStructTypeFromConfig(): StructureType {
const st: string = this._jsonConfig["defaultStructType"];
return StructureType[st];
}
public get defaultLoiDebitFromConfig(): LoiDebit {
const ld: string = this._jsonConfig["defaultLoiDebit"];
return LoiDebit[ld];
}
/**
......
......@@ -121,39 +121,6 @@ export class FieldSet extends FormulaireElement implements Observer {
return this._props.setPropValue(key, val, this);
}
/**
* valeurs par défaut pour StructureType, LoiDebit en fonction d'un ComputeNodeType
*/
private static defaultProps(nodeType: ComputeNodeType): [StructureType, LoiDebit] {
let structType: StructureType;
let loiDebit: LoiDebit
switch (nodeType) {
case ComputeNodeType.StructureRectangle:
structType = StructureType.VanneRectangulaire;
loiDebit = LoiDebit.Cem88v;
break;
}
return [structType, loiDebit];
}
/**
* crée un objet Props servant de filtre pour sélectionner un Nub
* @param calcType
* @param nodeType
*/
public static makeDefaultProps(calcType: CalculatorType, nodeType: ComputeNodeType): Props {
const res: Props = new Props();
res.setPropValue("calcType", calcType);
res.setPropValue("nodeType", nodeType);
const p: [StructureType, LoiDebit] = FieldSet.defaultProps(nodeType);
res.setPropValue("structureType", p[0]);
res.setPropValue("loiDebit", p[1]);
return res;
}
private getNubParamFromSymbol(symbol: string): ParamDefinition {
return this._sessionNub.nub.getParameter(symbol);
}
......
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