An error occurred while loading the file. Please try again.
-
Mathias Chouet authored252e6781
import { Component, Input, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { SelectEntry } from "../../formulaire/select-entry";
import { FormulaireService } from "../../services/formulaire/formulaire.service";
import { CalculatorType } from "jalhyd";
import { FormulaireDefinition } from "../../formulaire/definition/form-definition";
import { FieldsetContainer } from "../../formulaire/fieldset-container";
import { SelectFieldCloisons } from "../../formulaire/select-field-cloisons";
@Component({
selector: "select-cloisons-field-line",
templateUrl: "./select-cloisons-field-line.component.html",
styleUrls: [
"./select-cloisons-field-line.component.scss"
]
})
export class SelectCloisonsFieldLineComponent implements OnInit {
@Input()
private _select: SelectFieldCloisons;
public constructor(
private _formService: FormulaireService,
private router: Router
) {}
public get selectId() {
return this._select.id;
}
public get entries(): SelectEntry[] {
if (! this._select) {
return [];
}
return this._select.entries;
}
public get cloisonsUid() {
return this.selectedValue ? this.selectedValue.id : "";
}
// called every time we navigate to the module
ngOnInit(): void {
console.log("------------------------- SF dans le onInit", this._select.constructor.name);
this._select.updateEntries();
}
/**
* Label d'une entrée du select des modèles de cloisons
*/
public selectItemLabel(entry: SelectEntry): string {
if (entry && entry.id) {
const cloisonsForm = this._formService.getFormulaireFromNubId(entry.id);
const name = cloisonsForm.calculatorName;
return name;
}
}
public get selectedValue(): SelectEntry {
return this._select.getValue();
}
public set selectedValue(v: SelectEntry) {
this._select.setValue(v);
}
public get label() {
if (this._select) {
return this._select.label;
} else {
717273747576777879808182838485868788899091
return "";
}
}
public createCloisons() {
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;
}
}
});
}
}