diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c43bf5be39312fea1af54731bd0dc99861ec57c8..811356e827b358e5e6951a1ea80686d848e3129b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -187,9 +187,9 @@ export class AppComponent implements OnInit, OnDestroy, Observer { } } - private getCalculatorIndexFromId(formId: number) { + private getCalculatorIndexFromId(formId: string) { const index = this._calculators.reduce((resultIndex, calc, currIndex) => { - if (resultIndex === -1 && +calc["uid"] === formId) { + if (resultIndex === -1 && calc["uid"] === formId) { resultIndex = currIndex; } return resultIndex; @@ -214,7 +214,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer { // création de la liste des formulaires const list = []; for (const c of this._calculators) { - const uid = +c["uid"]; + const uid = c["uid"]; list.push({ "selected": uid === form.uid, "title": c["title"], @@ -252,7 +252,7 @@ export class AppComponent implements OnInit, OnDestroy, Observer { } private closeCalculator(form: FormulaireDefinition) { - const formId: number = form.uid; + const formId: string = form.uid; // désabonnement en tant qu'observateur @@ -268,27 +268,27 @@ export class AppComponent implements OnInit, OnDestroy, Observer { * - ou celle avant celle supprimée si on supprime la dernière */ - let newId = -1; + let newId = null; const l = this._calculators.length; if (l > 1) { if (closedIndex === l - 1) { - newId = +this._calculators[closedIndex - 1]["uid"]; + newId = this._calculators[closedIndex - 1]["uid"]; } else { - newId = +this._calculators[closedIndex + 1]["uid"]; + newId = this._calculators[closedIndex + 1]["uid"]; } } // suppression this._calculators = this._calculators.filter(calc => { - return formId !== +calc["uid"]; + return formId !== calc["uid"]; }); // MAJ affichage - if (newId === -1) { + if (newId === null) { this.toList(); - this._currentFormId = -1; + this._currentFormId = null; } else { this.toCalc(newId); } 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 392d56ebbe672e41c40c228416dd263d283aca04..0ad0c67169448065bfd9935c5b7e46521427a4ba 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 @@ -12,7 +12,8 @@ export class NgBaseParam extends Observable { constructor(symb: string, d: ParamDomain | ParamDomainValue, val: number) { super(); - this._param = new ParamDefinition(symb, d, val); + console.log(">> new paramdef", symb); + this._param = new ParamDefinition(null, symb, d, val); } public get symbol() { diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index a2c9b14cf171a5271a19e36428800aaab671f20d..c71f47b8597e18dc8d76f7aad080d6289e0eab7a 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -172,8 +172,8 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit, private subscribeRouter() { // récupération des paramètres passés avec la route (URL) this._subscription = this.route.params.subscribe(params => { - const uid: number = params["uid"]; - this.formulaireService.setCurrentForm(+uid); + const uid: string = params["uid"]; + this.formulaireService.setCurrentForm(uid); }); } @@ -266,7 +266,7 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit, } } - private updateFormulaireResults(uid: number) { + private updateFormulaireResults(uid: string) { if (this._formulaire.uid === uid) { this.resultsComponent.updateView(); } @@ -280,7 +280,7 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit, } else if (sender instanceof FormulaireService) { switch (data["action"]) { case "currentFormChanged": - const uid: number = +data["formId"]; + const uid: string = data["formId"]; this.setForm(this.formulaireService.getFormulaireFromId(uid)); this.resultsComponent.formulaire = this._formulaire; this._calculatorNameComponent.model = this._formulaire; diff --git a/src/app/components/load-calculator/load-calculator.component.ts b/src/app/components/load-calculator/load-calculator.component.ts index 5fa455f31f77a61e60cea9cdc8bc79c09e601cb6..655d3baf237c65fd83cb55a0b718a97623ae2c94 100644 --- a/src/app/components/load-calculator/load-calculator.component.ts +++ b/src/app/components/load-calculator/load-calculator.component.ts @@ -131,7 +131,7 @@ export class LoadCalculatorComponent { private onCheckCalc(event: any) { for (const c of this._calculators) { - if (c.uid === +event.target.value) { + if (c.uid === event.target.value) { c.selected = event.target.checked; break; } diff --git a/src/app/components/save-calculator/save-calculator.component.ts b/src/app/components/save-calculator/save-calculator.component.ts index 2dfd207bb8f65e1d9c305c31a071a9b0c794e497..653e76c4bffce16c3a14360ffa357c5ac5987810 100644 --- a/src/app/components/save-calculator/save-calculator.component.ts +++ b/src/app/components/save-calculator/save-calculator.component.ts @@ -91,7 +91,7 @@ export class SaveCalculatorComponent { private onCheckCalc(event: any) { for (const c of this._calculators) { - if (c.uid === +event.target.value) { + if (c.uid === event.target.value) { c.selected = event.target.checked; } } diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index 0985db9573718d1191c0209954853ff407fce753..1154c95023f638f1ea264c5a5a98adb16eb2d0bf 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -1,4 +1,4 @@ -import { CalculatorType, ComputeNodeType, Nub, ParamDefinition, Props, Observer } from "jalhyd"; +import { CalculatorType, ComputeNodeType, Nub, Props, Observer } from "jalhyd"; import { FormulaireElement } from "../formulaire-element"; import { NgParameter, ParamRadioConfig } from "../ngparam"; @@ -91,6 +91,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs } public set currentNub(n: Nub) { + console.log("set current nub", n); const nubCalcType = (n.properties as Props).getPropValue("calcType"); if (this._props["calcType"] !== nubCalcType) { throw new Error( @@ -101,19 +102,23 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs } protected createNub(params: Props | {}): Nub { + console.log("create nub", params); const props = params instanceof Props ? params : new Props(params); return this._paramService.createNub(props); } protected replaceCurrentNub(params: Props) { + console.log("replace current nub", params); this.currentNub = this._paramService.replaceNub(this._currentNub, params); } protected replaceNub(sn: Nub, params: Props): Nub { + console.log("replace nub", params); return this._paramService.replaceNub(sn, params); } protected deleteNub(sn: Nub) { + console.log("delete nub", sn); this._paramService.deleteNub(sn); } diff --git a/src/app/formulaire/fieldset.ts b/src/app/formulaire/fieldset.ts index f69701b00eaa7adb0dfed353ebd4197b70b68520..4024161b41276b54dd8763a73bfbd4719da2d850 100644 --- a/src/app/formulaire/fieldset.ts +++ b/src/app/formulaire/fieldset.ts @@ -43,6 +43,7 @@ export class FieldSet extends FormulaireElement implements Observer { public setNub(sn: Nub, update: boolean = true) { this._nub = sn; + this.setParentNubForAllFields(); this._props.setProps(sn.properties || new Props({}), this); if (update) { this.updateFields(); @@ -123,6 +124,9 @@ export class FieldSet extends FormulaireElement implements Observer { return this._jsonConfig; } + private setParentNubForAllFields() { + } + /** * crée un input * @param json definition de l'input, extrait du fichier de conf de la calculette diff --git a/src/app/formulaire/formulaire-node.ts b/src/app/formulaire/formulaire-node.ts index 128e3b1002f9a516f12c97d95651fb5e44cb7f25..44245795e47a5a381c6f6382603a7d392ff6f5ac 100644 --- a/src/app/formulaire/formulaire-node.ts +++ b/src/app/formulaire/formulaire-node.ts @@ -12,7 +12,7 @@ export abstract class FormulaireNode implements IObservable { /** * id numérique unique */ - private _uid: number; + private _uid: string; /** * parent direct @@ -77,7 +77,7 @@ export abstract class FormulaireNode implements IObservable { /** * cherche un FormulaireNode par son id numérique unique */ - public getFormulaireNodeByUid(uid: number): FormulaireNode { + public getFormulaireNodeByUid(uid: string): FormulaireNode { if (this.uid === uid) { return this; } diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts index d8c61df5cb7487fc54c780f7a6eeae49c64ae466..23c2eeb133de914ed704bb86f22e94c0fc0b2153 100644 --- a/src/app/results/remous-results.ts +++ b/src/app/results/remous-results.ts @@ -97,7 +97,7 @@ export class RemousResults extends CalculatorResults { const Dx = p.map.Dx.v; // série de valeurs de X - this._xValues = new ParamDefinition("Abscisse", ParamDomainValue.POS_NULL); + this._xValues = new ParamDefinition(p, "Abscisse", ParamDomainValue.POS_NULL); this._xValues.paramValues.setValues(0, Long, Dx); } @@ -138,7 +138,8 @@ export class RemousResults extends CalculatorResults { this._varResults = new VarResults(); this._varResults.variatedParameter = new NgParameter(this._xValues, undefined); - this._varResults.calculatedParameter = new NgParameter(new ParamDefinition("Ligne d'eau", ParamDomainValue.POS_NULL), undefined); + this._varResults.calculatedParameter + = new NgParameter(new ParamDefinition(null, "Ligne d'eau", ParamDomainValue.POS_NULL), undefined); this._varResults.result = this._result; const keys = []; if (this._hasFlu) { diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index 3fbec68f3b0a400e1edce4c870ba0d959934aca6..67055680b0da7097900d882ca9d7c11560655228 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -29,7 +29,7 @@ import { NgParameter } from "../../formulaire/ngparam"; export class FormulaireService extends Observable { private _formulaires: FormulaireDefinition[]; - private _currentFormId = -1; + private _currentFormId: string = null; constructor() { super(); @@ -62,7 +62,7 @@ export class FormulaireService extends Observable { * @param formId id unique du formulaire * @param localisation ensemble id-message traduit */ - private updateFormulaireLocalisation(formId: number, localisation: StringMap) { + private updateFormulaireLocalisation(formId: string, localisation: StringMap) { for (const f of this._formulaires) { if (f.uid === formId) { f.updateLocalisation(localisation); @@ -197,7 +197,7 @@ export class FormulaireService extends Observable { }); } - public getFormulaireFromId(uid: number): FormulaireDefinition { + public getFormulaireFromId(uid: string): FormulaireDefinition { for (const f of this._formulaires) { if (f.uid === uid) { return f; @@ -207,7 +207,7 @@ export class FormulaireService extends Observable { return undefined; } - public getInputField(formId: number, elemId: string): InputField { + public getInputField(formId: string, elemId: string): InputField { const s = this.getFormulaireElementById(formId, elemId); if (!(s instanceof InputField)) { throw new Error("Form element with id '" + elemId + "' is not an input"); @@ -215,7 +215,7 @@ export class FormulaireService extends Observable { return <InputField>s; } - public getCheckField(formId: number, elemId: string): CheckField { + public getCheckField(formId: string, elemId: string): CheckField { const s = this.getFormulaireElementById(formId, elemId); if (!(s instanceof CheckField)) { throw new Error("Form element with id '" + elemId + "' is not a checkbox"); @@ -223,7 +223,7 @@ export class FormulaireService extends Observable { return <CheckField>s; } - public getSelectField(formId: number, elemId: string): SelectField { + public getSelectField(formId: string, elemId: string): SelectField { const s = this.getFormulaireElementById(formId, elemId); if (!(s instanceof SelectField)) { throw new Error("Form element with id '" + elemId + "' is not a select"); @@ -231,7 +231,7 @@ export class FormulaireService extends Observable { return <SelectField>s; } - private getFormulaireElementById(formId: number, elemId: string): FormulaireElement { + private getFormulaireElementById(formId: string, elemId: string): FormulaireElement { for (const f of this._formulaires) { if (f.uid === formId) { const s = f.getFormulaireNodeById(elemId); @@ -300,7 +300,7 @@ export class FormulaireService extends Observable { } } - public requestCloseForm(uid: number) { + public requestCloseForm(uid: string) { const form = this.getFormulaireFromId(uid); if (form !== undefined) { this._formulaires = this._formulaires.filter(f => f.uid !== uid); @@ -316,10 +316,10 @@ export class FormulaireService extends Observable { return this._currentFormId; } - public setCurrentForm(formId: number) { + public setCurrentForm(formId: string) { const form = this.getFormulaireFromId(formId); if (form === undefined) { - this._currentFormId = -1; + this._currentFormId = null; this.notifyObservers({ "action": "invalidFormId", "formId": formId @@ -493,7 +493,7 @@ export class FormulaireService extends Observable { // 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; - + console.log("ça passe 1"); // valeurs liables const ps = sn.getLinkableValues(p.paramDefinition, undefined, exclude); for (const npp of ps) { diff --git a/src/app/services/param/param.service.ts b/src/app/services/param/param.service.ts index 6e5362f391f07f5c3e99f459234c852ecebec92a..7f3ef4039a349d0262f1b77a944c5d906dea55e6 100644 --- a/src/app/services/param/param.service.ts +++ b/src/app/services/param/param.service.ts @@ -19,7 +19,7 @@ export class ParamService { private createAccuracyParameter(): ParamDefinition { const d = new ParamDomain(ParamDomainValue.INTERVAL, 1e-10, 100); - const p = new ParamDefinition("Pr", d, this._appSetupService.computePrecision); + const p = new ParamDefinition(null, "Pr", d, this._appSetupService.computePrecision); p.calculability = ParamCalculability.FREE; return p; } @@ -37,7 +37,7 @@ export class ParamService { p.confId = "Pr"; } else { const dom = new ParamDomain(ParamDomainValue.POS_NULL); - p = new NgParameter(new ParamDefinition(symbol, dom), parent); + p = new NgParameter(new ParamDefinition(null, symbol, dom), parent); p.confId = symbol; switch (symbol) {