WEB-655 feat(clients): filter datatables by client subtype (Person/Entity) (#3120)
This commit is contained in:
@@ -24,6 +24,7 @@ import { CaptureImageDialogComponent } from './custom-dialogs/capture-image-dial
|
|||||||
|
|
||||||
/** Custom Services */
|
/** Custom Services */
|
||||||
import { ClientsService } from '../clients.service';
|
import { ClientsService } from '../clients.service';
|
||||||
|
import { LegalFormId } from '../models/legal-form.enum';
|
||||||
import {
|
import {
|
||||||
MatCard,
|
MatCard,
|
||||||
MatCardHeader,
|
MatCardHeader,
|
||||||
@@ -144,11 +145,26 @@ export class ClientsViewComponent implements OnInit {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.route.data.subscribe((data: { clientViewData: any; clientTemplateData: any; clientDatatables: any }) => {
|
this.route.data.subscribe((data: { clientViewData: any; clientTemplateData: any; clientDatatables: any }) => {
|
||||||
this.clientViewData = data.clientViewData;
|
this.clientViewData = data.clientViewData;
|
||||||
this.clientDatatables = data.clientDatatables;
|
this.clientDatatables = this.filterDatatablesByClientSubtype(
|
||||||
|
data.clientDatatables,
|
||||||
|
data.clientViewData?.legalForm?.id
|
||||||
|
);
|
||||||
this.clientTemplateData = data.clientTemplateData;
|
this.clientTemplateData = data.clientTemplateData;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters datatables based on the client's legal form (Person or Entity).
|
||||||
|
* Datatables without an entitySubType are kept visible for all client types.
|
||||||
|
*/
|
||||||
|
private filterDatatablesByClientSubtype(datatables: any[], legalFormId: number): any[] {
|
||||||
|
if (!datatables || !legalFormId) {
|
||||||
|
return datatables || [];
|
||||||
|
}
|
||||||
|
const subtype = legalFormId === LegalFormId.PERSON ? 'person' : 'entity';
|
||||||
|
return datatables.filter((dt: any) => !dt.entitySubType || dt.entitySubType.toLowerCase() === subtype);
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe({
|
this.clientsService.getClientProfileImage(this.clientViewData.id).subscribe({
|
||||||
next: (base64Image: any) => {
|
next: (base64Image: any) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user