From 35dd5460d15b7b306a6297b24576a0701d11815a Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 13 Jun 2019 11:14:07 +0200 Subject: [PATCH] =?UTF-8?q?Pab=20:=20mod=C3=A8le=20maintenu=20entre=20deux?= =?UTF-8?q?=20=C3=A9ditions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pab-table/pab-table.component.ts | 84 ------------------- .../definition/concrete/form-pab.ts | 10 +-- .../services/formulaire/formulaire.service.ts | 36 +++++++- 3 files changed, 37 insertions(+), 93 deletions(-) diff --git a/src/app/components/pab-table/pab-table.component.ts b/src/app/components/pab-table/pab-table.component.ts index 162b5f89d..9feccf6df 100644 --- a/src/app/components/pab-table/pab-table.component.ts +++ b/src/app/components/pab-table/pab-table.component.ts @@ -5,10 +5,8 @@ import { MatDialog } from "@angular/material"; import { Pab, Session, - PabCloisons, Props, CalculatorType, - LoiDebit, Cloisons, Nub, Structure, @@ -297,89 +295,7 @@ export class PabTableComponent implements /* DoCheck, AfterViewInit, */ OnInit { // at this time @Input data is supposed to be already populated public ngOnInit() { - // get model this.model = this.pabTable.pab; - - // ------------- TEST ------------------------ - - // empty PAB - const chLen = this.model.children.length; - for (let i = 0; i < chLen; i++) { - this.model.deleteChild(0); - } - - // cloison à 1 ouvrage - const cl1 = Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Cloisons }) - ) as Cloisons; - cl1.addChild(Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Structure, loiDebit: LoiDebit.RectangularOrificeFree }), cl1 - )); - // PabCloison associé - const pc1 = Session.getInstance().createNub( - new Props({ calcType: CalculatorType.PabCloisons }), this.model - ) as PabCloisons; - pc1.initModelCloisons(cl1); - pc1.prms.setCurrentValuesFromModel(); - this.model.addChild(pc1); - this.dumpParams(pc1); - - // cloison à 3 ouvrages - const cl2 = Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Cloisons }) - ) as Cloisons; - cl2.addChild(Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Structure, loiDebit: LoiDebit.GateCem88v }), cl2 - )); - cl2.addChild(Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Structure, loiDebit: LoiDebit.RectangularOrificeFree }), cl2 - )); - cl2.addChild(Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Structure, loiDebit: LoiDebit.RectangularOrificeSubmerged }), cl2 - )); - // PabCloison associé - const pc2 = Session.getInstance().createNub( - new Props({ calcType: CalculatorType.PabCloisons }), this.model - ) as PabCloisons; - pc2.initModelCloisons(cl2); - pc2.prms.setCurrentValuesFromModel(); - this.model.addChild(pc2); - this.dumpParams(pc2); - - // cloison à 2 ouvrages - const cl3 = Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Cloisons }) - ) as Cloisons; - cl3.addChild(Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Structure, loiDebit: LoiDebit.GateCem88v }), cl3 - )); - cl3.addChild(Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Structure, loiDebit: LoiDebit.RectangularOrificeFree }), cl3 - )); - // PabCloison associé - const pc3 = Session.getInstance().createNub( - new Props({ calcType: CalculatorType.PabCloisons }), this.model - ) as PabCloisons; - pc3.initModelCloisons(cl3); - pc3.prms.setCurrentValuesFromModel(); - this.model.addChild(pc3); - this.dumpParams(pc3); - - // cloison aval à 1 ouvrage - const cloisonAval: ParallelStructure = Session.getInstance().createSessionNub( - new Props({ calcType: CalculatorType.ParallelStructure }) - ) as ParallelStructure; - cloisonAval.addChild(Session.getInstance().createNub( - new Props({ calcType: CalculatorType.Structure, loiDebit: LoiDebit.KIVI }), cloisonAval - )); - this.model.setDownWall(cloisonAval.uid); - this.dumpParams(this.model.downWall); - - // debug - console.log("Model in ngOnInit:", this.model); - - // ------------- FIN TEST -------------------- - this.refresh(); } diff --git a/src/app/formulaire/definition/concrete/form-pab.ts b/src/app/formulaire/definition/concrete/form-pab.ts index 0ad94bf66..22371ff1c 100644 --- a/src/app/formulaire/definition/concrete/form-pab.ts +++ b/src/app/formulaire/definition/concrete/form-pab.ts @@ -1,11 +1,5 @@ -import { /* Nub, Props, Session, PabCloisons, */ Pab } from "jalhyd"; - -/* import { FieldsetContainer } from "../../fieldset-container"; -import { FieldSet } from "../../fieldset"; -import { SelectField } from "../../select-field"; -import { NgParameter } from "../../ngparam"; -import { FieldsetTemplate } from "../../fieldset-template"; -import { FormulaireNode } from "../../formulaire-node"; */ +import { Pab } from "jalhyd"; + import { FormulaireBase } from "./form-base"; import { FormComputePab } from "../form-compute-pab"; import { FormResultPab } from "../form-result-pab"; diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index d33770c26..76308dbd5 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -3,7 +3,7 @@ import { Injectable } from "@angular/core"; import { decode } from "he"; import { saveAs } from "file-saver"; -import { CalculatorType, LinkedValue, Observable, ParamDefinition, Session, Nub, ParallelStructure, Pab } from "jalhyd"; +import { CalculatorType, LinkedValue, Observable, ParamDefinition, Session, Nub, ParallelStructure, Pab, Props, Cloisons } from "jalhyd"; import { HttpService } from "../../services/http/http.service"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; @@ -345,6 +345,40 @@ export class FormulaireService extends Observable { } } + // when creating a new Pab, add one wall with one device, plus the downwall + if (f instanceof FormulairePab) { + // 1. one wall + const newWall = Session.getInstance().createNub( + new Props({ + calcType: CalculatorType.Cloisons + }) + ) as Cloisons; + // add new default device for new wall + const newDevice = Session.getInstance().createNub( + new Props({ + calcType: CalculatorType.Structure, + loiDebit: newWall.getDefaultLoiDebit() + }) + ); + newWall.addChild(newDevice); + f.pabNub.addChild(newWall); + // 2. downwall + const newDownWall = Session.getInstance().createNub( + new Props({ + calcType: CalculatorType.ParallelStructure + }) + ) as ParallelStructure; + // add new default device for new downwall + const newDownwallDevice = Session.getInstance().createNub( + new Props({ + calcType: CalculatorType.Structure, + loiDebit: newDownWall.getDefaultLoiDebit() + }) + ); + newDownWall.addChild(newDownwallDevice); + f.pabNub.downWall = newDownWall; + } + return f; }).then(fi => { -- GitLab