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

[WIP] PbCloison form

parent 1bb75ca7
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import { PbSchema } from "../elements/pb-schema";
import { FormulaireDefinition } from "./form-definition";
import { ServiceFactory } from "../../services/service-factory";
import { FormulairePbCloison } from "./form-pb-cloison";
import { FieldsetContainer } from "../elements/fieldset-container";
/**
* Formulaire pour les PréBarrage
......@@ -100,12 +101,29 @@ export class FormulairePrebarrage extends FormulaireFixedVar {
this.showFormElements(this.basinForm);
} else if (node instanceof PbCloison) {
console.log("---------------> new wall form !!");
this.wallForm = new FormulairePbCloison();
this.wallForm.defaultProperties["calcType"] = CalculatorType.PbCloison;
this.wallForm.currentNub = node;
this.wallForm.preparseConfig(this.wallFormConfig);
this.wallForm.parseConfig(this.wallFormConfig);
this.wallForm.addObserver(this); // subscribe to upstream/downstream basin change
// add fieldsets for existing Structures
console.log(`Node ${node.uid} : ${node.structures.length} structures, Form ${this.uid} : ${this._kids.length} form elements`);
if (node.structures.length > 0) {
console.log(">> adding fieldsets for existing structures");
for (const struct of node.structures) {
for (const e of this.allFormElements) {
if (e instanceof FieldsetContainer) { // @TODO manage many containers one day ?
e.addFromTemplate(0, undefined, struct);
}
}
}
} else {
// if there was no existing structure, add a default one ! @TODO
console.log("TODO add default structure");
}
// subscribe to upstream/downstream basin change
this.wallForm.addObserver(this);
ServiceFactory.instance.formulaireService.loadUpdateFormulaireLocalisation(this.wallForm);
this.showFormElements(this.wallForm);
}
......
......@@ -5,7 +5,8 @@ import {
StructureType,
LoiDebit,
Session,
Solveur
Solveur,
StructureProperties
} from "jalhyd";
import { Field } from "./field";
......@@ -192,9 +193,12 @@ export class SelectField extends Field {
case "device_loi_debit":
// get current structure type from appropriate Nub child
const child = nub.getChildren()[this.parent.indexAsKid()];
const cst = child.properties.getPropValue("structureType");
const la = (nub as ParallelStructure).getLoisAdmissibles();
const stName = StructureType[cst];
const loiDebit = child.properties.getPropValue("loiDebit");
const stCode = StructureProperties.findCompatibleStructure(loiDebit, nub as ParallelStructure);
const stName = StructureType[stCode];
// console.log(`__device_loi_debit__ : child=${child.constructor.name}, loiDebit=${loiDebit}, stCode=${stCode}, stName=${stName}`);
// console.log("(child.properties)", child.properties.props);
for (const ld of la[stName]) {
const e: SelectEntry = new SelectEntry(this._entriesBaseId + LoiDebit[ld], ld);
this.addEntry(e);
......
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