diff --git a/src/app/calculators/parallel-structures/parallel-structures.config.json b/src/app/calculators/parallel-structures/parallel-structures.config.json index 0c90faf54a08e51b0198aadd3eef975686d5892f..928b882362a74e1121eb7718cffbfd620523196f 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.config.json +++ b/src/app/calculators/parallel-structures/parallel-structures.config.json @@ -4,6 +4,13 @@ "type": "fieldset", "option": "cal", "fields": [ + { + "type": "input", + "id": "Q", + "symbol": "Q", + "unit": "m³/s", + "value": 0.5 + }, { "type": "input", "id": "Z1", @@ -15,11 +22,55 @@ "id": "Z2", "unit": "m", "value": 1 + } + ] + }, + { + "id": "fs_struct_cem88d", + "type": "fieldset_template", + "structType": "Cem88d", + "option": "cal", + "fields": [ + { + "type": "input", + "id": "ZDV", + "unit": "m", + "value": 1 }, { "type": "input", - "id": "Q", - "unit": "m³/s", + "id": "L", + "unit": "m", + "value": 1 + }, + { + "type": "input", + "id": "Cd", + "value": 0.5 + } + ] + }, + { + "id": "fs_struct_cem88v", + "type": "fieldset_template", + "structType": "Cem88v", + "option": "cal", + "fields": [ + { + "type": "input", + "id": "ZDV", + "unit": "m", + "value": 1 + }, + { + "type": "input", + "id": "L", + "unit": "m", + "value": 1 + }, + { + "type": "input", + "id": "Cd", "value": 0.5 } ] @@ -36,7 +87,6 @@ ] }, { - "type": "options", - "idCal": "J" + "type": "options" } ] \ No newline at end of file diff --git a/src/app/calculators/parallel-structures/parallel-structures.fr.json b/src/app/calculators/parallel-structures/parallel-structures.fr.json index d2637fdbdc5b08f9e0cf205fe6aeb9083520a97e..4c1d1697f893db2a2974e35d058f97f94bf45fcc 100644 --- a/src/app/calculators/parallel-structures/parallel-structures.fr.json +++ b/src/app/calculators/parallel-structures/parallel-structures.fr.json @@ -1,8 +1,13 @@ { "fs_param_hydro": "Paramètres hydrauliques", + "Q": "Débit total", "Z1": "Cote amont", "Z2": "Cote aval", - "Q": "Débit total", + "fs_struct_cem88d": "Cem88d", + "ZDV": "Cote de la crête du déversoir ou du radier de la vanne", + "L": "Largeur du déversoir", + "Cd": "Coefficient de débit", + "fs_struct_cem88v": "Cem88v", "fs_param_calc": "Paramètres de calcul", "Pr": "Précision de calcul" } \ No newline at end of file diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 6e7911c5f879b38082bc0aa1de276688191b3bd2..5b007db69f72f12e97fc0046027a3d084b0b0d87 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -10,15 +10,22 @@ import { NgParameter } from "./ngparam"; export class FieldSet extends FormulaireElement { private _fields: Field[]; - constructor(nodeType: ComputeNodeType, id: string, formId: number) { + private _template: boolean; + + constructor(nodeType: ComputeNodeType, id: string, formId: number, tmpl: boolean) { super(nodeType, id, formId); this._fields = []; + this._template = tmpl; } public get fields() { return this._fields; } + public get isTemplate(): boolean { + return this._template; + } + public addField(f: Field) { this._fields.push(f); } diff --git a/src/app/formulaire/formulaire-definition.ts b/src/app/formulaire/formulaire-definition.ts index 3f174628fb284f4dac7b6fce8674ceeb144da1dd..b7292ecf2c23ab2428bbe9b01d185a3eb338a855 100644 --- a/src/app/formulaire/formulaire-definition.ts +++ b/src/app/formulaire/formulaire-definition.ts @@ -126,12 +126,15 @@ export class FormulaireDefinition extends Observable implements Observer { public getFieldSets(): FieldSet[] { let res: FieldSet[] = []; - if (this.hasSectionNodeTypeSelect) { - for (let fs of this._fieldSets) - if (fs.computeNodeType == this._sectionNodeType || fs.computeNodeType == ComputeNodeType.None) - res.push(fs); - } else { - res = this._fieldSets; + for (let fs of this._fieldSets) { + const ok = !fs.isTemplate && ( + !this.hasSectionNodeTypeSelect || + fs.computeNodeType == this._sectionNodeType || + fs.computeNodeType == ComputeNodeType.None + ); + if (ok) + res.push(fs); + } return res; @@ -509,21 +512,20 @@ export class FormulaireDefinition extends Observable implements Observer { return res; } - private parse_fieldset(fieldset: {}) { - const fs_id: string = fieldset["id"]; - const nt: string = fieldset["nodeType"]; + private parse_fieldset(json: {}) { + const fs_id: string = json["id"]; + const nt: string = json["nodeType"]; let node_type: ComputeNodeType = nt == undefined ? ComputeNodeType.None : ComputeNodeType[nt]; - const res: FieldSet = new FieldSet(node_type, fs_id, this._uid); + const res: FieldSet = new FieldSet(node_type, fs_id, this._uid, json["type"] == "fieldset_template"); this._fieldSets.push(res); - const fields = fieldset["fields"]; + const fields = json["fields"]; for (const field_index in fields) { const field = fields[field_index]; if (field["type"] === "input") { - const param = this.parse_input(node_type, fieldset, field); - if (param != undefined) - res.addField(param); + const param = this.parse_input(node_type, json, field); + res.addField(param); } else if (field["type"] === "select") { const param = this.parse_select(node_type, field); res.addField(param); @@ -533,7 +535,7 @@ export class FormulaireDefinition extends Observable implements Observer { } } - this.parse_dependencies(res, fieldset); + this.parse_dependencies(res, json); } private getOption(option: string): string { @@ -558,6 +560,7 @@ export class FormulaireDefinition extends Observable implements Observer { switch (type) { // field set case "fieldset": + case "fieldset_template": this.parse_fieldset(conf); break;