From 3a3d96222e68e2d5139df24fa0b70c128949b682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Alberto=20Hern=C3=A1ndez?= <44206706+josehernandezfintecheandomx@users.noreply.github.com> Date: Thu, 5 Jan 2023 11:58:16 -0600 Subject: [PATCH] Add datatable step when exist entity datatable checks (#1633) Co-authored-by: Jose Alberto Hernandez --- .../documents-tab/documents-tab.component.ts | 2 +- src/app/clients/clients.component.html | 28 +++--- src/app/clients/clients.component.ts | 4 +- .../notes-tab/notes-tab.component.html | 46 ++------- .../notes-tab/notes-tab.component.scss | 19 ---- .../notes-tab/notes-tab.component.ts | 95 ++++--------------- .../create-loans-account.component.ts | 14 ++- .../single-row/single-row.component.html | 38 +++----- .../loan-documents-tab.component.ts | 2 +- .../notes-tab/notes-tab.component.ts | 2 +- .../savings-documents-tab.component.ts | 2 +- src/app/savings/savings-routing.module.ts | 5 +- .../entity-documents-tab.component.html | 2 +- .../entity-notes-tab.component.ts | 2 + 14 files changed, 70 insertions(+), 191 deletions(-) diff --git a/src/app/clients/clients-view/documents-tab/documents-tab.component.ts b/src/app/clients/clients-view/documents-tab/documents-tab.component.ts index 7f1872884..92ce27e82 100644 --- a/src/app/clients/clients-view/documents-tab/documents-tab.component.ts +++ b/src/app/clients/clients-view/documents-tab/documents-tab.component.ts @@ -13,7 +13,7 @@ import { ClientsService } from '../../clients.service'; export class DocumentsTabComponent implements OnInit { entityDocuments: any; entityId: string; - entityType: string = 'clients'; + entityType = 'clients'; constructor(private route: ActivatedRoute, private clientsService: ClientsService, diff --git a/src/app/clients/clients.component.html b/src/app/clients/clients.component.html index 0d25c511b..fb93c6ccd 100644 --- a/src/app/clients/clients.component.html +++ b/src/app/clients/clients.component.html @@ -22,24 +22,24 @@ -
+
- - + + - - + + - - + + @@ -47,7 +47,7 @@ - + + + - - + + @@ -75,11 +75,11 @@
Name Name {{row.entityName}} Account No. Account No. {{row.entityAccountNo}} External Id External Id Status Status
@@ -59,14 +59,14 @@ - -
Office Name Office Name {{row.parentName}} Staff Name Staff Name {{row.staffName}}
-
-
+
No client was found diff --git a/src/app/clients/clients.component.ts b/src/app/clients/clients.component.ts index 782c09a29..36dbeb25c 100644 --- a/src/app/clients/clients.component.ts +++ b/src/app/clients/clients.component.ts @@ -17,7 +17,7 @@ import { environment } from 'environments/environment'; export class ClientsComponent implements OnInit { @ViewChild('showClosedAccounts', { static: true }) showClosedAccounts: MatCheckbox; - displayedColumns = ['name', 'clientNo', 'externalId', 'status', 'office', 'staff']; + displayedColumns = ['entityName', 'entityAccountNo', 'entityExternalId', 'status', 'parentName', 'staffName']; dataSource: MatTableDataSource; existsClientsToFilter = false; @@ -55,6 +55,8 @@ export class ClientsComponent implements OnInit { private getClients(value: string) { this.searchService.getSearchResults(value, 'clients').subscribe((data: any) => { this.dataSource = new MatTableDataSource(data); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; this.existsClientsToFilter = (data.length > 0); this.notExistsClientsToFilter = !this.existsClientsToFilter; this.moreClientsToFilter = (data.length > 50); diff --git a/src/app/groups/groups-view/notes-tab/notes-tab.component.html b/src/app/groups/groups-view/notes-tab/notes-tab.component.html index 66786e00d..04cf7318f 100644 --- a/src/app/groups/groups-view/notes-tab/notes-tab.component.html +++ b/src/app/groups/groups-view/notes-tab/notes-tab.component.html @@ -1,39 +1,7 @@ -
- -

Notes

- -
- - - - - - - -
- - - - - -

{{groupNote.note}}

-

- Created by: {{groupNote.createdByUsername}}
- Date: {{groupNote.createdOn | dateFormat}} -

-
- - -
-
- -
- -
+ + diff --git a/src/app/groups/groups-view/notes-tab/notes-tab.component.scss b/src/app/groups/groups-view/notes-tab/notes-tab.component.scss index 566f436e3..e69de29bb 100644 --- a/src/app/groups/groups-view/notes-tab/notes-tab.component.scss +++ b/src/app/groups/groups-view/notes-tab/notes-tab.component.scss @@ -1,19 +0,0 @@ -.tab-container { - padding: 1%; - margin: 1%; -} - -h3 { - margin-bottom: 0px; -} - -mat-list { - padding-top: 0px; -} - -mat-list-item { - margin-block: 20px; - &:hover{ - background-color: #f5f5f5; - } -} diff --git a/src/app/groups/groups-view/notes-tab/notes-tab.component.ts b/src/app/groups/groups-view/notes-tab/notes-tab.component.ts index d747a80a5..a62f38818 100644 --- a/src/app/groups/groups-view/notes-tab/notes-tab.component.ts +++ b/src/app/groups/groups-view/notes-tab/notes-tab.component.ts @@ -1,20 +1,12 @@ /** Angular Imports */ -import { Component, OnInit, ViewChild } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; /** Custom Services */ import { AuthenticationService } from '../../../core/authentication/authentication.service'; import { GroupsService } from '../../groups.service'; /** Custom Dialogs */ -import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component'; -import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; - -/** Custom Models */ -import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base'; -import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; /** * Groups Notes Tab Component. @@ -26,113 +18,66 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; }) export class NotesTabComponent implements OnInit { - /** Group Notes */ - groupNotes: any; - /** Group Id */ - groupId: string; - /** User Name */ + /** Group ID */ + entityId: string; + /** Username */ username: string; - /** Note form */ - noteForm: FormGroup; - - /** Note Form Reference */ - @ViewChild('formRef', { static: true }) formRef: any; + /** Client Notes */ + entityNotes: any; /** * Fetches notes data from `resolve` * @param {Activated Route} route Activated Route. - * @param {FormBuilder} formBuilder FormBuilder * @param {GroupsService} groupsService Groups Service - * @param {MatDialog} dialog MatDialog * @param {AuthenticationService} authenticationService Authentication Service. */ constructor(private route: ActivatedRoute, - private formBuilder: FormBuilder, private authenticationService: AuthenticationService, - private groupsService: GroupsService, - public dialog: MatDialog) { + private groupsService: GroupsService) { const savedCredentials = this.authenticationService.getCredentials(); this.username = savedCredentials.username; - this.groupId = this.route.parent.snapshot.params['groupId']; + this.entityId = this.route.parent.snapshot.params['groupId']; this.route.data.subscribe((data: { groupNotes: any }) => { - this.groupNotes = data.groupNotes; + this.entityNotes = data.groupNotes; }); } ngOnInit() { - this.createNoteForm(); - } - - /** - * Creates the note form. - */ - createNoteForm() { - this.noteForm = this.formBuilder.group({ - 'note': ['', Validators.required] - }); } /** * Adds a new note. */ - addNote() { - this.groupsService.createGroupNote(this.groupId, this.noteForm.value).subscribe((response: any) => { - this.groupNotes.push({ + addNote(noteContent: any) { + this.groupsService.createGroupNote(this.entityId, noteContent).subscribe((response: any) => { + this.entityNotes.push({ id: response.resourceId, createdByUsername: this.username, createdOn: new Date(), - note: this.noteForm.value.note + note: noteContent.note }); - this.formRef.resetForm(); }); } /** * Edits selected note. * @param {string} noteId Note Id. - * @param {string} noteContent Note's content. - * @param {number} index Index of note. + * @param {any} noteContent Note's content. */ - editNote(noteId: string, noteContent: string, index: number) { - const formfields: FormfieldBase[] = [ - new InputBase({ - controlName: 'note', - label: 'Note', - value: noteContent, - type: 'text', - required: true, - }), - ]; - const data = { - title: 'Edit Note', - layout: { addButtonText: 'Confirm' }, - formfields: formfields - }; - const editNoteDialogRef = this.dialog.open(FormDialogComponent, { data }); - editNoteDialogRef.afterClosed().subscribe((response: any) => { - if (response.data) { - this.groupsService.editGroupNote(this.groupId, noteId, response.data.value).subscribe(() => { - this.groupNotes[index].note = response.data.value.note; - }); - } + editNote(noteId: string, noteContent: any, index: number) { + this.groupsService.editGroupNote(this.entityId, noteId, noteContent).subscribe(() => { + this.entityNotes[index].note = noteContent.note; }); } /** * Delets the given note. * @param {string} noteId Note Id. - * @param {number} index Index of Note. */ deleteNote(noteId: string, index: number) { - const deleteNoteDialogRef = this.dialog.open(DeleteDialogComponent, { - data: { deleteContext: `Note id:${noteId}` } - }); - deleteNoteDialogRef.afterClosed().subscribe((response: any) => { - if (response.delete) { - this.groupsService.deleteGroupNote(this.groupId, noteId).subscribe(() => { - this.groupNotes.splice(index, 1); - }); - } + this.groupsService.deleteGroupNote(this.entityId, noteId) + .subscribe(() => { + this.entityNotes.splice(index, 1); }); } diff --git a/src/app/loans/create-loans-account/create-loans-account.component.ts b/src/app/loans/create-loans-account/create-loans-account.component.ts index 16791a2b8..ef1905caf 100644 --- a/src/app/loans/create-loans-account/create-loans-account.component.ts +++ b/src/app/loans/create-loans-account/create-loans-account.component.ts @@ -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; + @ViewChildren('dtloan') loanDatatables: QueryList; /** 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; diff --git a/src/app/loans/loans-view/datatable-tab/single-row/single-row.component.html b/src/app/loans/loans-view/datatable-tab/single-row/single-row.component.html index 42336a183..e933bf643 100644 --- a/src/app/loans/loans-view/datatable-tab/single-row/single-row.component.html +++ b/src/app/loans/loans-view/datatable-tab/single-row/single-row.component.html @@ -1,31 +1,15 @@
- -
- -
-

{{datatableName}}

-
- -
-
- - - - - - - - - -
-
- +

{{datatableName}}

+
+ + +
diff --git a/src/app/loans/loans-view/loan-documents-tab/loan-documents-tab.component.ts b/src/app/loans/loans-view/loan-documents-tab/loan-documents-tab.component.ts index 64cd84c20..ee9b34830 100644 --- a/src/app/loans/loans-view/loan-documents-tab/loan-documents-tab.component.ts +++ b/src/app/loans/loans-view/loan-documents-tab/loan-documents-tab.component.ts @@ -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`. diff --git a/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts b/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts index 98f0647cc..56da5ddfa 100644 --- a/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts +++ b/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts @@ -34,7 +34,7 @@ export class NotesTabComponent implements OnInit { id: response.resourceId, createdByUsername: this.username, createdOn: new Date(), - note: noteContent + note: noteContent.note }); }); } diff --git a/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts b/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts index b0829ac7b..c588b070a 100644 --- a/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts +++ b/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts @@ -17,7 +17,7 @@ export class SavingsDocumentsTabComponent implements OnInit { entityDocuments: any; /** Stores the saving Account Id */ entityId: string; - entityType: string = 'savings'; + entityType = 'savings'; /** * Retrieves the savings data from `resolve`. diff --git a/src/app/savings/savings-routing.module.ts b/src/app/savings/savings-routing.module.ts index 2605e4565..706eec7ae 100644 --- a/src/app/savings/savings-routing.module.ts +++ b/src/app/savings/savings-routing.module.ts @@ -41,7 +41,6 @@ import { SavingsDocumentsTabComponent } from './savings-account-view/savings-doc import { NotesTabComponent } from './savings-account-view/notes-tab/notes-tab.component'; import { SavingNotesResolver } from './common-resolvers/saving-notes.resolver'; import { SavingDocumentsResolver } from './common-resolvers/saving-documents.resolver'; -import { DocumentsTabComponent } from 'app/clients/clients-view/documents-tab/documents-tab.component'; /** Savings Routes */ const routes: Routes = [ { @@ -106,10 +105,10 @@ const routes: Routes = [ }, { path: 'documents', - component: DocumentsTabComponent, + component: SavingsDocumentsTabComponent, data: { title: extract('Savings Account Documents'), breadcrumb: 'Documents', routeParamBreadcrumb: false }, resolve: { - savingAccountDocuments: SavingDocumentsResolver + savingsDocuments: SavingDocumentsResolver } }, { diff --git a/src/app/shared/tabs/entity-documents-tab/entity-documents-tab.component.html b/src/app/shared/tabs/entity-documents-tab/entity-documents-tab.component.html index f9eee5951..16008724c 100644 --- a/src/app/shared/tabs/entity-documents-tab/entity-documents-tab.component.html +++ b/src/app/shared/tabs/entity-documents-tab/entity-documents-tab.component.html @@ -45,6 +45,6 @@ - +
diff --git a/src/app/shared/tabs/entity-notes-tab/entity-notes-tab.component.ts b/src/app/shared/tabs/entity-notes-tab/entity-notes-tab.component.ts index ceab73be7..8e226faef 100644 --- a/src/app/shared/tabs/entity-notes-tab/entity-notes-tab.component.ts +++ b/src/app/shared/tabs/entity-notes-tab/entity-notes-tab.component.ts @@ -2,6 +2,7 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { ClientsService } from 'app/clients/clients.service'; +import { GroupsService } from 'app/groups/groups.service'; import { LoansService } from 'app/loans/loans.service'; import { SavingsService } from 'app/savings/savings.service'; import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; @@ -29,6 +30,7 @@ export class EntityNotesTabComponent implements OnInit { private savingsService: SavingsService, private loansService: LoansService, private clientsService: ClientsService, + private groupsService: GroupsService, private dialog: MatDialog) { } ngOnInit() {