From f557088ecd512d0427c423172f620aa0b19e745f Mon Sep 17 00:00:00 2001 From: pc_11 <76156941+PC-11-00@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:49:53 +0530 Subject: [PATCH] feat: added data table for transactions of saving account (#1844) * feat: added data table for transactions of saving account Now we can add the data table for transactions entity type of saving account and also we can edit,delete and create the datatable. Fixes: #1726 * made changes in the comments --- .../transaction-datatable.resolver.ts | 28 +++ .../transaction-datatables.resolver.ts | 27 ++ .../datatable-transaction-tab.component.html | 9 + .../datatable-transaction-tab.component.scss | 0 ...atatable-transaction-tab.component.spec.ts | 25 ++ .../datatable-transaction-tab.component.ts | 25 ++ .../view-transaction.component.html | 238 ++++++++---------- .../view-transaction.component.scss | 60 ++++- .../view-transaction.component.ts | 16 +- src/app/savings/savings-routing.module.ts | 25 +- src/app/savings/savings.module.ts | 4 +- src/app/savings/savings.service.ts | 18 ++ .../manage-data-tables/app-table-data.ts | 35 +-- 13 files changed, 343 insertions(+), 167 deletions(-) create mode 100644 src/app/savings/common-resolvers/transaction-datatable.resolver.ts create mode 100644 src/app/savings/common-resolvers/transaction-datatables.resolver.ts create mode 100644 src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.html create mode 100644 src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.scss create mode 100644 src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.spec.ts create mode 100644 src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.ts diff --git a/src/app/savings/common-resolvers/transaction-datatable.resolver.ts b/src/app/savings/common-resolvers/transaction-datatable.resolver.ts new file mode 100644 index 000000000..a4b30a777 --- /dev/null +++ b/src/app/savings/common-resolvers/transaction-datatable.resolver.ts @@ -0,0 +1,28 @@ +// Angular Imports +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +// rxjs Imports +import { Observable, of } from 'rxjs'; + +// Custom Service +import { SavingsService } from '../savings.service'; + +@Injectable() +export class TransactionDatatableResolver implements Resolve { + /** + * + * @param {SavingsService} savingsService + */ + constructor(private savingsService: SavingsService) { } + /** + * Returns the Transactions Account's Datatable data. + * @returns {Observable} + */ + + resolve(route: ActivatedRouteSnapshot): Observable { + const accountId = route.parent.parent.paramMap.get('id'); + const datatableName = route.paramMap.get('datatableName'); + return this.savingsService.getSavingsTransactionDatatable(accountId, datatableName); + } +} \ No newline at end of file diff --git a/src/app/savings/common-resolvers/transaction-datatables.resolver.ts b/src/app/savings/common-resolvers/transaction-datatables.resolver.ts new file mode 100644 index 000000000..6d818696b --- /dev/null +++ b/src/app/savings/common-resolvers/transaction-datatables.resolver.ts @@ -0,0 +1,27 @@ +// Angular Imports +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +// rxjs Imports +import { Observable, of } from 'rxjs'; + +// Custom Service +import { SavingsService } from '../savings.service'; + +@Injectable() +export class TransactionDatatablesResolver implements Resolve { + + /** + * + * @param savingsService Savings Service + */ + constructor(private savingsService: SavingsService) { } + /** + * + * @param route + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + return this.savingsService.getSavingsTransactionDatatables(); + } +} \ No newline at end of file diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.html b/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.html new file mode 100644 index 000000000..fb1897f12 --- /dev/null +++ b/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.html @@ -0,0 +1,9 @@ +
+ + +
\ No newline at end of file diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.scss b/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.spec.ts b/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.spec.ts new file mode 100644 index 000000000..2b5510c21 --- /dev/null +++ b/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DatatableTransactionTabComponent } from './datatable-transaction-tab.component'; + +describe('DatatableTransactionTabComponent', () => { + let component: DatatableTransactionTabComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ DatatableTransactionTabComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(DatatableTransactionTabComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.ts b/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.ts new file mode 100644 index 000000000..c2043227b --- /dev/null +++ b/src/app/savings/savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +@Component({ + selector: 'mifosx-datatable-transaction-tab', + templateUrl: './datatable-transaction-tab.component.html', + styleUrls: ['./datatable-transaction-tab.component.scss'] +}) + +export class DatatableTransactionTabComponent { + /** Transaction Id */ + entityId: string; + /** Savings Datatable */ + entityDatatable: any; + /** Multi Row Datatable Flag */ + multiRowDatatableFlag: boolean; + constructor(private route: ActivatedRoute) { + this.entityId = this.route.parent.parent.snapshot.paramMap.get('id'); + this.route.data.subscribe((data: { transactionDatatable: any }) => { + this.entityDatatable = data.transactionDatatable; + this.multiRowDatatableFlag = this.entityDatatable.columnHeaders[0].columnName === 'id' ? true : false; + }); + } + +} \ No newline at end of file diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.html b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.html index a0e02afd2..e578a8d57 100644 --- a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.html +++ b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.html @@ -1,140 +1,110 @@ -
- - - - - - - -
- -
- - - - - -
- -
- Transaction Id + diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.scss b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.scss index 56668f14f..aa80d96ba 100644 --- a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.scss +++ b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.scss @@ -1,10 +1,54 @@ -.container { - max-width: 37rem; - - .content { - div { - margin: 1rem 0; - word-wrap: break-word; +.savings-account-card { + margin: 0 auto; + max-width: 80rem; + width: 90%; + padding: 0; + .header { + padding: 1%; + background-color:rgb(16, 116, 185); + .header-title-group { + .account-card-title { + color: white; + width: 90%; + p { + color: white; + } + } + } + .profile-image-container { + margin: 1%; + .profile-image { + object-fit: cover; + border-radius: 20px; + } + } + .account-actions { + align-self: flex-end; + margin: 0 1%; + i { + margin-bottom: 2px; + margin-right: 4px; + } } } -} + .navigation-tabs { + background-color: #f2f2f2; + overflow: auto; + } + .content { + .savings-account-tables { + padding: 1%; + margin: 1%; + .table-headers { + margin: 0; + padding: 6px; + } + td { + padding: 3px; + } + } + } + i, img:hover { + cursor: pointer; + } +} \ No newline at end of file diff --git a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.ts b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.ts index a1d3da200..5e15e46cc 100644 --- a/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.ts +++ b/src/app/savings/savings-account-view/transactions/view-transaction/view-transaction.component.ts @@ -26,7 +26,12 @@ export class ViewTransactionComponent { /** Transaction data. */ transactionData: any; - accountId: string; + accountId: any; + /** Transaction Data Tables */ + entityDatatable: any; + /** Multi Row Datatable Flag */ + multiRowDatatableFlag: boolean; + isActive:false; /** * Retrieves the Transaction data from `resolve`. @@ -43,10 +48,11 @@ export class ViewTransactionComponent { private router: Router, public dialog: MatDialog, private settingsService: SettingsService) { - this.route.data.subscribe((data: { savingsAccountTransaction: any }) => { - this.accountId = this.route.snapshot.params['savingAccountId']; - this.transactionData = data.savingsAccountTransaction; - }); + this.route.data.subscribe((data: { savingsAccountTransaction: any,transactionDatatables:any}) => { + this.accountId = this.route.snapshot.params['savingAccountId']; + this.transactionData = data.savingsAccountTransaction; + this.entityDatatable = data.transactionDatatables; + }); } /** diff --git a/src/app/savings/savings-routing.module.ts b/src/app/savings/savings-routing.module.ts index b450c58d2..457fefb1e 100644 --- a/src/app/savings/savings-routing.module.ts +++ b/src/app/savings/savings-routing.module.ts @@ -8,6 +8,7 @@ import { extract } from '../core/i18n/i18n.service'; /** Custom Components */ import { SavingsAccountViewComponent } from './savings-account-view/savings-account-view.component'; import { TransactionsTabComponent } from './savings-account-view/transactions-tab/transactions-tab.component'; +import { DatatableTransactionTabComponent } from './savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component'; import { SavingAccountActionsComponent } from './saving-account-actions/saving-account-actions.component'; import { ChargesTabComponent } from './savings-account-view/charges-tab/charges-tab.component'; import { StandingInstructionsTabComponent } from './savings-account-view/standing-instructions-tab/standing-instructions-tab.component'; @@ -26,6 +27,8 @@ import { GsimAccountComponent } from './gsim-account/gsim-account.component'; import { SavingsAccountViewResolver } from './common-resolvers/savings-account-view.resolver'; import { SavingsDatatableResolver } from './common-resolvers/savings-datatable.resolver'; import { SavingsDatatablesResolver } from './common-resolvers/savings-datatables.resolver'; +import { TransactionDatatableResolver } from './common-resolvers/transaction-datatable.resolver'; +import { TransactionDatatablesResolver } from './common-resolvers/transaction-datatables.resolver'; import { SavingsAccountTemplateResolver } from './common-resolvers/savings-account-template.resolver'; import { SavingsAccountAndTemplateResolver } from './common-resolvers/savings-account-and-template.resolver'; import { SavingsAccountTransactionResolver } from './common-resolvers/savings-account-transaction.resolver'; @@ -141,8 +144,24 @@ const routes: Routes = [ path: '', component: ViewTransactionComponent, resolve: { - savingsAccountTransaction: SavingsAccountTransactionResolver - } + savingsAccountTransaction: SavingsAccountTransactionResolver, + transactionDatatables: TransactionDatatablesResolver + }, + children: [ + { + path: 'datatables', + children: [{ + path: ':datatableName', + component: DatatableTransactionTabComponent, + data: { title: extract('View Data table'), routeParamBreadcrumb: 'datatableName' }, + resolve: { + transactionDatatable: TransactionDatatableResolver + } + } + ] + + } + ] }, { path: 'edit', @@ -232,6 +251,8 @@ const routes: Routes = [ providers: [SavingsAccountViewResolver, SavingsDatatablesResolver, SavingsDatatableResolver, + TransactionDatatableResolver, + TransactionDatatablesResolver, SavingsAccountTemplateResolver, SavingsAccountAndTemplateResolver, SavingsAccountTransactionResolver, diff --git a/src/app/savings/savings.module.ts b/src/app/savings/savings.module.ts index c29808803..57bb31459 100644 --- a/src/app/savings/savings.module.ts +++ b/src/app/savings/savings.module.ts @@ -49,6 +49,7 @@ import { ManageSavingsAccountComponent } from './saving-account-actions/manage-s import { ReleaseAmountDialogComponent } from './savings-account-view/custom-dialogs/release-amount-dialog/release-amount-dialog.component'; import { SavingsDocumentsTabComponent } from './savings-account-view/savings-documents-tab/savings-documents-tab.component'; import { NotesTabComponent } from './savings-account-view/notes-tab/notes-tab.component'; +import { DatatableTransactionTabComponent } from './savings-account-view/transactions/view-transaction/datatable-transaction-tab/datatable-transaction-tab.component'; /** @@ -104,7 +105,8 @@ import { NotesTabComponent } from './savings-account-view/notes-tab/notes-tab.co ManageSavingsAccountComponent, ReleaseAmountDialogComponent, SavingsDocumentsTabComponent, - NotesTabComponent + NotesTabComponent, + DatatableTransactionTabComponent ], providers: [ ] }) diff --git a/src/app/savings/savings.service.ts b/src/app/savings/savings.service.ts index 3d1cda9d8..eec8bc4fe 100644 --- a/src/app/savings/savings.service.ts +++ b/src/app/savings/savings.service.ts @@ -107,6 +107,24 @@ export class SavingsService { return this.http.get(`/datatables/${datatableName}/${accountId}`, { params: httpParams }); } + /** + * @returns {Observable} + */ + getSavingsTransactionDatatables(): Observable { + const httpParams = new HttpParams().set('apptable', 'm_savings_account_transaction'); + return this.http.get(`/datatables`, { params: httpParams }); + } + + /** + * @param accountId account Id of savings account to get datatable for. + * @param datatableName Data table name. + * @returns {Observable} + */ + getSavingsTransactionDatatable(transactionId: string, datatableName: string): Observable { + const httpParams = new HttpParams().set('genericResultSet', 'true'); + return this.http.get(`/datatables/${datatableName}/${transactionId}`, { params: httpParams }); + } + /** * @param accountId account Id of savings account to get add datatable entry for. * @param datatableName Data Table name. diff --git a/src/app/system/manage-data-tables/app-table-data.ts b/src/app/system/manage-data-tables/app-table-data.ts index 88f051502..dd20012e5 100644 --- a/src/app/system/manage-data-tables/app-table-data.ts +++ b/src/app/system/manage-data-tables/app-table-data.ts @@ -1,22 +1,23 @@ export const appTableData: { displayValue: string, value: string }[] = [ - { displayValue: 'Client', value: 'm_client' }, - { displayValue: 'Group', value: 'm_group' }, - { displayValue: 'Center', value: 'm_center' }, - { displayValue: 'Office', value: 'm_office' }, - { displayValue: 'Loan Account', value: 'm_loan' }, - { displayValue: 'Saving Account', value: 'm_savings_account' }, - { displayValue: 'Loan Product', value: 'm_product_loan' }, - { displayValue: 'Savings Product', value: 'm_savings_product' }, - { displayValue: 'Share Product', value: 'm_share_product' } - ]; + { displayValue: 'Client', value: 'm_client' }, + { displayValue: 'Group', value: 'm_group' }, + { displayValue: 'Center', value: 'm_center' }, + { displayValue: 'Office', value: 'm_office' }, + { displayValue: 'Loan Account', value: 'm_loan' }, + { displayValue: 'Saving Account', value: 'm_savings_account' }, + { displayValue: 'Loan Product', value: 'm_product_loan' }, + { displayValue: 'Saving Account Transaction', value: 'm_savings_account_transaction' }, + { displayValue: 'Savings Product', value: 'm_savings_product' }, + { displayValue: 'Share Product', value: 'm_share_product' } +]; export const entitySubTypeData: { displayValue: string, value: string }[] = [ - { displayValue: 'Person', value: 'Person' }, - { displayValue: 'Entity', value: 'Entity' }, - ]; + { displayValue: 'Person', value: 'Person' }, + { displayValue: 'Entity', value: 'Entity' }, +]; export const savingsSubTypeData: { displayValue: string, value: string }[] = [ - { displayValue: 'Savings Product', value: 'Savings Product' }, - { displayValue: 'Fixed Deposit', value: 'Fixed Deposit' }, - { displayValue: 'Recurring Deposit', value: 'Recurring Deposit' }, - ]; + { displayValue: 'Savings Product', value: 'Savings Product' }, + { displayValue: 'Fixed Deposit', value: 'Fixed Deposit' }, + { displayValue: 'Recurring Deposit', value: 'Recurring Deposit' }, +];