From 197702cc5702dc14adc2d0b75011127420bb3cc3 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 15 Jan 2019 12:27:04 +0100 Subject: [PATCH 1/8] =?UTF-8?q?Compatibilit=C3=A9=20avec=20jalhyd=2058-?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/remous-results/remous-results.component.ts | 4 ++-- src/app/formulaire/ngparam.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts index bbcbd0e13..290ae0548 100644 --- a/src/app/components/remous-results/remous-results.component.ts +++ b/src/app/components/remous-results/remous-results.component.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from "@angular/core"; -import { ArrayReverseIterator, ResultElement, NumberIterator } from "jalhyd"; +import { ArrayReverseIterator, ResultElement, INumberIterator } from "jalhyd"; import { InternationalisationService } from "../../services/internationalisation/internationalisation.service"; import { LogComponent } from "../../components/log/log.component"; @@ -164,7 +164,7 @@ export class RemousResultsComponent { return false; } - private get abscisseIterator(): NumberIterator { + private get abscisseIterator(): INumberIterator { return this._remousResults.varResults.variatedParameter.paramDefinition.paramValues.getValuesIterator(); } diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index 4ea578ea0..d1d9db1db 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -1,4 +1,4 @@ -import { ParamDefinition, Pair, ParamDomain, ParamValueMode, NumberIterator, Nub, Observer, asObservable } from "jalhyd"; +import { ParamDefinition, Pair, ParamDomain, ParamValueMode, INumberIterator, Nub, Observer, asObservable } from "jalhyd"; import { InputField } from "./input-field"; import { Dependency } from "./dependency/dependency"; @@ -149,7 +149,7 @@ export class NgParameter extends InputField implements Observer { return this._paramDef.isValid; } - public get valuesIterator(): NumberIterator { + public get valuesIterator(): INumberIterator { return this._paramDef.valuesIterator; } public unit: string; -- GitLab From 14bff02c3b9af7b418545c9fb9fab2b0b480e646 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 15 Jan 2019 14:49:11 +0100 Subject: [PATCH 2/8] =?UTF-8?q?M=C3=A0j=20jalhyd:=20utilisation=20de=20Int?= =?UTF-8?q?erval=20=C3=A0=20la=20place=20de=20Pair?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/formulaire/ngparam.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index d1d9db1db..3eb725cc7 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -1,4 +1,4 @@ -import { ParamDefinition, Pair, ParamDomain, ParamValueMode, INumberIterator, Nub, Observer, asObservable } from "jalhyd"; +import { Interval, ParamDefinition, ParamDomain, ParamValueMode, INumberIterator, Nub, Observer, asObservable } from "jalhyd"; import { InputField } from "./input-field"; import { Dependency } from "./dependency/dependency"; @@ -6,7 +6,6 @@ import { DependencyConditionType } from "./dependency/dependency-condition"; import { ValueDependencyCondition } from "./dependency/value-dependency-condition"; import { ServiceFactory } from "../services/service-factory"; import { ApplicationSetupService } from "../services/app-setup/app-setup.service"; -import { StringMap } from "../stringmap"; import { FormulaireNode } from "./formulaire-node"; export enum ParamRadioConfig { @@ -121,7 +120,7 @@ export class NgParameter extends InputField implements Observer { this._paramValues.max = v; } - public get stepRefValue(): Pair { + public get stepRefValue(): Interval { return this._paramValues.stepRefValue; } -- GitLab From ed1cb2f0d6434118563afa1fe0332c5ff3e337c5 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 15 Jan 2019 15:21:12 +0100 Subject: [PATCH 3/8] =?UTF-8?q?M=C3=A0j=20jalhyd:=20utilisation=20de=20Par?= =?UTF-8?q?amDefinition=20au=20lieu=20de=20BaseParam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../base-param-input/base-param-input.component.ts | 11 +++++------ .../generic-input/generic-input.component.ts | 4 ++-- src/app/formulaire/ngparam.ts | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2af2e1c50..1ee1be580 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ and then : - dans _src/app/calculators/ma-calculette_ : Créer _ma-calculette.config.json_ sur le modèle des autres. - Les ids utilisés doivent correspondre au symbole fourni à classe _BaseParam_ (1er paramètre du constructeur) + Les ids utilisés doivent correspondre au symbole fourni à classe _ParamDefinition_ (1er paramètre du constructeur) Ne pas oublier de spécifier : - éventuellement le type de noeud par défaut de la calculette dans les options avec le champ "_defaultNodeType_". Si ce champ est absent, sa valeur est "_ComputeNodeType.None_". Ce champ sert par ex pour les sections paramétrées à déterminer le type de section à afficher lors de la création de la calculette. diff --git a/src/app/components/base-param-input/base-param-input.component.ts b/src/app/components/base-param-input/base-param-input.component.ts index f879a787b..8144f03d7 100644 --- a/src/app/components/base-param-input/base-param-input.component.ts +++ b/src/app/components/base-param-input/base-param-input.component.ts @@ -1,19 +1,18 @@ // cf. https://blog.thoughtram.io/angular/2016/07/27/custom-form-controls-in-angular-2.html -import { Component, Input, forwardRef, OnInit, DoCheck, ChangeDetectorRef } from "@angular/core"; -import { ControlValueAccessor, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl } from "@angular/forms"; +import { Component, ChangeDetectorRef } from "@angular/core"; -import { BaseParam, NumericalString, Message, ParamDomain, ParamDomainValue, Observable } from "jalhyd"; +import { NumericalString, Message, ParamDefinition, ParamDomain, ParamDomainValue, Observable } from "jalhyd"; -import { InternationalisationService, LanguageCode } from "../../services/internationalisation/internationalisation.service"; +import { InternationalisationService } from "../../services/internationalisation/internationalisation.service"; import { GenericInputComponent } from "../generic-input/generic-input.component"; export class NgBaseParam extends Observable { - private _param: BaseParam; + private _param: ParamDefinition; constructor(symb: string, d: ParamDomain | ParamDomainValue, val: number) { super(); - this._param = new BaseParam(symb, d, val); + this._param = new ParamDefinition(symb, d, val); } public get symbol() { diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts index f392282fb..e5513138b 100644 --- a/src/app/components/generic-input/generic-input.component.ts +++ b/src/app/components/generic-input/generic-input.component.ts @@ -360,7 +360,7 @@ export class TestInputComponent extends GenericInputComponent { // exemple où le modèle est une classe dont on ne gère qu'un membre -import { BaseParam } from "jalhyd"; +import { ParamDefinition } from "jalhyd"; @Component({ selector: "test2-input", @@ -376,7 +376,7 @@ export class Test2InputComponent extends GenericInputComponent { } // paramètre géré - private get _param(): BaseParam { + private get _param(): ParamDefinition { return this._model; } diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index 3eb725cc7..50125790a 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -387,7 +387,7 @@ export class NgParameter extends InputField implements Observer { public update(sender: any, data: any) { switch (data["action"]) { - case "baseparamAfterValue": // changement de valeur envoyé par l'objet référencé + case "paramdefinitionAfterValue": // changement de valeur envoyé par l'objet référencé this.notifyValueModified(sender); break; } -- GitLab From eb43c7abb6392db00874dcdc495943d9b635d11b Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 16 Jan 2019 10:03:59 +0100 Subject: [PATCH 4/8] =?UTF-8?q?ParamService=20ne=20se=20charge=20plus=20de?= =?UTF-8?q?=20d=C3=A9placer=20les=20Structure=20dans=20une=20ParallelStruc?= =?UTF-8?q?ture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../concrete/form-parallel-structures.ts | 22 +++++++++++-------- src/app/services/param/param.service.ts | 9 -------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/app/formulaire/definition/concrete/form-parallel-structures.ts b/src/app/formulaire/definition/concrete/form-parallel-structures.ts index 1b47a27c0..5958f36e3 100644 --- a/src/app/formulaire/definition/concrete/form-parallel-structures.ts +++ b/src/app/formulaire/definition/concrete/form-parallel-structures.ts @@ -1,4 +1,4 @@ -import { CalculatorType, ComputeNodeType, Structure, ParallelStructure, SessionNub, StructureType, LoiDebit, StructureProperties, Props } from "jalhyd"; +import { Structure, ParallelStructure, SessionNub, StructureType, LoiDebit, StructureProperties, Props } from "jalhyd"; import { FormulaireDefinition } from "../form-definition"; import { CalculatorResults } from "../../../results/calculator-results"; @@ -116,20 +116,20 @@ export class FormulaireParallelStructure extends FormulaireDefinition { public moveFieldsetUp(fs: FieldSet) { if (fs.sessionNub.nub instanceof Structure) { // déplacement du nub - this._paramService.moveStructureNubUp(fs.sessionNub); - + fs.sessionNub.nub.parent.moveStructureUp(fs.sessionNub.nub); // déplacement du fieldset this.fieldsetContainer.moveFieldsetUp(fs); this.resetResults(); - } else { super.moveFieldsetUp(fs); } + } else { + super.moveFieldsetUp(fs); + } } public moveFieldsetDown(fs: FieldSet) { if (fs.sessionNub.nub instanceof Structure) { // déplacement du nub - this._paramService.moveStructureNubDown(fs.sessionNub); - + fs.sessionNub.nub.parent.moveStructureDown(fs.sessionNub.nub); // déplacement du fieldset this.fieldsetContainer.moveFieldsetDown(fs); @@ -185,7 +185,7 @@ export class FormulaireParallelStructure extends FormulaireDefinition { private get fieldsetContainer(): FieldsetContainer { const n = this.getFormulaireNodeById("struct_container"); - if (n == undefined || !(n instanceof FieldsetContainer)) { + if (n === undefined || !(n instanceof FieldsetContainer)) { throw new Error("l'élément 'struct_container' n'est pas du type FieldsetContainer"); } return n as FieldsetContainer; @@ -266,6 +266,7 @@ export class FormulaireParallelStructure extends FormulaireDefinition { const loidebitSelect = this.findObjectWithDependency(fs.jsonConfig["fields"], structSelect.select.id, structSelect.entry.id); if (loidebitSelect === undefined || loidebitSelect["type"] !== "select") { + // tslint:disable-next-line:max-line-length throw new Error(`pas de select trouvé avec une dépendance au select 'type de structure' pour la valeur ${structSelect.select.id}=${structSelect.entry.id} (1)`); } @@ -280,6 +281,7 @@ export class FormulaireParallelStructure extends FormulaireDefinition { } if (loisDebit.length === 0) { + // tslint:disable-next-line:max-line-length throw new Error(`pas de select trouvé avec une dépendance au select 'type de structure' pour la valeur ${structSelect.select.id}=${structSelect.entry.id} (2)`); } @@ -299,8 +301,10 @@ export class FormulaireParallelStructure extends FormulaireDefinition { * @param val nouvelle valeur de la propriété */ private adjustProperties(fs: FieldSet, name: string, val: any): Props { - // si prop=type d'ouvrage, on prend la 1ère loi de débit compatible avec (spécifique aux ouvrages //), en tenant compte des dépendances. - // (par ex, s'il existe un select de lois de débit dépendant du select de types d'ouvrage, on prend la 1ère entrée du select de lois de débit compatible) + // si prop=type d'ouvrage, on prend la 1ère loi de débit compatible avec + // (spécifique aux ouvrages //), en tenant compte des dépendances. + // (par ex, s'il existe un select de lois de débit dépendant du select de types + // d'ouvrage, on prend la 1ère entrée du select de lois de débit compatible) if (name === "structureType") { if (!StructureProperties.isCompatibleValues(val, fs.properties.getPropValue("loiDebit"))) { return this.adjustLoiDebit(fs, val); diff --git a/src/app/services/param/param.service.ts b/src/app/services/param/param.service.ts index d915cd712..cd117e6d0 100644 --- a/src/app/services/param/param.service.ts +++ b/src/app/services/param/param.service.ts @@ -1,7 +1,6 @@ import { ParamDomain, ParamDefinition, ParamDomainValue, ParamCalculability, NubFactory, SessionNub, Props } from "jalhyd"; import { NgParameter } from "../../formulaire/ngparam"; -import { FormulaireDefinition } from "../../formulaire/definition/form-definition"; import { Injectable } from "@angular/core"; import { ServiceFactory } from "../service-factory"; import { InternationalisationService } from "../internationalisation/internationalisation.service"; @@ -104,14 +103,6 @@ export class ParamService { return NubFactory.getInstance().replaceSessionNub(sn, params); } - public moveStructureNubUp(sn: SessionNub) { - NubFactory.getInstance().moveStructureNubUp(sn); - } - - public moveStructureNubDown(sn: SessionNub) { - NubFactory.getInstance().moveStructureNubDown(sn); - } - public deleteSessionNub(sn: SessionNub) { NubFactory.getInstance().deleteSessionNub(sn); } -- GitLab From f8ca35e38a2f3ee4eb745f20c00f803ac90f45c5 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 16 Jan 2019 12:28:02 +0100 Subject: [PATCH 5/8] =?UTF-8?q?M=C3=A0j=20jalhyd:=20NubFactory=20=3D>=20Se?= =?UTF-8?q?ssion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/app/formulaire/definition/form-definition.ts | 2 +- src/app/services/param/param.service.ts | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1ee1be580..4692536a0 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ and then : * Ajouter une valeur à l'enum _CalculatorType_ pour identifier le type de calculette (par ex _MaCalculette_). -* Compléter la méthode _NubFactory.createNub()_. +* Compléter la méthode _Session.createNub()_. ## ngHyd diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index ea579d10d..1e5377872 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -292,7 +292,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs // console.log("-----"); - // for (const n of NubFactory.getInstance().sessionNubIterator) { + // for (const n of Session.getInstance().sessionNubIterator) { // console.log(n.nub); // for (const p of n.nub.parameterIterator) // console.log(`${p.symbol} uid ${p.uid} props ${n.properties} mode ${p.valueMode} val ${p.uncheckedValue}`); diff --git a/src/app/services/param/param.service.ts b/src/app/services/param/param.service.ts index cd117e6d0..0c529caf3 100644 --- a/src/app/services/param/param.service.ts +++ b/src/app/services/param/param.service.ts @@ -1,4 +1,4 @@ -import { ParamDomain, ParamDefinition, ParamDomainValue, ParamCalculability, NubFactory, SessionNub, Props } from "jalhyd"; +import { ParamDomain, ParamDefinition, ParamDomainValue, ParamCalculability, Session, SessionNub, Props } from "jalhyd"; import { NgParameter } from "../../formulaire/ngparam"; import { Injectable } from "@angular/core"; @@ -92,18 +92,18 @@ export class ParamService { } public createSessionNub(params: Props | {}): SessionNub { - return NubFactory.getInstance().createSessionNub(params); + return Session.getInstance().createSessionNub(params); } public findSessionNub(params: Props | {}): SessionNub { - return NubFactory.getInstance().findSessionNub(params); + return Session.getInstance().findSessionNub(params); } public replaceSessionNub(sn: SessionNub, params: Props): SessionNub { - return NubFactory.getInstance().replaceSessionNub(sn, params); + return Session.getInstance().replaceSessionNub(sn, params); } public deleteSessionNub(sn: SessionNub) { - NubFactory.getInstance().deleteSessionNub(sn); + Session.getInstance().deleteSessionNub(sn); } } -- GitLab From 43f3956a7f4e02514d78fad396fbadc2ef24b5f9 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 16 Jan 2019 16:58:23 +0100 Subject: [PATCH 6/8] =?UTF-8?q?M=C3=A0j=20jalhyd:=20fusion=20Nub=20et=20Se?= =?UTF-8?q?ssionNub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 48 +++++++------- .../param-field-line.component.ts | 2 +- .../definition/concrete/form-cond-distri.ts | 6 +- .../definition/concrete/form-courbe-remous.ts | 8 +-- .../concrete/form-parallel-structures.ts | 35 ++++++----- .../concrete/form-regime-uniforme.ts | 6 +- .../concrete/form-section-parametree.ts | 6 +- .../definition/form-compute-courbe-remous.ts | 2 +- .../definition/form-compute-fixedvar.ts | 2 +- .../form-compute-section-parametree.ts | 10 ++- src/app/formulaire/definition/form-compute.ts | 2 +- .../formulaire/definition/form-definition.ts | 63 ++++++++++--------- src/app/formulaire/fieldset.ts | 20 +++--- .../services/formulaire/formulaire.service.ts | 8 +-- src/app/services/param/param.service.ts | 19 +++--- 15 files changed, 119 insertions(+), 118 deletions(-) diff --git a/package-lock.json b/package-lock.json index b064a6bfa..9e1268ce0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -133,7 +133,7 @@ "dependencies": { "source-map": { "version": "0.5.6", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", "dev": true }, @@ -1873,7 +1873,7 @@ }, "util": { "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { @@ -4073,7 +4073,7 @@ }, "source-map": { "version": "0.2.0", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", "dev": true, "optional": true, @@ -6716,7 +6716,7 @@ }, "resolve": { "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "resolved": "http://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true }, @@ -6921,7 +6921,7 @@ }, "jalhyd": { "version": "file:../jalhyd/jalhyd-1.0.0.tgz", - "integrity": "sha512-2/Os2o1wZUuPZqE6cdtyFpMr+13XGG2VXuwfIYwx4MqJKnvyKNIoBGpbo/t77ca+izUuh7n+SB1HxjK00fszQQ==" + "integrity": "sha512-ieqqCYVkbBnMqFCkVBnnfYH0ANM4VLpymdyRmcrN580L1WziUgQqFSmXNFXY4q/4TeAncO3R+2PeI79KrYHYMQ==" }, "jasmine": { "version": "2.8.0", @@ -7751,7 +7751,7 @@ }, "load-json-file": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { @@ -8173,7 +8173,7 @@ }, "meow": { "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "resolved": "http://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "optional": true, @@ -8615,7 +8615,7 @@ "dependencies": { "semver": { "version": "5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "resolved": "http://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true, "optional": true @@ -8713,7 +8713,7 @@ }, "supports-color": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "resolved": "http://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true, "optional": true @@ -9172,7 +9172,7 @@ }, "os-locale": { "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", "dev": true, "optional": true, @@ -9436,7 +9436,7 @@ }, "parse-asn1": { "version": "5.1.1", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", + "resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "dev": true, "requires": { @@ -9529,7 +9529,7 @@ }, "path-browserify": { "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", + "resolved": "http://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", "dev": true }, @@ -10271,7 +10271,7 @@ }, "raw-loader": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/raw-loader/-/raw-loader-0.5.1.tgz", "integrity": "sha1-DD0L6u2KAclm2Xh793goElKpeao=", "dev": true }, @@ -10768,7 +10768,7 @@ "dependencies": { "source-map": { "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "optional": true, @@ -10963,7 +10963,7 @@ }, "sha.js": { "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { @@ -11574,7 +11574,7 @@ }, "stream-browserify": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", + "resolved": "http://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", "dev": true, "requires": { @@ -11622,7 +11622,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -11637,7 +11637,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -11772,13 +11772,13 @@ }, "sax": { "version": "0.5.8", - "resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz", + "resolved": "http://registry.npmjs.org/sax/-/sax-0.5.8.tgz", "integrity": "sha1-1HLbIo6zMcJQaw6MFVJK25OdEsE=", "dev": true }, "source-map": { "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", + "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", "dev": true, "requires": { @@ -11821,7 +11821,7 @@ }, "tar": { "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "resolved": "http://registry.npmjs.org/tar/-/tar-2.2.1.tgz", "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", "dev": true, "optional": true, @@ -12352,7 +12352,7 @@ }, "tty-browserify": { "version": "0.0.0", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", + "resolved": "http://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", "dev": true }, @@ -12754,7 +12754,7 @@ }, "vm-browserify": { "version": "0.0.4", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", + "resolved": "http://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", "dev": true, "requires": { @@ -12859,7 +12859,7 @@ }, "source-map": { "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { diff --git a/src/app/components/param-field-line/param-field-line.component.ts b/src/app/components/param-field-line/param-field-line.component.ts index ab389e306..65263d2c0 100644 --- a/src/app/components/param-field-line/param-field-line.component.ts +++ b/src/app/components/param-field-line/param-field-line.component.ts @@ -294,7 +294,7 @@ export class ParamFieldLineComponent implements OnChanges { // ou une seule calculette "ouvrages parallèles" if (this._formService.formulaires[0].calculatorType === CalculatorType.ParallelStructure) { - const ps: ParallelStructure = this._formService.formulaires[0].currentSessionNub.nub as ParallelStructure; + const ps: ParallelStructure = this._formService.formulaires[0].currentNub as ParallelStructure; if (ps.structures.length > 1) { return this._formService.filterLinkableValues(this._formService.getLinkableValues(this.param)).length > 0; } diff --git a/src/app/formulaire/definition/concrete/form-cond-distri.ts b/src/app/formulaire/definition/concrete/form-cond-distri.ts index 9229f2ce6..5f648a73a 100644 --- a/src/app/formulaire/definition/concrete/form-cond-distri.ts +++ b/src/app/formulaire/definition/concrete/form-cond-distri.ts @@ -1,5 +1,4 @@ import { FormDefFixedVar } from "../form-def-fixedvar"; -import { CalculatorType, ComputeNodeType } from "jalhyd"; import { FormResultFixedVar } from "../form-result-fixedvar"; import { FormulaireDefinition } from "../form-definition"; import { CalculatorResults } from "../../../results/calculator-results"; @@ -7,7 +6,8 @@ import { FormDefParamToCalculate } from "../form-def-paramcalc"; import { FormComputeFixedVar } from "../form-compute-fixedvar"; export class FormulaireConduiteDistributrice extends FormulaireDefinition { - private _formFixedVar: FormDefFixedVar; + + // private _formFixedVar: FormDefFixedVar; private _formParamCalc: FormDefParamToCalculate; @@ -17,7 +17,7 @@ export class FormulaireConduiteDistributrice extends FormulaireDefinition { constructor() { super(); - this._formFixedVar = new FormDefFixedVar(this); + // this._formFixedVar = new FormDefFixedVar(this); this._formParamCalc = new FormDefParamToCalculate(this); this._formResult = new FormResultFixedVar(this, false); this._formCompute = new FormComputeFixedVar(this, this._formResult); diff --git a/src/app/formulaire/definition/concrete/form-courbe-remous.ts b/src/app/formulaire/definition/concrete/form-courbe-remous.ts index 12bf97599..2789da339 100644 --- a/src/app/formulaire/definition/concrete/form-courbe-remous.ts +++ b/src/app/formulaire/definition/concrete/form-courbe-remous.ts @@ -1,4 +1,4 @@ -import { CalculatorType, ComputeNodeType, IObservable } from "jalhyd"; +import { IObservable } from "jalhyd"; import { FormResultRemous } from "../form-result-remous"; import { FormDefSection } from "../form-def-section"; @@ -66,12 +66,12 @@ export class FormulaireCourbeRemous extends FormulaireDefinition { // interface Observer update(sender: IObservable, data: any) { - if (sender instanceof FieldSet && data.action == "propertyChange") { + if (sender instanceof FieldSet && data.action === "propertyChange") { switch (sender.id) { case "fs_section": - this.replaceCurrentSessionNub(sender.properties); + this.replaceCurrentNub(sender.properties); for (const fs of this.allFieldsets) { - fs.setSessionNub(this._currentSessionNub); + fs.setNub(this._currentNub); } this.reset(); break; diff --git a/src/app/formulaire/definition/concrete/form-parallel-structures.ts b/src/app/formulaire/definition/concrete/form-parallel-structures.ts index 5958f36e3..4d5697248 100644 --- a/src/app/formulaire/definition/concrete/form-parallel-structures.ts +++ b/src/app/formulaire/definition/concrete/form-parallel-structures.ts @@ -1,4 +1,4 @@ -import { Structure, ParallelStructure, SessionNub, StructureType, LoiDebit, StructureProperties, Props } from "jalhyd"; +import { Structure, Nub, ParallelStructure, StructureType, LoiDebit, StructureProperties, Props } from "jalhyd"; import { FormulaireDefinition } from "../form-definition"; import { CalculatorResults } from "../../../results/calculator-results"; @@ -15,7 +15,8 @@ import { FieldsetTemplate } from "../../fieldset-template"; import { FormulaireNode } from "../../formulaire-node"; export class FormulaireParallelStructure extends FormulaireDefinition { - private _formFixedVar: FormDefFixedVar; + + // private _formFixedVar: FormDefFixedVar; private _formParallelStruct: FormDefParallelStructures; @@ -32,14 +33,14 @@ export class FormulaireParallelStructure extends FormulaireDefinition { constructor() { super(); - this._formFixedVar = new FormDefFixedVar(this); + // this._formFixedVar = new FormDefFixedVar(this); this._formParamCalc = new FormDefParamToCalculate(this); this._formResult = new FormResultFixedVar(this, false); this._formParallelStruct = new FormDefParallelStructures(); this._formCompute = new FormComputeParallelStructures(this, this._formParallelStruct, this._formResult); } - private createStructNub(templ: FieldsetTemplate): SessionNub { + private createStructNub(templ: FieldsetTemplate): Nub { // !!! attention !!! // Il doit y avoir cohérence dans le fichier de conf entre les valeurs defaultXXX et les valeurs possibles pour les select // cad valeur par défaut du 1er select (type d'ouvrage), du 2ème (loi de débit). @@ -51,7 +52,7 @@ export class FormulaireParallelStructure extends FormulaireDefinition { params["structureType"] = templ.defaultStructTypeFromConfig; params["loiDebit"] = templ.defaultLoiDebitFromConfig; - return this.createSessionNub(params); + return this.createNub(params); } /** @@ -64,7 +65,7 @@ export class FormulaireParallelStructure extends FormulaireDefinition { } private get parallelStructureNub(): ParallelStructure { - return this.currentSessionNub.nub as ParallelStructure; + return this.currentNub as ParallelStructure; } public createFieldset(parent: FormulaireNode, json: {}, data?: {}): FieldSet { @@ -74,8 +75,8 @@ export class FormulaireParallelStructure extends FormulaireDefinition { const res: FieldSet = new FieldSet(parent); const sn = this.createStructNub(data["template"]); - this.addStructureNub(sn.nub as Structure, after); - res.setSessionNub(sn, false); + this.addStructureNub(sn as Structure, after); + res.setNub(sn, false); if (after !== undefined) { parent.kids.splice(after + 1, 0, res); @@ -114,9 +115,9 @@ export class FormulaireParallelStructure extends FormulaireDefinition { } public moveFieldsetUp(fs: FieldSet) { - if (fs.sessionNub.nub instanceof Structure) { + if (fs.nub instanceof Structure) { // déplacement du nub - fs.sessionNub.nub.parent.moveStructureUp(fs.sessionNub.nub); + fs.nub.parent.moveStructureUp(fs.nub); // déplacement du fieldset this.fieldsetContainer.moveFieldsetUp(fs); @@ -127,9 +128,9 @@ export class FormulaireParallelStructure extends FormulaireDefinition { } public moveFieldsetDown(fs: FieldSet) { - if (fs.sessionNub.nub instanceof Structure) { + if (fs.nub instanceof Structure) { // déplacement du nub - fs.sessionNub.nub.parent.moveStructureDown(fs.sessionNub.nub); + fs.nub.parent.moveStructureDown(fs.nub); // déplacement du fieldset this.fieldsetContainer.moveFieldsetDown(fs); @@ -138,9 +139,9 @@ export class FormulaireParallelStructure extends FormulaireDefinition { } public removeFieldset(fs: FieldSet) { - if (fs.sessionNub.nub instanceof Structure) { + if (fs.nub instanceof Structure) { // suppression du nub - this._paramService.deleteSessionNub(fs.sessionNub); + this._paramService.deleteNub(fs.nub); // suppression du fieldset this.fieldsetContainer.removeFieldset(fs); @@ -356,12 +357,12 @@ export class FormulaireParallelStructure extends FormulaireDefinition { this.subscribeStructureInputFields(data["fieldset"]); this.subscribeStructureSelectFields(data["fieldset"]); } - } else if (sender instanceof FieldSet && data.action == "propertyChange") { + } else if (sender instanceof FieldSet && data.action === "propertyChange") { switch (sender.id) { case "fs_ouvrage": const props = this.adjustProperties(sender, data["name"], data["value"]); - const newNub = this.replaceSessionNub(sender.sessionNub, props); - sender.setSessionNub(newNub); + const newNub = this.replaceNub(sender.nub, props); + sender.setNub(newNub); this.reset(); break; } diff --git a/src/app/formulaire/definition/concrete/form-regime-uniforme.ts b/src/app/formulaire/definition/concrete/form-regime-uniforme.ts index e821225d2..b7549d676 100644 --- a/src/app/formulaire/definition/concrete/form-regime-uniforme.ts +++ b/src/app/formulaire/definition/concrete/form-regime-uniforme.ts @@ -78,10 +78,10 @@ export class FormulaireRegimeUniforme extends FormulaireDefinition implements Ob update(sender: IObservable, data: any) { // 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") { - this.replaceCurrentSessionNub(sender.properties); + if (sender instanceof FieldSet && sender.id === "fs_section" && data.action === "propertyChange") { + this.replaceCurrentNub(sender.properties); for (const fs of this.allFieldsets) { - fs.setSessionNub(this._currentSessionNub); + fs.setNub(this._currentNub); } this.reset(); } diff --git a/src/app/formulaire/definition/concrete/form-section-parametree.ts b/src/app/formulaire/definition/concrete/form-section-parametree.ts index 1e5a9301e..5b2e2bd2d 100644 --- a/src/app/formulaire/definition/concrete/form-section-parametree.ts +++ b/src/app/formulaire/definition/concrete/form-section-parametree.ts @@ -66,12 +66,12 @@ export class FormulaireSectionParametree extends FormulaireDefinition { update(sender: IObservable, data: any) { // changement de propriété du FieldSet contenant le select de choix du type de section - if (sender instanceof FieldSet && data.action == "propertyChange") { + if (sender instanceof FieldSet && data.action === "propertyChange") { switch (sender.id) { case "fs_section": - this.replaceCurrentSessionNub(sender.properties); + this.replaceCurrentNub(sender.properties); for (const fs of this.allFieldsets) { - fs.setSessionNub(this._currentSessionNub); + fs.setNub(this._currentNub); } this.reset(); break; diff --git a/src/app/formulaire/definition/form-compute-courbe-remous.ts b/src/app/formulaire/definition/form-compute-courbe-remous.ts index ebd833cc0..6d996a2ab 100644 --- a/src/app/formulaire/definition/form-compute-courbe-remous.ts +++ b/src/app/formulaire/definition/form-compute-courbe-remous.ts @@ -18,7 +18,7 @@ export class FormComputeCourbeRemous extends FormCompute { } protected compute() { - const cr: CourbeRemous = this._formBase.currentSessionNub.nub as CourbeRemous; + const cr: CourbeRemous = this._formBase.currentNub as CourbeRemous; const prmCR: CourbeRemousParams = cr.parameters as CourbeRemousParams; const sect: acSection = prmCR.Sn; diff --git a/src/app/formulaire/definition/form-compute-fixedvar.ts b/src/app/formulaire/definition/form-compute-fixedvar.ts index 837e1eea9..873488018 100644 --- a/src/app/formulaire/definition/form-compute-fixedvar.ts +++ b/src/app/formulaire/definition/form-compute-fixedvar.ts @@ -44,7 +44,7 @@ export class FormComputeFixedVar extends FormCompute { } protected compute() { - const nub: Nub = this._formBase.currentSessionNub.nub; + const nub: Nub = this._formBase.currentNub; let computePrec: number; if (this._formBase.hasParameter("Pr")) { computePrec = this._formBase.getParameterValue("Pr"); // précision de calcul diff --git a/src/app/formulaire/definition/form-compute-section-parametree.ts b/src/app/formulaire/definition/form-compute-section-parametree.ts index c31b941c1..5466762f0 100644 --- a/src/app/formulaire/definition/form-compute-section-parametree.ts +++ b/src/app/formulaire/definition/form-compute-section-parametree.ts @@ -1,12 +1,10 @@ -import { SectionParametree, acSection, ParamsEquation, ComputeNode, Result, ParamValueMode, Nub, ParamsSection, CalculatorType, SessionNub } from "jalhyd"; +import { SectionParametree, acSection } from "jalhyd"; import { FormCompute } from "./form-compute"; import { NgParameter } from "../ngparam"; import { FormResult } from "./form-result"; -import { Form } from "@angular/forms"; import { FormDefSection } from "./form-def-section"; import { FormResultSection } from "./form-result-section"; -import { InputField } from "../input-field"; import { FixedResults } from "../../results/fixed-results"; import { VarResults } from "../../results/var-results"; import { SectionResults } from "../../results/section-results"; @@ -51,7 +49,7 @@ export class FormComputeSectionParametree extends FormCompute { // paramètre à calculer en fonction du paramètre à varier const computedParamInfo = this._formSection.getSectionComputedParam(); - const sectNub: SectionParametree = this._formBase.currentSessionNub.nub as SectionParametree; + const sectNub: SectionParametree = this._formBase.currentNub as SectionParametree; const sect: acSection = sectNub.section; const prms = sectNub.parameters; @@ -71,12 +69,12 @@ export class FormComputeSectionParametree extends FormCompute { protected compute() { const varParam = this._formSection.getSectionVariatedParameter(); - if (varParam != undefined) { + if (varParam !== undefined) { this.doComputeSectionVar(varParam); return; } - const sectNub: SectionParametree = this._formBase.currentSessionNub.nub as SectionParametree; + const sectNub: SectionParametree = this._formBase.currentNub as SectionParametree; const sect: acSection = sectNub.section; this._sectionResults.section = sect; diff --git a/src/app/formulaire/definition/form-compute.ts b/src/app/formulaire/definition/form-compute.ts index 63d5460ce..6d9b33ea2 100644 --- a/src/app/formulaire/definition/form-compute.ts +++ b/src/app/formulaire/definition/form-compute.ts @@ -1,4 +1,4 @@ -import { ParamValueMode, Nub, Result, ParamDomainValue, ParamDomain, SessionNub } from "jalhyd"; +import { Nub, Result, ParamDomainValue } from "jalhyd"; import { FormResult } from "./form-result"; import { FormulaireDefinition } from "./form-definition"; diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index 1e5377872..9347ec050 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -1,4 +1,4 @@ -import { CalculatorType, ComputeNodeType, ParamDefinition, SessionNub, Props, Observer } from "jalhyd"; +import { CalculatorType, ComputeNodeType, Nub, ParamDefinition, Props, Observer } from "jalhyd"; import { FormulaireElement } from "../formulaire-element"; import { NgParameter, ParamRadioConfig } from "../ngparam"; @@ -25,12 +25,12 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs private _calculatorName: string; /** - * SessionNub courant + * Nub courant */ - protected _currentSessionNub: SessionNub; + protected _currentNub: Nub; /** - * propriétés par défaut (lues si _currentSessionNub === undefined ) + * propriétés par défaut (lues si _currentNub === undefined ) */ private _props = {}; @@ -52,12 +52,12 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs } public get calculatorType(): CalculatorType { - const props = this._currentSessionNub === undefined ? this.defaultProperties : this._currentSessionNub.properties.props; + const props = this._currentNub === undefined ? this.defaultProperties : (this._currentNub.properties as Props).props; return props["calcType"]; } public get nodeType(): ComputeNodeType { - const props = this._currentSessionNub === undefined ? this.defaultProperties : this._currentSessionNub.properties.props; + const props = this._currentNub === undefined ? this.defaultProperties : (this._currentNub.properties as Props).props; return props["nodeType"]; } @@ -82,49 +82,51 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs return this._props; } - public initSessionNub(props?: {}) { - this._currentSessionNub = this.createSessionNub(props === undefined ? this.defaultProperties : props); + public initNub(props?: {}) { + this._currentNub = this.createNub(props === undefined ? this.defaultProperties : props); } - public get currentSessionNub(): SessionNub { - return this._currentSessionNub; + public get currentNub(): Nub { + return this._currentNub; } - public set currentSessionNub(n: SessionNub) { - if (this._props["calcType"] !== n.properties.getPropValue("calcType")) { + public set currentNub(n: Nub) { + const nubCalcType = (n.properties as Props).getPropValue("calcType"); + if (this._props["calcType"] !== nubCalcType) { throw new Error( `Nub ${n.properties["calcType"]} incompatible avec le formulaire ${this._calculatorName} (${this._props["calcType"]})` ); } - this._currentSessionNub = n; + this._currentNub = n; } private findNub(params: Props | {}) { - return this._paramService.findSessionNub(params); + return this._paramService.findNub(params); } - protected createSessionNub(params: Props | {}): SessionNub { - return this._paramService.createSessionNub(params); + protected createNub(params: Props | {}): Nub { + const props = params instanceof Props ? params : new Props(params); + return this._paramService.createNub(props); } /** * @return le Nub associé à un type de noeud donné, le crée si nécessaire * @param params paramètres de contexte de création du nub */ - protected getSessionNub(params: Props | {}): SessionNub { + protected getNub(params: Props | {}): Nub { let res = this.findNub(params); if (!res) { - res = this.createSessionNub(params); + res = this.createNub(params); } return res; } - protected replaceCurrentSessionNub(params: Props) { - this.currentSessionNub = this._paramService.replaceSessionNub(this._currentSessionNub, params); + protected replaceCurrentNub(params: Props) { + this.currentNub = this._paramService.replaceNub(this._currentNub, params); } - protected replaceSessionNub(sn: SessionNub, params: Props): SessionNub { - return this._paramService.replaceSessionNub(sn, params); + protected replaceNub(sn: Nub, params: Props): Nub { + return this._paramService.replaceNub(sn, params); } /** @@ -133,17 +135,17 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs * @param params paramètres de contexte de création du nub */ protected getNubParamFromSymbol(symbol: string, params: Props | {}): ParamDefinition { - const sessionNub: SessionNub = this.getSessionNub(params); + const nub: Nub = this.getNub(params); - if (sessionNub) { - return sessionNub.nub.getParameter(symbol); + if (nub) { + return nub.getParameter(symbol); } throw new Error(`FormulaireDefinition.getNubParamFromSymbol() : pas de Nub trouvé pour ${params}`); } - protected deleteSessionNub(sn: SessionNub) { - this._paramService.deleteSessionNub(sn); + protected deleteNub(sn: Nub) { + this._paramService.deleteNub(sn); } protected initParse() { @@ -171,7 +173,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs public createFieldset(parent: FormulaireNode, json: {}, data?: {}): FieldSet { const res: FieldSet = new FieldSet(parent); - res.setSessionNub(this._currentSessionNub, false); + res.setNub(this._currentNub, false); this.kids.push(res); return res; } @@ -292,7 +294,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs // console.log("-----"); - // for (const n of Session.getInstance().sessionNubIterator) { + // for (const n of Session.getInstance().NubIterator) { // console.log(n.nub); // for (const p of n.nub.parameterIterator) // console.log(`${p.symbol} uid ${p.uid} props ${n.properties} mode ${p.valueMode} val ${p.uncheckedValue}`); @@ -300,7 +302,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs // logObject(this._fieldSets, "fieldsets"); // logObject(this._dependencies, "dependences"); - this.parseDependencies(this._jsonConfig); } @@ -489,7 +490,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs const res = {}; res["id"] = this.calculatorName; res["uid"] = this.uid; - res["props"] = this._currentSessionNub.properties.props; + res["props"] = (this._currentNub.properties as Props).props; res["elements"] = this.serialiseKids(); return { "form": res }; } diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index 97484a818..f69701b00 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -1,4 +1,4 @@ -import { CalculatorType, ComputeNodeType, ParamDefinition, LoiDebit, StructureType, Props, SessionNub, Observer } from "jalhyd"; +import { CalculatorType, ComputeNodeType, ParamDefinition, LoiDebit, StructureType, Props, Observer, Nub } from "jalhyd"; import { FormulaireElement } from "./formulaire-element"; import { Field } from "./field"; @@ -13,9 +13,9 @@ import { FormulaireNode } from "./formulaire-node"; export class FieldSet extends FormulaireElement implements Observer { /** - * SessionNub associé + * Nub associé */ - private _sessionNub: SessionNub; + private _nub: Nub; /** * dictionnaire de traduction @@ -37,13 +37,13 @@ export class FieldSet extends FormulaireElement implements Observer { this._props = new Props(); } - public get sessionNub(): SessionNub { - return this._sessionNub; + public get nub(): Nub { + return this._nub; } - public setSessionNub(sn: SessionNub, update: boolean = true) { - this._sessionNub = sn; - this._props.setProps(sn.properties, this); + public setNub(sn: Nub, update: boolean = true) { + this._nub = sn; + this._props.setProps(sn.properties || new Props({}), this); if (update) { this.updateFields(); } @@ -116,7 +116,7 @@ export class FieldSet extends FormulaireElement implements Observer { } private getNubParamFromSymbol(symbol: string): ParamDefinition { - return this._sessionNub.nub.getParameter(symbol); + return this._nub.getParameter(symbol); } public get jsonConfig(): {} { @@ -206,7 +206,7 @@ export class FieldSet extends FormulaireElement implements Observer { } /** - * @param createOrUpdate true pour forcer la création d'un SessionNub + * @param createOrUpdate true pour forcer la création d'un Nub */ private updateFields() { this.clearFields(); diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index 385f056c8..3fbec68f3 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -169,7 +169,7 @@ export class FormulaireService extends Observable { if (jsonState === undefined) { fi.calculatorName = decode(this.getLocalisedTitleFromCalculatorType(ct) + " (" + fi.uid + ")"); } - fi.initSessionNub(); + fi.initNub(); return fi; }).then(fi => { fi.parseConfig(undefined); @@ -485,17 +485,17 @@ export class FormulaireService extends Observable { if (p !== undefined) { for (const f of this._formulaires) { // nub associé au formulaire - const sn = f.currentSessionNub; + const sn = f.currentNub; try { // on vérifie que le paramètre en entrée appartient au nub - const np = sn.nub.getParameter(p.symbol); + const np = sn.getParameter(p.symbol); // si oui, on demande à exclure des valeurs retournées le résultat du même nom que le paramètre const exclude = np !== undefined ? p.paramDefinition.uid === np.uid : false; // valeurs liables - const ps = sn.getLinkableValues(p.paramDefinition, exclude); + const ps = sn.getLinkableValues(p.paramDefinition, undefined, exclude); for (const npp of ps) { npp["formTitle"] = f.calculatorName; res.push(npp); diff --git a/src/app/services/param/param.service.ts b/src/app/services/param/param.service.ts index 0c529caf3..0a564be12 100644 --- a/src/app/services/param/param.service.ts +++ b/src/app/services/param/param.service.ts @@ -1,4 +1,4 @@ -import { ParamDomain, ParamDefinition, ParamDomainValue, ParamCalculability, Session, SessionNub, Props } from "jalhyd"; +import { ParamDomain, ParamDefinition, ParamDomainValue, ParamCalculability, Session, Props, Nub } from "jalhyd"; import { NgParameter } from "../../formulaire/ngparam"; import { Injectable } from "@angular/core"; @@ -91,19 +91,20 @@ export class ParamService { return p; } - public createSessionNub(params: Props | {}): SessionNub { - return Session.getInstance().createSessionNub(params); + public createNub(params: Props | {}): Nub { + const truc = Session.getInstance().createSessionNub(params); + return truc; } - public findSessionNub(params: Props | {}): SessionNub { - return Session.getInstance().findSessionNub(params); + public findNub(params: Props | {}): Nub { + return Session.getInstance().findNub(params); } - public replaceSessionNub(sn: SessionNub, params: Props): SessionNub { - return Session.getInstance().replaceSessionNub(sn, params); + public replaceNub(sn: Nub, params: Props): Nub { + return Session.getInstance().replaceNub(sn, params); } - public deleteSessionNub(sn: SessionNub) { - Session.getInstance().deleteSessionNub(sn); + public deleteNub(sn: Nub) { + Session.getInstance().deleteNub(sn); } } -- GitLab From 06cc7ff09a2af1ae939e6b4fbe76d16a287fc7fa Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 17 Jan 2019 10:12:03 +0100 Subject: [PATCH 7/8] =?UTF-8?q?Suppression=20m=C3=A9thodes=20inutilis?= =?UTF-8?q?=C3=A9es=20li=C3=A9es=20=C3=A0=20Props?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../formulaire/definition/form-definition.ts | 31 ------------------- src/app/services/param/param.service.ts | 4 --- 2 files changed, 35 deletions(-) diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index 9347ec050..0985db957 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -100,27 +100,11 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs this._currentNub = n; } - private findNub(params: Props | {}) { - return this._paramService.findNub(params); - } - protected createNub(params: Props | {}): Nub { const props = params instanceof Props ? params : new Props(params); return this._paramService.createNub(props); } - /** - * @return le Nub associé à un type de noeud donné, le crée si nécessaire - * @param params paramètres de contexte de création du nub - */ - protected getNub(params: Props | {}): Nub { - let res = this.findNub(params); - if (!res) { - res = this.createNub(params); - } - return res; - } - protected replaceCurrentNub(params: Props) { this.currentNub = this._paramService.replaceNub(this._currentNub, params); } @@ -129,21 +113,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs return this._paramService.replaceNub(sn, params); } - /** - * @return le paramètre d'un type de noeud - * @param symbol symbole du paramètre - * @param params paramètres de contexte de création du nub - */ - protected getNubParamFromSymbol(symbol: string, params: Props | {}): ParamDefinition { - const nub: Nub = this.getNub(params); - - if (nub) { - return nub.getParameter(symbol); - } - - throw new Error(`FormulaireDefinition.getNubParamFromSymbol() : pas de Nub trouvé pour ${params}`); - } - protected deleteNub(sn: Nub) { this._paramService.deleteNub(sn); } diff --git a/src/app/services/param/param.service.ts b/src/app/services/param/param.service.ts index 0a564be12..6e5362f39 100644 --- a/src/app/services/param/param.service.ts +++ b/src/app/services/param/param.service.ts @@ -96,10 +96,6 @@ export class ParamService { return truc; } - public findNub(params: Props | {}): Nub { - return Session.getInstance().findNub(params); - } - public replaceNub(sn: Nub, params: Props): Nub { return Session.getInstance().replaceNub(sn, params); } -- GitLab From d0ae7476922d61596664ca14c558e2703fe7f853 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 17 Jan 2019 10:14:05 +0100 Subject: [PATCH 8/8] Liaison jalhyd_branch --- jalhyd_branch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jalhyd_branch b/jalhyd_branch index 1f7391f92..bd388944e 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -master +58-nettoyage-et-simplification-du-code -- GitLab