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

refactor: move pab_table object (from calculator JSON configuration) processing to FormulairePab

parent 759af5cf
No related branches found
No related tags found
1 merge request!225Release v4.17.0
Pipeline #140077 passed
......@@ -22,7 +22,6 @@ import { DeepFieldsetIterator } from "../form-iterator/deep-fieldset-iterator";
import { TopFormulaireElementIterator } from "../form-iterator/top-element-iterator";
import { CalculatorResults } from "../../results/calculator-results";
import { ServiceFactory } from "../../services/service-factory";
import { PabTable } from "../elements/pab-table";
import { SelectEntry } from "../elements/select/select-entry";
import { SelectField } from "../elements/select/select-field";
import { DeepSelectFieldIterator } from "../form-iterator/deep-selectfield-iterator";
......@@ -216,13 +215,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
this.kids.push(fsc);
}
// @TODO move to FormulairePAB by overloading parseConfig()
private parse_pab_table(json: {}) {
const tab: PabTable = new PabTable(this);
tab.parseConfig(json);
this.kids.push(tab);
}
/**
* 1ère passe d'analyse de la configuration
*/
......@@ -246,6 +238,16 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
}
}
/**
* parse specific type from configuration file
* @param type object name
* @param confData object data
* @returns false if type is unknown
*/
protected parseConfigType(type: string, confData: any): boolean {
return false;
}
/**
* 2ème passe d'analyse de la configuration
*/
......@@ -278,12 +280,10 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
this.parse_template_container(conf, templates);
break;
case "pab_table": // not generic at all
this.parse_pab_table(conf);
break;
default:
throw new Error(`type d'objet de module de calcul ${type} non pris en charge`);
if (!this.parseConfigType(type, conf)) {
throw new Error(`type d'objet de module de calcul ${type} non pris en charge`);
}
}
}
......@@ -522,5 +522,5 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
this.compute();
}
public resetFormResults() {}
public resetFormResults() { }
}
......@@ -2,9 +2,9 @@ import { Pab, Result, VariatedDetails } from "jalhyd";
import { FormulaireDefinition } from "./form-definition";
import { PabResults } from "../../results/pab-results";
import { NgParameter, ParamRadioConfig } from "../elements/ngparam";
import { NgParameter } from "../elements/ngparam";
import { longestVarParam } from "../../util";
import { CalculatorResults } from "../../results/calculator-results";
import { PabTable } from "../elements/pab-table";
/**
* Formulaire pour les passes à bassins, inspiré du formulaire
......@@ -24,6 +24,18 @@ export class FormulairePab extends FormulaireDefinition {
return this.currentNub as Pab;
}
protected parseConfigType(type: string, confData: any): boolean {
switch (type) {
case "pab_table":
const tab: PabTable = new PabTable(this);
tab.parseConfig(confData);
this.kids.push(tab);
return true;
}
return false;
}
protected compute() {
this.runNubCalc(this.currentNub);
// reset variable index to avoid trying to access an index > 0 when nothing varies
......
  • David Dorchies :zany_face: @david.dorchies

    mentioned in issue #588 (closed)

    By Grand Francois on 2023-02-03T10:37:36 (imported from GitLab)

    ·

    mentioned in issue #588 (closed)

    By Grand Francois on 2023-02-03T10:37:36 (imported from GitLab)

    Toggle commit list
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