diff --git a/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.html b/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.html index 5f8e91036c4a72b6e89547048baec7ff0601041e..5e293865720bb633e1c9b7baac1643d7cbf2c8c3 100644 --- a/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.html +++ b/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.html @@ -14,7 +14,7 @@ <div class="button-container" fxFlex="0 0 auto"> <button mat-icon-button *ngIf="selectedValue" [routerLink]="['/calculator/', cloisonsUid]"> - <mat-icon>settings</mat-icon> + <mat-icon>edit</mat-icon> </button> <button mat-icon-button *ngIf="entries.length === 0" (click)="createCloisons()"> <mat-icon>add_circle_outline</mat-icon> diff --git a/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.ts b/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.ts index 80612a8bf9940776db0ef3e59e81dc5944dd9826..652f36fbe2534d5876d4fe46bc76474957cc4e7d 100644 --- a/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.ts +++ b/src/app/components/select-cloisons-field-line/select-cloisons-field-line.component.ts @@ -1,9 +1,12 @@ import { Component, Input, OnInit } from "@angular/core"; +import { Router } from "@angular/router"; import { SelectField } from "../../formulaire/select-field"; import { SelectEntry } from "../../formulaire/select-entry"; import { FormulaireService } from "../../services/formulaire/formulaire.service"; -import { Session } from "jalhyd"; +import { Session, CalculatorType } from "jalhyd"; +import { FormulaireDefinition } from "../../formulaire/definition/form-definition"; +import { FieldsetContainer } from "../../formulaire/fieldset-container"; @Component({ selector: "select-cloisons-field-line", @@ -17,7 +20,8 @@ export class SelectCloisonsFieldLineComponent implements OnInit { private _select: SelectField; public constructor( - private _formService: FormulaireService + private _formService: FormulaireService, + private router: Router ) {} public get selectId() { @@ -88,6 +92,18 @@ export class SelectCloisonsFieldLineComponent implements OnInit { } public createCloisons() { - console.log("CREATE CLOISONS !!"); + const p: Promise<FormulaireDefinition> = this._formService.createFormulaire(CalculatorType.Cloisons); + p.then(f => { + this.router.navigate(["/calculator", f.uid]); + return f; + }).then(f => { + // on ajoute un ouvrage au module "cloisons" + for (const e of f.allFormElements) { + if (e instanceof FieldsetContainer) { + e.addFromTemplate(0); + break; + } + } + }); } }