Skip to content
Snippets Groups Projects
Commit 170e5f96 authored by David Dorchies's avatar David Dorchies
Browse files

jalhyd/#33 Delete references to PabCloisons. #93 Working generation of PAB...

jalhyd/#33 Delete references to PabCloisons. #93 Working generation of PAB from cloison (new version).
parent efbc620a
No related branches found
No related tags found
1 merge request!49Resolve "Ajout du module de calcul d'une passe à bassins"
......@@ -79,7 +79,6 @@ export class CalculatorListComponent implements OnInit {
if ( // those sub-Nub types cannot be built outside a parent
t !== CalculatorType.Structure
&& t !== CalculatorType.Section
&& t !== CalculatorType.PabCloisons
) {
unusedTheme.calculators.push({
type: t,
......
......@@ -2,7 +2,7 @@ import { Component, OnInit, DoCheck, OnDestroy, ViewChild, ViewChildren,
QueryList, AfterViewChecked, ElementRef } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { Observer, Session, Cloisons, Pab, PabCloisons, ParamValueMode, CalculatorType } from "jalhyd";
import { Observer, Session, Cloisons, Pab, ParamValueMode, CalculatorType } from "jalhyd";
import { FormulaireService } from "../../services/formulaire/formulaire.service";
import { I18nService } from "../../services/internationalisation/internationalisation.service";
......@@ -21,7 +21,6 @@ import { ServiceFactory } from "../../services/service-factory";
import { MatDialog } from "@angular/material";
import { DialogConfirmCloseCalcComponent } from "../dialog-confirm-close-calc/dialog-confirm-close-calc.component";
import { DialogGeneratePABComponent } from "../dialog-generate-pab/dialog-generate-pab.component";
import { SelectFieldModel } from "../../formulaire/select-field-model";
import { PabTable } from "../../formulaire/pab-table";
@Component({
......@@ -484,21 +483,8 @@ export class GenericCalculatorComponent extends BaseComponent implements OnInit,
params.Z1.singleValue = result.coteAmont;
params.Z2.singleValue = result.coteAval;
// création des bassins
for (let i = 0; i < result.nbBassins; i++) {
const pabCloisons = new PabCloisons(this._formulaire.currentNub as Cloisons);
pab.addChild(pabCloisons); // @TODO should be replace afterwards
for (const e of f.allFormElements) {
if (e instanceof FieldsetContainer) {
const newFieldset = e.addFromTemplate(0, undefined, pabCloisons);
// set selected value by ID; nub should be set by "select value changed" event listener
const modeleSelect = (newFieldset.getFormulaireNodeById("select_modele_cloisons") as SelectFieldModel);
modeleSelect.updateEntries();
// ID of the Cloisons nub used by pabCloisons as a model
modeleSelect.setValueFromId(this._formulaire.currentNub.uid);
break;
}
}
}
pab.deleteChild(0);
pab.addCloisonsFromModel(this._formulaire.currentNub as Cloisons, result.nbBassins);
// go to new PAB
this.router.navigate(["/calculator", f.uid]);
});
......
import { Input, Output, EventEmitter, ChangeDetectorRef, OnChanges, ViewChild } from "@angular/core";
import { NgModel } from "@angular/forms";
import { BaseComponent } from "../base/base.component";
import { isNumeric, Structure, PabCloisons } from "jalhyd";
import { isNumeric, Structure, Pab } from "jalhyd";
import { FormulaireDefinition } from "../../formulaire/definition/form-definition";
import { NgParameter } from "../../formulaire/ngparam";
import { I18nService } from "../../services/internationalisation/internationalisation.service";
......@@ -46,7 +46,7 @@ export abstract class GenericInputComponent extends BaseComponent implements OnC
// if inside a nested Structure, prefix with Structure position
// to disambiguate
const nub = param.paramDefinition.parentNub;
if (nub && (nub instanceof Structure || nub instanceof PabCloisons)) {
if (nub && (nub instanceof Structure || nub.parent instanceof Pab)) {
id = nub.findPositionInParent() + "_" + id;
}
}
......
......@@ -8,8 +8,6 @@ import { NgParameter, ParamRadioConfig } from "./ngparam";
import { FormulaireDefinition } from "./definition/form-definition";
import { StringMap } from "../stringmap";
import { FormulaireNode } from "./formulaire-node";
import { SelectFieldModelCloisons } from "./select-field-model-cloisons";
import { SelectFieldModelCloisonAval } from "./select-field-model-cloison-aval";
import { FieldsetContainer } from "./fieldset-container";
export class FieldSet extends FormulaireElement implements Observer {
......@@ -87,24 +85,6 @@ export class FieldSet extends FormulaireElement implements Observer {
return res;
}
// non-generic version of parse_select for SelectFieldModel because
// downcasting is not possible with @Input() apparently
private parse_select_cloisons(json: {}): SelectField {
const res: SelectFieldModel = new SelectFieldModelCloisons(this, CalculatorType.Cloisons);
res.parseConfig(json);
res.addObserver(this);
return res;
}
// non-generic version of parse_select for SelectFieldCloisonAval because
// downcasting is not possible with @Input() apparently
private parse_select_cloison_aval(json: {}): SelectField {
const res: SelectFieldModel = new SelectFieldModelCloisonAval(this, CalculatorType.ParallelStructure);
res.parseConfig(json);
res.addObserver(this);
return res;
}
public get properties(): Props {
return this.nub.properties;
}
......@@ -182,16 +162,6 @@ export class FieldSet extends FormulaireElement implements Observer {
this.addField(param);
break;
case "select_cloisons":
param = this.parse_select_cloisons(field);
this.addField(param);
break;
case "select_cloison_aval":
param = this.parse_select_cloison_aval(field);
this.addField(param);
break;
}
}
}
......
import { Session } from "jalhyd";
import { SelectEntry } from "./select-entry";
import { FieldSet } from "./fieldset";
import { SelectFieldModel } from "./select-field-model";
/**
* A select field that populates itself with references to
* available ParallelStructure modules (used by PAB)
*/
export class SelectFieldModelCloisonAval extends SelectFieldModel {
protected initSelectedValue() {
if (this.parent instanceof FieldSet) {
const mc = this.parent.nub.properties.getPropValue("modeleCloisonAval");
if (mc) {
this._selectedEntry = new SelectEntry(mc, {});
} // else if current model is undefined, do not select it so that default ParallelStructures will be chosen (if available)
}
}
/**
* Populates entries with available ParallelStructures
*/
protected populate() {
const psNubs = Session.getInstance().getParallelStructureNubs();
for (const cl of psNubs) {
const e = new SelectEntry(cl.uid, cl);
this.addEntry(e);
}
}
}
import { Session } from "jalhyd";
import { SelectEntry } from "./select-entry";
import { FieldSet } from "./fieldset";
import { SelectFieldModel } from "./select-field-model";
/**
* A select field that populates itself with references to
* available Cloisons modules (used by PAB)
*/
export class SelectFieldModelCloisons extends SelectFieldModel {
protected initSelectedValue() {
if (this.parent instanceof FieldSet) {
const mc = this.parent.nub.properties.getPropValue("modeleCloisons");
if (mc) {
this._selectedEntry = new SelectEntry(mc, {});
} // else if current model is undefined, do not select it so that default Cloisons will be chosen (if available)
}
}
/**
* Populates entries with available Cloisons
*/
protected populate() {
const cloisonsNubs = Session.getInstance().getCloisonsNubs();
for (const cl of cloisonsNubs) {
const e = new SelectEntry(cl.uid, cl);
this.addEntry(e);
}
}
}
......@@ -620,9 +620,10 @@ export class FormulaireService extends Observable {
}
// list Cloisons / downWall models dependencies for each PAB Nub
if (e.props.calcType === CalculatorType.Pab) {
// TODO Check if can be removed
// Cloisons models
e.children.forEach((c) => {
if (c.props.calcType === CalculatorType.PabCloisons) { // who knows ?
if (c.props.calcType === CalculatorType.Cloisons) { // who knows ?
if (c.props.modeleCloisons && ! nubInfo.requires.includes(c.props.modeleCloisons)) {
nubInfo.requires.push(c.props.modeleCloisons);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment