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

#27 : ajout du bouton d'ajout d'un ouvrage (dépendances non gérées)

parent 6d610fe6
No related branches found
No related tags found
1 merge request!12Resolve "Ajout de la calculette "Ouvrages hydrauliques""
......@@ -2,6 +2,7 @@
{
"id": "fs_param_hydro",
"type": "fieldset",
"calcType": "ParallelStructure",
"option": "cal",
"fields": [
{
......@@ -26,56 +27,130 @@
]
},
{
"id": "fs_struct_cem88d",
"id": "fs_ouvrage",
"type": "fieldset_template",
"calcType": "Structure",
"nodeType": "StructureRectangle",
"structType": "Cem88d",
"nodeType": "None",
"option": "cal",
"fields": [
{
"type": "input",
"id": "ZDV",
"unit": "m",
"value": 1
"id": "select_ouvrage",
"type": "select",
"select": [
{
"id": "select_ouvrage_vanne_rect"
},
{
"id": "select_ouvrage_vanne_circ"
},
{
"id": "select_ouvrage_seuil_rect"
},
{
"id": "select_ouvrage_seuil_trap"
},
{
"id": "select_ouvrage_vanne_trap"
}
]
},
{
"type": "input",
"id": "L",
"unit": "m",
"value": 1
"id": "select_loidebit1",
"type": "select",
"select": [
{
"id": "select_loidebit1_cemagref88"
},
{
"id": "select_loidebit1_vannedenoye"
},
{
"id": "select_loidebit1_vannenoye"
}
],
"dep_exist": [
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_rect"
},
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_circ"
},
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_seuil_rect"
}
]
},
{
"type": "input",
"id": "Cd",
"value": 0.5
}
]
},
{
"id": "fs_struct_cem88v",
"type": "fieldset_template",
"calcType": "Structure",
"nodeType": "StructureRectangle",
"structType": "Cem88v",
"option": "cal",
"fields": [
"id": "select_loidebit2",
"type": "select",
"select": [
{
"id": "select_loidebit2_cemagref88"
}
],
"dep_exist": [
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_seuil_trap"
},
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_trap"
}
]
},
{
"type": "input",
"id": "ZDV",
"id": "W",
"unit": "m",
"value": 1
"value": 0.5,
"dep_exist": [
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_rect"
},
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_circ"
}
]
},
{
"type": "input",
"id": "L",
"unit": "m",
"value": 1
"value": 2,
"nodeType": "StructureRectangle",
"dep_exist": [
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_rect"
},
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_circ"
}
]
},
{
"type": "input",
"id": "Cd",
"value": 0.5
"unit": "",
"value": 0.4,
"nodeType": "StructureRectangle",
"dep_exist": [
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_rect"
},
{
"refid": "select_ouvrage",
"refvalue": "select_ouvrage_vanne_circ"
}
]
}
]
},
......@@ -83,13 +158,13 @@
"id": "struct_container",
"type": "template_container",
"templates": [
"fs_struct_cem88d",
"fs_struct_cem88v"
"fs_ouvrage"
]
},
{
"id": "fs_param_calc",
"type": "fieldset",
"calcType": "ParallelStructure",
"option": "fix",
"fields": [
{
......@@ -101,4 +176,4 @@
{
"type": "options"
}
]
\ No newline at end of file
]
......@@ -3,12 +3,24 @@
"Q": "Débit total",
"Z1": "Cote amont",
"Z2": "Cote aval",
"fs_struct_cem88d": "Cem88d",
"fs_ouvrage": "Ouvrage",
"select_ouvrage": "Ouvrage",
"select_ouvrage_vanne_circ": "Vanne circulaire",
"select_ouvrage_vanne_rect": "Vanne rectangulaire",
"select_ouvrage_seuil_rect": "Seuil rectangulaire",
"select_ouvrage_seuil_trap": "Seuil trapézoïdal",
"select_ouvrage_vanne_trap": "Vanne trapézoïdale",
"W": "Ouverture de vanne",
"select_loidebit1": "Loi de débit",
"select_loidebit1_cemagref88": "Déversoir/Orifice Cemagref 88",
"select_loidebit1_vannedenoye": "Vanne dénoyé",
"select_loidebit1_vannenoye": "Vanne noyé",
"select_loidebit2": "Loi de débit",
"select_loidebit2_cemagref88": "Déversoir/Orifice Cemagref 88",
"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",
"struct_container": "Ouvrages",
"fs_param_calc": "Paramètres de calcul",
"Pr": "Précision de calcul"
}
\ No newline at end of file
}
......@@ -2,6 +2,10 @@
<div class="row">
<h4>{{title}}</h4>
</div>
</div>
<field-set *ngFor="let fs of fieldsets" [fieldSet]=fs>
</field-set>
<div class="row">
<!-- bouton d'ajout d'un ouvrage -->
<button type="button" class="btn btn-grey waves-light" mdbRippleRadius (click)="addStructure()">Ajouter un ouvrage</button>
</div>
<field-set *ngFor="let fs of fieldsets" [fieldSet]=fs>
</field-set>
</div>
\ No newline at end of file
......@@ -16,7 +16,11 @@ export class FieldsetContainerComponent {
return this._container.label;
}
private get fielsets() {
private get fieldsets() {
return this._container.fieldsets;
}
private addStructure() {
this._container.addFromTemplate(this._container.templates[0].id);
}
}
\ No newline at end of file
......@@ -3,10 +3,13 @@ import { ComputeNodeType } from "jalhyd";
import { FormulaireElement } from "./formulaire-element";
import { FieldSet } from "./fieldset";
import { Dependency } from "./dependency";
import { StringMap } from "../stringmap";
export class FieldsetContainer extends FormulaireElement {
private _templates: FieldSet[];
private _localisation: StringMap;
public title: string
constructor(id: string, formId: number) {
......@@ -44,14 +47,31 @@ export class FieldsetContainer extends FormulaireElement {
public addFromTemplate(templId: string) {
const templ: FieldSet = this.getTemplate(templId);
this._templates.push(templ.instanciateTemplate());
this.fieldsets.push(templ.instanciateTemplate());
this.updateLocalisation()
}
public get fieldsets(): FieldSet[] {
return this.kids as FieldSet[];
}
public get templates(): FieldSet[] {
return this._templates;
}
protected verifyDependency(d: Dependency): boolean {
return true;
}
public updateLocalisation(loc?: StringMap) {
if (loc == undefined)
loc = this._localisation;
else
this._localisation = loc;
super.updateLocalisation(loc);
for (let t of this._templates)
t.updateLocalisation(loc);
}
}
......@@ -507,6 +507,8 @@ export class FormulaireDefinition extends Observable implements Observer { //, I
dep.slaveValue = d["value"];
this._dependencies.push(dep);
}
else
throw new Error(`la dépendance de valeur de '${slave.id}' fait référence à un élément inconnu '${d["refid"]}'`);
}
}
......@@ -540,6 +542,8 @@ export class FormulaireDefinition extends Observable implements Observer { //, I
let dep = new ExistenceDependency(masterField, slave, mc);
this._dependencies.push(dep);
}
else
throw new Error(`la dépendance d'existence de '${slave.id}' fait référence à un élément inconnu '${d["refid"]}'`);
}
}
......@@ -583,8 +587,15 @@ export class FormulaireDefinition extends Observable implements Observer { //, I
return res;
}
private parse_input(calc_type: CalculatorType, node_type: ComputeNodeType, fieldset: {}, field: {}): NgParameter {
private parse_input(default_calc_type: CalculatorType, default_node_type: ComputeNodeType, fieldset: {}, field: {}): NgParameter {
let input_id: string = field["id"];
const ct: string = field["calcType"];
let calc_type: CalculatorType = ct == undefined ? default_calc_type : CalculatorType[ct];
const nt: string = field["nodeType"];
let node_type: ComputeNodeType = nt == undefined ? default_node_type : ComputeNodeType[nt];
let res: NgParameter = this.paramService.createParameter(calc_type, node_type, input_id, this._uid);
if (res == undefined)
throw new Error(`pas de paramètre '${input_id}' trouvé dans le noeud ${ComputeNodeType[node_type]} (${node_type}) ou ComputeNodeType.None`);
......@@ -636,6 +647,13 @@ export class FormulaireDefinition extends Observable implements Observer { //, I
this.parse_dependencies(res, json);
}
private getFieldsetTemplate(id: string) {
for (const t of this.topFieldsets)
if (t.id === id && t.isTemplate)
return t;
throw new Error(`Pas de template nommé '${id}'`);
}
private parse_template_container(json: {}) {
const fsc_id: string = json["id"];
......@@ -643,7 +661,7 @@ export class FormulaireDefinition extends Observable implements Observer { //, I
const templs: string[] = json["templates"];
for (const t of templs)
fsc.addTemplate(this.getFieldSet(t));
fsc.addTemplate(this.getFieldsetTemplate(t));
this.formElements.push(fsc);
}
......
......@@ -75,6 +75,11 @@ export abstract class FormulaireElement {
public updateLocalisation(loc: StringMap) {
this._label = loc[this.id];
if (this._label == undefined)
console.log(`WARNING : pas de traduction pour l'id ${this.id}`);
for (let f of this.kids)
f.updateLocalisation(loc);
}
public toString() {
......
......@@ -294,7 +294,8 @@ export class NgParameter extends InputField implements IObservable {
res._minValue = this._minValue;
res._maxValue = this._maxValue;
res._stepValue = this._stepValue;
res._valueList = this._valueList.slice(0); // copîe
if (this._valueList != undefined)
res._valueList = this._valueList.slice(0); // copie
return res;
}
......
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