Skip to content
Snippets Groups Projects
Commit 840cc4a2 authored by François Grand's avatar François Grand
Browse files

refactor: FieldSet class: rename getPropValue to getNubPropValue, setPropValue to setNubPropValue

refs #483
parent c88385a9
No related branches found
No related tags found
No related merge requests found
......@@ -89,8 +89,8 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit {
const prms = after.backupParameters();
// replace in-place to change properties (overkill)
// @WTF why only those two ?
newFs.setPropValue("structureType", after.properties.getPropValue("structureType"));
newFs.setPropValue("loiDebit", after.properties.getPropValue("loiDebit"));
newFs.setNubPropValue("structureType", after.properties.getPropValue("structureType"));
newFs.setNubPropValue("loiDebit", after.properties.getPropValue("loiDebit"));
// au cas où un des paramètres du fieldset source est en mode calcul,
// on met le paramètre copié en mode fixé (nghyd#567)
......
......@@ -140,9 +140,11 @@ export class FieldSet extends FormulaireElement implements Observer {
}
/**
* get associated nub property value
* @param key property name
* @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 {
private getNubPropValue(key: string, inSection: boolean = false): any {
if (inSection) {
return this.sectionProperties.getPropValue(key);
} else {
......@@ -150,7 +152,13 @@ export class FieldSet extends FormulaireElement implements Observer {
}
}
public setPropValue(key: string, val: any): boolean {
/**
* assign associated nub property
* @param key nub property name
* @param val value to assign with
* @returns true if property value has changed
*/
public setNubPropValue(key: string, val: any): boolean {
return this.properties.setPropValue(key, val, this);
}
......@@ -259,7 +267,7 @@ export class FieldSet extends FormulaireElement implements Observer {
private setSelectValueFromProperty(selectId: string, inSection: boolean = false) {
const selectField: SelectField = this.getFormulaireNodeById(selectId) as SelectField;
if (selectField) {
let propVal: any = this.getPropValue(selectField.associatedProperty, inSection);
let propVal: any = this.getNubPropValue(selectField.associatedProperty, inSection);
if (propVal === undefined) {
propVal = ""; // clodo bullet-proof loading
}
......@@ -288,7 +296,7 @@ export class FieldSet extends FormulaireElement implements Observer {
const ct: string = json["calcType"];
const currentCt = this.properties.getPropValue("calcType");
const calc_type: CalculatorType = currentCt ? currentCt : (ct ? CalculatorType[ct] : this.parentForm.calculatorType);
this.setPropValue("calcType", calc_type);
this.setNubPropValue("calcType", calc_type);
// parse fields once, so that SelectField elements are present
// when setting default properties below
......@@ -313,7 +321,7 @@ export class FieldSet extends FormulaireElement implements Observer {
if (enumClass) {
formalValue = enumClass[defaultValue];
}
this.setPropValue(prop, formalValue);
this.setNubPropValue(prop, formalValue);
}
}
}
......@@ -401,9 +409,9 @@ export class FieldSet extends FormulaireElement implements Observer {
const prop = (fe as SelectField).associatedProperty;
// for multiple select
if (Array.isArray(data.value)) {
this.setPropValue(prop, data.value.map((v: any) => v.value));
this.setNubPropValue(prop, data.value.map((v: any) => v.value));
} else {
this.setPropValue(prop, data.value.value);
this.setNubPropValue(prop, data.value.value);
}
}
}
......
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