Client datatables to be shown on the Client creation page based on legal form

This commit is contained in:
Jose Alberto Hernandez
2022-11-14 20:38:31 -06:00
parent 0cdf6bad3c
commit e991c8a881
3 changed files with 29 additions and 4 deletions
@@ -33,6 +33,9 @@ export class CreateClientComponent {
/** Get handle on dtclient tags in the template */
@ViewChildren('dtclient') clientDatatables: QueryList<ClientDatatableStepComponent>;
datatables: any = [];
legalFormType = 1;
/** Client Template */
clientTemplate: any;
/** Client Address Field Config */
@@ -52,6 +55,7 @@ export class CreateClientComponent {
this.route.data.subscribe((data: { clientTemplate: any, clientAddressFieldConfig: any }) => {
this.clientTemplate = data.clientTemplate;
this.clientAddressFieldConfig = data.clientAddressFieldConfig;
this.setDatatables();
});
}
@@ -94,6 +98,24 @@ export class CreateClientComponent {
return areValids;
}
setDatatables(): void {
this.datatables = [];
let legalFormTypeVal = 'Person';
if (this.legalFormType === 2) {
legalFormTypeVal = 'Entity';
}
this.clientTemplate.datatables.forEach((datatable: any) => {
if (datatable.entitySubType === legalFormTypeVal) {
this.datatables.push(datatable);
}
});
}
legalFormChange(eventData: { legalForm: number }) {
this.legalFormType = eventData.legalForm;
this.setDatatables();
}
/**
* Submits the create client form.
*/