Add datatable step when exist entity datatable checks (#1633)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-01-05 11:58:16 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent cafe8fa73d
commit 3a3d96222e
14 changed files with 70 additions and 191 deletions
@@ -11,7 +11,6 @@ import { ClientsService } from 'app/clients/clients.service';
import { LoansAccountDetailsStepComponent } from '../loans-account-stepper/loans-account-details-step/loans-account-details-step.component';
import { LoansAccountTermsStepComponent } from '../loans-account-stepper/loans-account-terms-step/loans-account-terms-step.component';
import { LoansAccountChargesStepComponent } from '../loans-account-stepper/loans-account-charges-step/loans-account-charges-step.component';
import { Dates } from 'app/core/utils/dates';
import { LoansAccountDatatableStepComponent } from '../loans-account-stepper/loans-account-datatable-step/loans-account-datatable-step.component';
/**
@@ -29,7 +28,7 @@ export class CreateLoansAccountComponent implements OnInit {
@ViewChild(LoansAccountTermsStepComponent, { static: true }) loansAccountTermsStep: LoansAccountTermsStepComponent;
@ViewChild(LoansAccountChargesStepComponent, { static: true }) loansAccountChargesStep: LoansAccountChargesStepComponent;
/** Get handle on dtloan tags in the template */
@ViewChildren('dtloan') clientDatatables: QueryList<LoansAccountDatatableStepComponent>;
@ViewChildren('dtloan') loanDatatables: QueryList<LoansAccountDatatableStepComponent>;
/** Loans Account Template */
loansAccountTemplate: any;
@@ -47,14 +46,12 @@ export class CreateLoansAccountComponent implements OnInit {
* Sets loans account create form.
* @param {route} ActivatedRoute Activated Route.
* @param {router} Router Router.
* @param {Dates} dateUtils Date Utils
* @param {loansService} LoansService Loans Service
* @param {SettingsService} settingsService Settings Service
* @param {ClientsService} clientService Client Service
*/
constructor(private route: ActivatedRoute,
private router: Router,
private dateUtils: Dates,
private loansService: LoansService,
private settingsService: SettingsService,
private clientService: ClientsService
@@ -83,13 +80,14 @@ export class CreateLoansAccountComponent implements OnInit {
this.loansService.getLoansAccountTemplateResource(entityId, isGroup, productId).subscribe((response: any) => {
this.multiDisburseLoan = response.multiDisburseLoan;
});
this.setDatatables();
}
setDatatables(): void {
this.datatables = [];
if (this.loansAccountTemplate.datatables) {
this.loansAccountTemplate.datatables.forEach((datatable: any) => {
if (this.loansAccountProductTemplate.datatables) {
this.loansAccountProductTemplate.datatables.forEach((datatable: any) => {
this.datatables.push(datatable);
});
}
@@ -138,9 +136,9 @@ export class CreateLoansAccountComponent implements OnInit {
const payload = this.loansService.buildLoanRequestPayload(this.loansAccount, this.loansAccountTemplate,
this.loansAccountProductTemplate.calendarOptions, locale, dateFormat);
if (this.loansAccountTemplate.datatables && this.loansAccountTemplate.datatables.length > 0) {
if (this.loansAccountProductTemplate.datatables && this.loansAccountProductTemplate.datatables.length > 0) {
const datatables: any[] = [];
this.loansAccountTemplate.forEach((loanDatatable: LoansAccountDatatableStepComponent) => {
this.loanDatatables.forEach((loanDatatable: LoansAccountDatatableStepComponent) => {
datatables.push(loanDatatable.payload);
});
payload['datatables'] = datatables;
@@ -1,31 +1,15 @@
<div class="tab-container mat-typography">
<div>
<div fxLayout="column" fxFlex="50%" class="table-name">
<h3>{{datatableName}}</h3>
</div>
<div fxLayout="column" fxFlex="50%">
<div fxLayout="row" fxLayoutAlign="flex-end">
<span>
<button mat-raised-button color="primary" (click)="add()" *ngIf="!dataObject.data[0]">
<fa-icon icon="plus" class="m-r-10"></fa-icon>Add
</button>
</span>
<span>
<button mat-raised-button color="primary" (click)="edit()" *ngIf="dataObject.data[0]">
<fa-icon icon="edit" class="m-r-10"></fa-icon>Edit
</button>
</span>
<span class="delete-button">
<button mat-raised-button color="warn" (click)="delete()" *ngIf="dataObject.data[0]">
<fa-icon icon="trash" class="m-r-10"></fa-icon>Delete
</button>
</span>
</div>
</div>
<h3>{{datatableName}}</h3>
<div fxLayout="row" fxLayoutAlign="flex-end">
<button mat-raised-button color="primary" (click)="add()" *ngIf="!dataObject.data[0]">
<fa-icon icon="plus" class="m-r-10"></fa-icon>Add
</button>
<button mat-raised-button color="primary" (click)="edit()" *ngIf="dataObject.data[0]">
<fa-icon icon="edit" class="m-r-10"></fa-icon>Edit
</button>
<button class="delete-button" mat-raised-button color="warn" (click)="delete()" *ngIf="dataObject.data[0]">
<fa-icon icon="trash" class="m-r-10"></fa-icon>Delete All
</button>
</div>
<mat-divider></mat-divider>
@@ -21,7 +21,7 @@ export class LoanDocumentsTabComponent implements OnInit {
entityDocuments: any;
/** Loan account Id */
entityId: string;
entityType: string = 'loans';
entityType = 'loans';
/**
* Retrieves the loans data from `resolve`.