diff --git a/src/app/examples/pab-complete-chain.json b/src/app/examples/pab-complete-chain.json index ee99ec0c84eb4ae574ea2e265a18a22517ca8d9c..ca9e460f1ab42027a2d272a7918a39731084a71b 100644 --- a/src/app/examples/pab-complete-chain.json +++ b/src/app/examples/pab-complete-chain.json @@ -1 +1,570 @@ -{"header":{"source":"jalhyd","format_version":"1.1","created":"2019-09-06T08:40:17.092Z"},"session":[{"uid":"NjdmM3","props":{"calcType":"PabChute","nodeType":"None"},"meta":{"title":"PAB : chute"},"children":[],"parameters":[{"symbol":"Z1","mode":"SINGLE","value":29.99},{"symbol":"Z2","mode":"SINGLE","value":26.81},{"symbol":"DH","mode":"CALCUL"}]},{"uid":"eWNjdG","props":{"calcType":"PabNombre","nodeType":"None"},"meta":{"title":"PAB : nombre"},"children":[],"parameters":[{"symbol":"DHT","mode":"LINK","targetNub":"NjdmM3","targetParam":"DH"},{"symbol":"N","mode":"SINGLE","value":14},{"symbol":"DH","mode":"CALCUL"}]},{"uid":"dXM4em","props":{"calcType":"PabPuissance","nodeType":"None"},"meta":{"title":"PAB : puissance"},"children":[],"parameters":[{"symbol":"DH","mode":"LINK","targetNub":"eWNjdG","targetParam":"DH"},{"symbol":"Q","mode":"SINGLE","value":1.8},{"symbol":"V","mode":"CALCUL"},{"symbol":"PV","mode":"SINGLE","value":140}]},{"uid":"bzNlaX","props":{"calcType":"PabDimensions","nodeType":"None"},"meta":{"title":"PAB : dimensions"},"children":[],"parameters":[{"symbol":"L","mode":"SINGLE","value":5},{"symbol":"W","mode":"SINGLE","value":3.6},{"symbol":"Y","mode":"CALCUL"},{"symbol":"V","mode":"LINK","targetNub":"dXM4em","targetParam":"V"}]},{"uid":"cGI5d3","props":{"calcType":"Cloisons","nodeType":"None"},"meta":{"title":"Cloisons"},"children":[{"uid":"ZzZzbD","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier","nodeType":"None"},"children":[],"parameters":[{"symbol":"h1","mode":"CALCUL"},{"symbol":"L","mode":"SINGLE","value":0.5},{"symbol":"CdWSL","mode":"SINGLE","value":0.83}]}],"parameters":[{"symbol":"Q","mode":"LINK","targetNub":"dXM4em","targetParam":"Q"},{"symbol":"Z1","mode":"SINGLE","value":30.14},{"symbol":"LB","mode":"SINGLE","value":4.5},{"symbol":"BB","mode":"LINK","targetNub":"bzNlaX","targetParam":"W"},{"symbol":"PB","mode":"SINGLE","value":2.5},{"symbol":"DH","mode":"LINK","targetNub":"eWNjdG","targetParam":"DH"}]},{"uid":"Y3k4bj","props":{"calcType":"Pab"},"meta":{"title":"PAB"},"children":[{"uid":"ampiN3","props":{"calcType":"Cloisons","nodeType":"None"},"children":[{"uid":"Yzgxa2","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier","nodeType":"None"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":28.085},{"symbol":"L","mode":"SINGLE","value":0.5},{"symbol":"CdWSL","mode":"SINGLE","value":0.83}]}],"parameters":[{"symbol":"LB","mode":"SINGLE","value":4.5},{"symbol":"BB","mode":"SINGLE","value":3.6},{"symbol":"ZRMB","mode":"SINGLE","value":27.413},{"symbol":"ZRAM","mode":"SINGLE","value":27.526},{"symbol":"QA","mode":"SINGLE","value":0}]},{"uid":"c3RmMz","props":{"calcType":"Cloisons","nodeType":"None"},"children":[{"uid":"dmwyem","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier","nodeType":"None"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":27.858},{"symbol":"L","mode":"SINGLE","value":0.5},{"symbol":"CdWSL","mode":"SINGLE","value":0.83}]}],"parameters":[{"symbol":"LB","mode":"SINGLE","value":4.5},{"symbol":"BB","mode":"SINGLE","value":3.6},{"symbol":"ZRMB","mode":"SINGLE","value":27.186},{"symbol":"ZRAM","mode":"SINGLE","value":27.299},{"symbol":"QA","mode":"SINGLE","value":0}]},{"uid":"cTlydj","props":{"calcType":"Cloisons","nodeType":"None"},"children":[{"uid":"cWQ5aX","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier","nodeType":"None"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":27.631},{"symbol":"L","mode":"SINGLE","value":0.5},{"symbol":"CdWSL","mode":"SINGLE","value":0.83}]}],"parameters":[{"symbol":"LB","mode":"SINGLE","value":4.5},{"symbol":"BB","mode":"SINGLE","value":3.6},{"symbol":"ZRMB","mode":"SINGLE","value":26.959},{"symbol":"ZRAM","mode":"SINGLE","value":27.072},{"symbol":"QA","mode":"SINGLE","value":0}]},{"uid":"emRkMX","props":{"calcType":"Cloisons","nodeType":"None"},"children":[{"uid":"aG1xbj","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier","nodeType":"None"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":27.404},{"symbol":"L","mode":"SINGLE","value":0.5},{"symbol":"CdWSL","mode":"SINGLE","value":0.83}]}],"parameters":[{"symbol":"LB","mode":"SINGLE","value":4.5},{"symbol":"BB","mode":"SINGLE","value":3.6},{"symbol":"ZRMB","mode":"SINGLE","value":26.731},{"symbol":"ZRAM","mode":"SINGLE","value":26.845},{"symbol":"QA","mode":"SINGLE","value":0}]},{"uid":"eG9hdT","props":{"calcType":"Cloisons","nodeType":"None"},"children":[{"uid":"M3Z5ZX","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier","nodeType":"None"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":27.177},{"symbol":"L","mode":"SINGLE","value":0.5},{"symbol":"CdWSL","mode":"SINGLE","value":0.83}]}],"parameters":[{"symbol":"LB","mode":"SINGLE","value":4.5},{"symbol":"BB","mode":"SINGLE","value":3.6},{"symbol":"ZRMB","mode":"SINGLE","value":26.504},{"symbol":"ZRAM","mode":"SINGLE","value":26.618},{"symbol":"QA","mode":"SINGLE","value":0}]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":1.8},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"SINGLE","value":28.778}],"downWall":{"uid":"bWExN2","props":{"calcType":"CloisonAval"},"children":[{"uid":"bm0zcD","props":{"calcType":"Structure","structureType":"SeuilRectangulaire","loiDebit":"WeirSubmergedLarinier","nodeType":"None"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":26.95},{"symbol":"L","mode":"SINGLE","value":0.5},{"symbol":"CdWSL","mode":"SINGLE","value":0.83}]}],"parameters":[{"symbol":"ZRAM","mode":"SINGLE","value":26.391}]}}]} \ No newline at end of file +{ + "header": { + "source": "jalhyd", + "format_version": "1.1", + "created": "2019-09-06T08:40:17.092Z" + }, + "session": [ + { + "uid": "NjdmM3", + "props": { + "calcType": "PabChute" + }, + "meta": { + "title": "PAB : chute" + }, + "children": [], + "parameters": [ + { + "symbol": "Z1", + "mode": "SINGLE", + "value": 29.99 + }, + { + "symbol": "Z2", + "mode": "SINGLE", + "value": 26.81 + }, + { + "symbol": "DH", + "mode": "CALCUL" + } + ] + }, + { + "uid": "eWNjdG", + "props": { + "calcType": "PabNombre" + }, + "meta": { + "title": "PAB : nombre" + }, + "children": [], + "parameters": [ + { + "symbol": "DHT", + "mode": "LINK", + "targetNub": "NjdmM3", + "targetParam": "DH" + }, + { + "symbol": "N", + "mode": "SINGLE", + "value": 14 + }, + { + "symbol": "DH", + "mode": "CALCUL" + } + ] + }, + { + "uid": "dXM4em", + "props": { + "calcType": "PabPuissance" + }, + "meta": { + "title": "PAB : puissance" + }, + "children": [], + "parameters": [ + { + "symbol": "DH", + "mode": "LINK", + "targetNub": "eWNjdG", + "targetParam": "DH" + }, + { + "symbol": "Q", + "mode": "SINGLE", + "value": 1.8 + }, + { + "symbol": "V", + "mode": "CALCUL" + }, + { + "symbol": "PV", + "mode": "SINGLE", + "value": 140 + } + ] + }, + { + "uid": "bzNlaX", + "props": { + "calcType": "PabDimensions" + }, + "meta": { + "title": "PAB : dimensions" + }, + "children": [], + "parameters": [ + { + "symbol": "L", + "mode": "SINGLE", + "value": 5 + }, + { + "symbol": "W", + "mode": "SINGLE", + "value": 3.6 + }, + { + "symbol": "Y", + "mode": "CALCUL" + }, + { + "symbol": "V", + "mode": "LINK", + "targetNub": "dXM4em", + "targetParam": "V" + } + ] + }, + { + "uid": "cGI5d3", + "props": { + "calcType": "Cloisons" + }, + "meta": { + "title": "Cloisons" + }, + "children": [ + { + "uid": "ZzZzbD", + "props": { + "calcType": "Structure", + "structureType": "SeuilRectangulaire", + "loiDebit": "WeirSubmergedLarinier" + }, + "children": [], + "parameters": [ + { + "symbol": "h1", + "mode": "CALCUL" + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 0.5 + }, + { + "symbol": "CdWSL", + "mode": "SINGLE", + "value": 0.83 + } + ] + } + ], + "parameters": [ + { + "symbol": "Q", + "mode": "LINK", + "targetNub": "dXM4em", + "targetParam": "Q" + }, + { + "symbol": "Z1", + "mode": "SINGLE", + "value": 30.14 + }, + { + "symbol": "LB", + "mode": "SINGLE", + "value": 4.5 + }, + { + "symbol": "BB", + "mode": "LINK", + "targetNub": "bzNlaX", + "targetParam": "W" + }, + { + "symbol": "PB", + "mode": "SINGLE", + "value": 2.5 + }, + { + "symbol": "DH", + "mode": "LINK", + "targetNub": "eWNjdG", + "targetParam": "DH" + } + ] + }, + { + "uid": "Y3k4bj", + "props": { + "calcType": "Pab" + }, + "meta": { + "title": "PAB" + }, + "children": [ + { + "uid": "ampiN3", + "props": { + "calcType": "Cloisons" + }, + "children": [ + { + "uid": "Yzgxa2", + "props": { + "calcType": "Structure", + "structureType": "SeuilRectangulaire", + "loiDebit": "WeirSubmergedLarinier" + }, + "children": [], + "parameters": [ + { + "symbol": "ZDV", + "mode": "SINGLE", + "value": 28.085 + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 0.5 + }, + { + "symbol": "CdWSL", + "mode": "SINGLE", + "value": 0.83 + } + ] + } + ], + "parameters": [ + { + "symbol": "LB", + "mode": "SINGLE", + "value": 4.5 + }, + { + "symbol": "BB", + "mode": "SINGLE", + "value": 3.6 + }, + { + "symbol": "ZRMB", + "mode": "SINGLE", + "value": 27.413 + }, + { + "symbol": "ZRAM", + "mode": "SINGLE", + "value": 27.526 + }, + { + "symbol": "QA", + "mode": "SINGLE", + "value": 0 + } + ] + }, + { + "uid": "c3RmMz", + "props": { + "calcType": "Cloisons" + }, + "children": [ + { + "uid": "dmwyem", + "props": { + "calcType": "Structure", + "structureType": "SeuilRectangulaire", + "loiDebit": "WeirSubmergedLarinier" + }, + "children": [], + "parameters": [ + { + "symbol": "ZDV", + "mode": "SINGLE", + "value": 27.858 + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 0.5 + }, + { + "symbol": "CdWSL", + "mode": "SINGLE", + "value": 0.83 + } + ] + } + ], + "parameters": [ + { + "symbol": "LB", + "mode": "SINGLE", + "value": 4.5 + }, + { + "symbol": "BB", + "mode": "SINGLE", + "value": 3.6 + }, + { + "symbol": "ZRMB", + "mode": "SINGLE", + "value": 27.186 + }, + { + "symbol": "ZRAM", + "mode": "SINGLE", + "value": 27.299 + }, + { + "symbol": "QA", + "mode": "SINGLE", + "value": 0 + } + ] + }, + { + "uid": "cTlydj", + "props": { + "calcType": "Cloisons" + }, + "children": [ + { + "uid": "cWQ5aX", + "props": { + "calcType": "Structure", + "structureType": "SeuilRectangulaire", + "loiDebit": "WeirSubmergedLarinier" + }, + "children": [], + "parameters": [ + { + "symbol": "ZDV", + "mode": "SINGLE", + "value": 27.631 + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 0.5 + }, + { + "symbol": "CdWSL", + "mode": "SINGLE", + "value": 0.83 + } + ] + } + ], + "parameters": [ + { + "symbol": "LB", + "mode": "SINGLE", + "value": 4.5 + }, + { + "symbol": "BB", + "mode": "SINGLE", + "value": 3.6 + }, + { + "symbol": "ZRMB", + "mode": "SINGLE", + "value": 26.959 + }, + { + "symbol": "ZRAM", + "mode": "SINGLE", + "value": 27.072 + }, + { + "symbol": "QA", + "mode": "SINGLE", + "value": 0 + } + ] + }, + { + "uid": "emRkMX", + "props": { + "calcType": "Cloisons" + }, + "children": [ + { + "uid": "aG1xbj", + "props": { + "calcType": "Structure", + "structureType": "SeuilRectangulaire", + "loiDebit": "WeirSubmergedLarinier" + }, + "children": [], + "parameters": [ + { + "symbol": "ZDV", + "mode": "SINGLE", + "value": 27.404 + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 0.5 + }, + { + "symbol": "CdWSL", + "mode": "SINGLE", + "value": 0.83 + } + ] + } + ], + "parameters": [ + { + "symbol": "LB", + "mode": "SINGLE", + "value": 4.5 + }, + { + "symbol": "BB", + "mode": "SINGLE", + "value": 3.6 + }, + { + "symbol": "ZRMB", + "mode": "SINGLE", + "value": 26.731 + }, + { + "symbol": "ZRAM", + "mode": "SINGLE", + "value": 26.845 + }, + { + "symbol": "QA", + "mode": "SINGLE", + "value": 0 + } + ] + }, + { + "uid": "eG9hdT", + "props": { + "calcType": "Cloisons" + }, + "children": [ + { + "uid": "M3Z5ZX", + "props": { + "calcType": "Structure", + "structureType": "SeuilRectangulaire", + "loiDebit": "WeirSubmergedLarinier" + }, + "children": [], + "parameters": [ + { + "symbol": "ZDV", + "mode": "SINGLE", + "value": 27.177 + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 0.5 + }, + { + "symbol": "CdWSL", + "mode": "SINGLE", + "value": 0.83 + } + ] + } + ], + "parameters": [ + { + "symbol": "LB", + "mode": "SINGLE", + "value": 4.5 + }, + { + "symbol": "BB", + "mode": "SINGLE", + "value": 3.6 + }, + { + "symbol": "ZRMB", + "mode": "SINGLE", + "value": 26.504 + }, + { + "symbol": "ZRAM", + "mode": "SINGLE", + "value": 26.618 + }, + { + "symbol": "QA", + "mode": "SINGLE", + "value": 0 + } + ] + } + ], + "parameters": [ + { + "symbol": "Q", + "mode": "SINGLE", + "value": 1.8 + }, + { + "symbol": "Z1", + "mode": "CALCUL" + }, + { + "symbol": "Z2", + "mode": "SINGLE", + "value": 28.778 + } + ], + "downWall": { + "uid": "bWExN2", + "props": { + "calcType": "CloisonAval" + }, + "children": [ + { + "uid": "bm0zcD", + "props": { + "calcType": "Structure", + "structureType": "SeuilRectangulaire", + "loiDebit": "WeirSubmergedLarinier" + }, + "children": [], + "parameters": [ + { + "symbol": "ZDV", + "mode": "SINGLE", + "value": 26.95 + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 0.5 + }, + { + "symbol": "CdWSL", + "mode": "SINGLE", + "value": 0.83 + } + ] + } + ], + "parameters": [ + { + "symbol": "ZRAM", + "mode": "SINGLE", + "value": 26.391 + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/app/formulaire/definition/concrete/form-courbe-remous.ts b/src/app/formulaire/definition/concrete/form-courbe-remous.ts index 0cd6c20802c1c348554862773592552bfb1886dd..ce98814c1544a6d32ba0184bbcdf96fec384cbbb 100644 --- a/src/app/formulaire/definition/concrete/form-courbe-remous.ts +++ b/src/app/formulaire/definition/concrete/form-courbe-remous.ts @@ -59,7 +59,7 @@ export class FormulaireCourbeRemous extends FormulaireBase { switch (sender.id) { case "fs_section": // replace underlying section without replacing whole Nub - const newSect = Session.getInstance().createSection(sender.properties.getPropValue("nodeType")); + const newSect = Session.getInstance().createSection(data.value); (this._currentNub as SectionNub).setSection(newSect); // reflect changes in GUI for (const fs of this.allFieldsets) { diff --git a/src/app/formulaire/definition/concrete/form-regime-uniforme.ts b/src/app/formulaire/definition/concrete/form-regime-uniforme.ts index bb4cbd0a9ef74c761e29c49cec44b917b88b19de..4e8b483148e512ece8d96651426a3e0466b580c9 100644 --- a/src/app/formulaire/definition/concrete/form-regime-uniforme.ts +++ b/src/app/formulaire/definition/concrete/form-regime-uniforme.ts @@ -30,12 +30,14 @@ export class FormulaireRegimeUniforme extends FormulaireBase implements Observer update(sender: IObservable, data: any) { + console.log(">> Update Form RU", sender.constructor.name, data); + super.update(sender, data); // changement de propriété du FieldSet contenant le select de choix du type de section if (sender instanceof FieldSet && sender.id === "fs_section" && data.action === "propertyChange") { // replace underlying section without replacing whole Nub - const newSect = Session.getInstance().createSection(sender.properties.getPropValue("nodeType")); + const newSect = Session.getInstance().createSection(data.value); (this._currentNub as SectionNub).setSection(newSect); // reflect changes in GUI for (const fs of this.allFieldsets) { diff --git a/src/app/formulaire/definition/concrete/form-section-parametree.ts b/src/app/formulaire/definition/concrete/form-section-parametree.ts index 0e623cd402c44e46275cbcd5a711e0803b11e412..3bb8a56c757d4bac5384070e9605527aff47f60c 100644 --- a/src/app/formulaire/definition/concrete/form-section-parametree.ts +++ b/src/app/formulaire/definition/concrete/form-section-parametree.ts @@ -34,8 +34,8 @@ export class FormulaireSectionParametree extends FormulaireBase { // interface Observer update(sender: IObservable, data: any) { - // super.update(sender, data); + if (sender instanceof Nub) { switch (data.action) { case "resultUpdated": @@ -50,7 +50,7 @@ export class FormulaireSectionParametree extends FormulaireBase { switch (sender.id) { case "fs_section": // replace underlying section without replacing whole Nub - const newSect = Session.getInstance().createSection(sender.properties.getPropValue("nodeType")); + const newSect = Session.getInstance().createSection(data.value); (this._currentNub as SectionNub).setSection(newSect); // reflect changes in GUI for (const fs of this.allFieldsets) { diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index 2ba17671bcb97125f20319a2bf72cb94938924af..41094efef5da07b84fb98073a34d9b35891a653b 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -29,6 +29,9 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs /** propriétés par défaut (lues si _currentNub === undefined ) */ protected _props = {}; + /** for SectionNubs only */ + protected _defaultNodeType; + /** aide en ligne pour les résultats */ protected _resultsHelpLinks: { [key: string]: string }; @@ -100,12 +103,13 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs */ public initNub(props?: Props) { const p = props ? props : new Props(this.defaultProperties); - const p2 = p.clone(); this.currentNub = Session.getInstance().createSessionNub(p); + if (this.currentNub instanceof SectionNub) { // add new Section as first child, from given nodeType - p2.setPropValue("calcType", CalculatorType.Section); - const section = Session.getInstance().createNub(p2); + p.setPropValue("calcType", CalculatorType.Section); + p.setPropValue("nodeType", this._defaultNodeType); + const section = Session.getInstance().createNub(p); this.currentNub.setSection(section as acSection); } } @@ -138,7 +142,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs protected parseOptions(json: {}) { const dnt = json["defaultNodeType"]; if (dnt !== undefined) { - this._props["nodeType"] = ComputeNodeType[dnt]; + this._defaultNodeType = ComputeNodeType[dnt]; } this._helpLink = json["help"]; this._resultsHelpLinks = json["resultsHelp"]; diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 6bdc4f1c4ca7bfba337d15eee124903aa82dcf70..494e64140121f81b1ac62b9bf0e6f90aefa3e021 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -309,11 +309,6 @@ export class FieldSet extends FormulaireElement implements Observer { const calc_type: CalculatorType = currentCt ? currentCt : (ct ? CalculatorType[ct] : parentForm.calculatorType); this.setPropValue("calcType", calc_type); - const dnt: string = json["defaultNodeType"]; - const currentNt = this.properties.getPropValue("nodeType"); - const node_type: ComputeNodeType = currentNt ? currentNt : (dnt ? ComputeNodeType[dnt] : parentForm.nodeType); - this.setPropValue("nodeType", node_type); - this.setPropertyValueFromConfig(json, "defaultStructType", "structureType"); this.setPropertyValueFromConfig(json, "defaultLoiDebit", "loiDebit", LoiDebit); this.setPropertyValueFromConfig(json, "methodeResolution", "methodeResolution", MethodeResolution); @@ -373,8 +368,17 @@ export class FieldSet extends FormulaireElement implements Observer { case "select": const senderId: string = sender.id.replace(/\d+$/, ""); switch (senderId) { - case "select_section": // sections paramétrées - this.setPropValue("nodeType", data.value.value); + case "select_section": // sections paramétrées, courbes de remous, régimes uniformes + // "nodeType" is a property of the section child, not of the parent + const oldNodeType = this.nub.getChildren()[0].properties.getPropValue("nodeType"); + if (oldNodeType !== data.value.value) { // avoid infinite loops + // manually notify parent so that it replaces the child Nub @WARNING clodo trick + this.parentForm.update(this, { + action: "propertyChange", + name: "nodeType", + value: data.value.value + }); + } break; case "select_structure": // ouvrages parallèles this.setPropValue("structureType", data.value.value); diff --git a/src/app/formulaire/formulaire-element.ts b/src/app/formulaire/formulaire-element.ts index c09ea72af70cb47322f62759208c9af0b076bda7..05c5965471ebdfbebdf85326dc219ffac5f2101b 100644 --- a/src/app/formulaire/formulaire-element.ts +++ b/src/app/formulaire/formulaire-element.ts @@ -3,6 +3,7 @@ import { StringMap } from "../stringmap"; import { DeepFormulaireElementIterator } from "./form-iterator/deep-element-iterator"; import { I18nService } from "../services/internationalisation.service"; import { ServiceFactory } from "../services/service-factory"; +import { FormulaireDefinition } from "./definition/form-definition"; /** * élément (enfant) du formulaire : fieldset, input, container, ... @@ -55,7 +56,7 @@ export abstract class FormulaireElement extends FormulaireNode { /** * formulaire parent */ - public get parentForm(): FormulaireNode { + public get parentForm(): FormulaireDefinition { let res = this.parent; // while (!(res instanceof FormulaireDefinition)) while (!("calculatorName" in res)) { @@ -63,7 +64,7 @@ export abstract class FormulaireElement extends FormulaireNode { // casser les dépendances circulaires d'import res = res.parent; } - return res; + return (res as FormulaireDefinition); } /**