Skip to content
Snippets Groups Projects
Commit d629e36b authored by David Dorchies's avatar David Dorchies
Browse files

Merge branch 'master' of gitlab-ssh.irstea.fr:cassiopee/nghyd

parents 3300d19a 4fafedd2
No related branches found
No related tags found
No related merge requests found
......@@ -88,8 +88,24 @@ export class FieldSet extends FormulaireElement implements Observer {
return this.nub.properties;
}
private getPropValue(key: string): any {
return this.properties.getPropValue(key);
private get sectionProperties(): Props {
const section = this.nub.getChildren()[0];
if (section) {
return section.properties;
} else {
return new Props();
}
}
/**
* @param inSection if true, will look for the required property in the Nub's section (children[0])
*/
private getPropValue(key: string, inSection: boolean = false): any {
if (inSection) {
return this.sectionProperties.getPropValue(key);
} else {
return this.properties.getPropValue(key);
}
}
public setPropValue(key: string, val: any): boolean {
......@@ -195,21 +211,12 @@ export class FieldSet extends FormulaireElement implements Observer {
case "fs_ouvrage":
this.setSelectValueFromProperty("select_structure", "structureType");
const st: StructureType = this.getPropValue("structureType");
switch (st) {
case StructureType.SeuilRectangulaire:
this.setSelectValueFromProperty("select_loidebit", "loiDebit");
break;
case StructureType.VanneRectangulaire:
this.setSelectValueFromProperty("select_loidebit", "loiDebit");
break;
}
this.setSelectValueFromProperty("select_loidebit", "loiDebit");
break;
case "fs_section":
this.setSelectValueFromProperty("select_section", "nodeType");
// property nodeType is stored in the section, not in the parent Nub
this.setSelectValueFromProperty("select_section", "nodeType", true);
break;
case "fs_param_calc":
......@@ -225,11 +232,15 @@ export class FieldSet extends FormulaireElement implements Observer {
/**
* Reflects a property value in the interface, through the value of a <select> field, if this select exists
* @param inSection if true, will look for the required property in the Nub's section (children[0])
*/
private setSelectValueFromProperty(selectId: string, propertyKey: string) {
private setSelectValueFromProperty(selectId: string, propertyKey: string, inSection: boolean = false) {
const selectField: SelectField = this.getFormulaireNodeById(selectId) as SelectField;
if (selectField) {
const propVal: any = this.getPropValue(propertyKey);
let propVal: any = this.getPropValue(propertyKey, inSection);
if (propVal === undefined) {
propVal = ""; // clodo bullet-proof loading
}
const selectElement = selectField.getSelectedEntryFromValue(propVal);
try {
selectField.setValue(selectElement);
......
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