diff --git a/src/app/savings/common-resolvers/savings-datatable.resolver.ts b/src/app/savings/common-resolvers/savings-datatable.resolver.ts new file mode 100644 index 000000000..f0b2ab6aa --- /dev/null +++ b/src/app/savings/common-resolvers/savings-datatable.resolver.ts @@ -0,0 +1,32 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { SavingsService } from '../savings.service'; + +/** + * Savings Datatable data resolver. + */ +@Injectable() +export class SavingsDatatableResolver implements Resolve { + + /** + * @param {SavingsService} SavingsService Savings service. + */ + constructor(private savingsService: SavingsService) { } + + /** + * Returns the Savings Account's Datatable data. + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const accountId = route.parent.parent.paramMap.get('savingAccountId'); + const datatableName = route.paramMap.get('datatableName'); + return this.savingsService.getSavingsDatatable(accountId, datatableName); + } + +} diff --git a/src/app/savings/common-resolvers/savings-datatables.resolver.ts b/src/app/savings/common-resolvers/savings-datatables.resolver.ts new file mode 100644 index 000000000..f3d4b7d3f --- /dev/null +++ b/src/app/savings/common-resolvers/savings-datatables.resolver.ts @@ -0,0 +1,30 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { SavingsService } from '../savings.service'; + +/** + * Saving Accounts Datatables data resolver. + */ +@Injectable() +export class SavingsDatatablesResolver implements Resolve { + + /** + * @param {SavingsService} SavingsService Savings service. + */ + constructor(private savingsService: SavingsService) { } + + /** + * Returns the Saving Account's Datatables data. + * @returns {Observable} + */ + resolve(): Observable { + return this.savingsService.getSavingsDatatables(); + } + +} diff --git a/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.html b/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.html new file mode 100644 index 000000000..cd642dc5c --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.html @@ -0,0 +1,4 @@ +
+ + +
diff --git a/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.scss b/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.spec.ts b/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.spec.ts new file mode 100644 index 000000000..0f1dfa604 --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DatatableTabsComponent } from './datatable-tabs.component'; + +describe('DatatableTabsComponent', () => { + let component: DatatableTabsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DatatableTabsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DatatableTabsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.ts b/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.ts new file mode 100644 index 000000000..460799d42 --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/datatable-tabs.component.ts @@ -0,0 +1,31 @@ +/** Angular Imports */ +import { Component } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +/** + * Savings Datatable Tabs Component + */ +@Component({ + selector: 'mifosx-datatable-tabs', + templateUrl: './datatable-tabs.component.html', + styleUrls: ['./datatable-tabs.component.scss'] +}) +export class DatatableTabsComponent { + + /** Savings Datatable */ + savingsDatatable: any; + /** Multi Row Datatable Flag */ + multiRowDatatableFlag: boolean; + + /** + * Fetches Savings and datatables data from `resolve` + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: { savingsDatatable: any }) => { + this.savingsDatatable = data.savingsDatatable; + this.multiRowDatatableFlag = this.savingsDatatable.columnHeaders[0].columnName === 'id' ? true : false; + }); + } + +} diff --git a/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.html b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.html new file mode 100644 index 000000000..c339f8643 --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.html @@ -0,0 +1,33 @@ +
+ +
+
+

{{datatableName}}

+
+
+ + + + + + +
+
+ + + + + + + + + + + +
{{datatableColumn}} {{data.row[i]}}
+ +
diff --git a/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.scss b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.scss new file mode 100644 index 000000000..6fa6a5f4e --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.scss @@ -0,0 +1,10 @@ +.tab-container { + padding: 1%; + margin: 1%; + .action-button{ + margin-left: auto; + } + table { + width: 100%; + } +} diff --git a/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.spec.ts b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.spec.ts new file mode 100644 index 000000000..dd46589d8 --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MultiRowComponent } from './multi-row.component'; + +describe('MultiRowComponent', () => { + let component: MultiRowComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ MultiRowComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MultiRowComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.ts b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.ts new file mode 100644 index 000000000..72f64e317 --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/multi-row/multi-row.component.ts @@ -0,0 +1,184 @@ +/** Angular Imports */ +import { Component, OnChanges, OnInit, Input, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { MatTable } from '@angular/material/table'; +import { MatDialog } from '@angular/material'; +import { DatePipe } from '@angular/common'; + +/** Custom Dialogs */ +import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; +import { DeleteDialogComponent } from '../../../../shared/delete-dialog/delete-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'; +import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base'; +import { CheckboxBase } from 'app/shared/form-dialog/formfield/model/checkbox-base'; +import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base'; + +/** Custom Services */ +import { SavingsService } from '../../../savings.service'; + +/** + * Savings Account Multi Row Data Tables + */ +@Component({ + selector: 'mifosx-multi-row', + templateUrl: './multi-row.component.html', + styleUrls: ['./multi-row.component.scss'] +}) +export class MultiRowComponent implements OnInit, OnChanges { + + /** Data Object */ + @Input() dataObject: any; + + /** Data Table Name */ + datatableName: string; + /** Data Table Columns */ + datatableColumns: string[] = []; + /** Data Table Data */ + datatableData: any; + /** Savings Id */ + savingAccountId: string; + /** Toggle button visibility */ + showDeleteBotton: boolean; + + /** Data Table Reference */ + @ViewChild('dataTable') dataTableRef: MatTable; + + /** + * Fetches savings account Id from parent route params. + * @param {ActivatedRoute} route Activated Route. + * @param {DatePipe} datePipe Date Pipe. + * @param {SavingsService} savingsService Savingss Service. + * @param {MatDialog} dialog Mat Dialog. + */ + constructor(private route: ActivatedRoute, + private datePipe: DatePipe, + private savingsService: SavingsService, + private dialog: MatDialog) { + this.savingAccountId = this.route.parent.parent.snapshot.paramMap.get('savingAccountId'); + } + + /** + * Updates related variables on changes to dataObject. + */ + ngOnChanges() { + this.datatableColumns = this.dataObject.columnHeaders.map((columnHeader: any) => { + return columnHeader.columnName; + }); + this.datatableData = this.dataObject.data; + this.showDeleteBotton = this.datatableData[0] ? true : false; + } + + /** + * Fetches data table name from route params. + * subscription is required due to asynchronicity. + */ + ngOnInit() { + this.route.params.subscribe((routeParams: any) => { + this.datatableName = routeParams.datatableName; + }); + } + + /** + * Adds a new row to the given multi row data table. + */ + add() { + let dataTableEntryObject: any = { locale: 'en' }; + const dateTransformColumns: string[] = []; + const columns = this.dataObject.columnHeaders.filter((column: any) => { + return ((column.columnName !== 'id') && (column.columnName !== 'savings_account_id')); + }); + const formfields: FormfieldBase[] = columns.map((column: any) => { + switch (column.columnDisplayType) { + case 'INTEGER': + case 'STRING': + case 'DECIMAL': + case 'TEXT': return new InputBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + type: (column.columnDisplayType === 'INTEGER' || column.columnDisplayType === 'DECIMAL') ? 'number' : 'text', + required: (column.isColumnNullable) ? false : true + }); + case 'BOOLEAN': return new CheckboxBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + type: 'checkbox', + required: (column.isColumnNullable) ? false : true + }); + case 'CODELOOKUP': return new SelectBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + options: { label: 'value', value: 'id', data: column.columnValues }, + required: (column.isColumnNullable) ? false : true + }); + case 'DATE': { + dateTransformColumns.push(column.columnName); + dataTableEntryObject.dateFormat = 'yyyy-MM-dd'; + return new DatepickerBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + type: 'date', + required: (column.isColumnNullable) ? false : true + }); + } + case 'DATETIME': { + dateTransformColumns.push(column.columnName); + dataTableEntryObject.dateFormat = 'yyyy-MM-dd HH:mm'; + return new DatepickerBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + type: 'datetime-local', + required: (column.isColumnNullable) ? false : true + }); + } + } + }); + const data = { + title: 'Add ' + this.datatableName, + formfields: formfields + }; + const addDialogRef = this.dialog.open(FormDialogComponent, { data }); + addDialogRef.afterClosed().subscribe((response: any) => { + if (response.data) { + dateTransformColumns.forEach((column) => { + response.data.value[column] = this.datePipe.transform(response.data.value[column], dataTableEntryObject.dateFormat); + }); + dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject }; + this.savingsService.addSavingsDatatableEntry(this.savingAccountId, this.datatableName, dataTableEntryObject).subscribe(() => { + this.savingsService.getSavingsDatatable(this.savingAccountId, this.datatableName).subscribe((dataObject: any) => { + this.datatableData = dataObject.data; + this.dataTableRef.renderRows(); + }); + }); + } + }); + } + + /** + * Deletes all rows of the given multi row data table. + */ + delete() { + const deleteDataTableDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `the contents of ${this.datatableName}` } + }); + deleteDataTableDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.savingsService.deleteDatatableContent(this.savingAccountId, this.datatableName).subscribe(() => { + this.savingsService.getSavingsDatatable(this.savingAccountId, this.datatableName).subscribe((dataObject: any) => { + this.datatableData = dataObject.data; + this.showDeleteBotton = false; + this.dataTableRef.renderRows(); + }); + }); + } + }); + } + +} diff --git a/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.html b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.html new file mode 100644 index 000000000..c2536b86a --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.html @@ -0,0 +1,29 @@ +
+ +

{{datatableName}}

+ +
+ + + + + + + + + +
+ + + + {{columnHeader.columnName}} : {{dataObject.data[0].row[i]}} + + + +
diff --git a/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.scss b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.scss new file mode 100644 index 000000000..63d2cfc9e --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.scss @@ -0,0 +1,7 @@ +.tab-container { + padding: 1%; + margin: 1%; + .delete-button { + margin-left: 1%; + } +} diff --git a/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.spec.ts b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.spec.ts new file mode 100644 index 000000000..8aece650c --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SingleRowComponent } from './single-row.component'; + +describe('SingleRowComponent', () => { + let component: SingleRowComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ SingleRowComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SingleRowComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.ts b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.ts new file mode 100644 index 000000000..890250453 --- /dev/null +++ b/src/app/savings/savings-account-view/datatable-tabs/single-row/single-row.component.ts @@ -0,0 +1,207 @@ +/** Angular Imports */ +import { Component, Input, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { MatDialog } from '@angular/material'; +import { DatePipe } from '@angular/common'; + +/** Custom Components */ +import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; +import { DeleteDialogComponent } from '../../../../shared/delete-dialog/delete-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'; +import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base'; +import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base'; +import { CheckboxBase } from 'app/shared/form-dialog/formfield/model/checkbox-base'; + +/** Custom Services */ +import { SavingsService } from '../../../savings.service'; + + +/** + * Savings Account Single Row Data Tables + */ +@Component({ + selector: 'mifosx-single-row', + templateUrl: './single-row.component.html', + styleUrls: ['./single-row.component.scss'] +}) +export class SingleRowComponent implements OnInit { + + /** Data Object */ + @Input() dataObject: any; + + /** Data Table Name */ + datatableName: string; + /** Savings Id */ + savingAccountId: string; + + /** + * Fetches savings account Id from parent route params. + * @param {ActivatedRoute} route Activated Route. + * @param {DatePipe} datePipe Date Pipe. + * @param {SavingsService} savingsService Savingss Service. + * @param {MatDialog} dialog Mat Dialog. + */ + constructor(private route: ActivatedRoute, + private datePipe: DatePipe, + private dialog: MatDialog, + private savingsService: SavingsService) { + this.savingAccountId = this.route.parent.parent.snapshot.paramMap.get('savingAccountId'); + } + + /** + * Fetches data table name from route params. + * subscription is required due to asynchronicity. + */ + ngOnInit() { + this.route.params.subscribe((routeParams: any) => { + this.datatableName = routeParams.datatableName; + }); + } + + /** + * Creates a new instance of the given single row data table. + */ + add() { + let dataTableEntryObject: any = { locale: 'en' }; + const dateTransformColumns: string[] = []; + const columns = this.dataObject.columnHeaders.filter((column: any) => { + return ((column.columnName !== 'id') && (column.columnName !== 'savings_account_id')); + }); + const formfields: FormfieldBase[] = this.getFormfields(columns, dateTransformColumns, dataTableEntryObject); + const data = { + title: 'Add ' + this.datatableName, + formfields: formfields + }; + const addDialogRef = this.dialog.open(FormDialogComponent, { data }); + addDialogRef.afterClosed().subscribe((response: any) => { + if (response.data) { + dateTransformColumns.forEach((column) => { + response.data.value[column] = this.datePipe.transform(response.data.value[column], dataTableEntryObject.dateFormat); + }); + dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject }; + this.savingsService.addSavingsDatatableEntry(this.savingAccountId, this.datatableName, dataTableEntryObject).subscribe(() => { + this.savingsService.getSavingsDatatable(this.savingAccountId, this.datatableName).subscribe((dataObject: any) => { + this.dataObject = dataObject; + }); + }); + } + }); + } + + /** + * Edits the current instance of single row data table. + */ + edit() { + let dataTableEntryObject: any = { locale: 'en' }; + const dateTransformColumns: string[] = []; + const columns = this.dataObject.columnHeaders.filter((column: any) => { + return ((column.columnName !== 'id') && (column.columnName !== 'savings_account_id')); + }); + let formfields: FormfieldBase[] = this.getFormfields(columns, dateTransformColumns, dataTableEntryObject); + formfields = formfields.map((formfield: FormfieldBase, index: number) => { + formfield.value = (this.dataObject.data[0].row[index + 1]) ? this.dataObject.data[0].row[index + 1] : ''; + return formfield; + }); + const data = { + title: 'Edit ' + this.datatableName, + layout: { addButtonText: 'Confirm' }, + formfields: formfields + }; + const editDialogRef = this.dialog.open(FormDialogComponent, { data }); + editDialogRef.afterClosed().subscribe((response: any) => { + if (response.data) { + dateTransformColumns.forEach((column) => { + response.data.value[column] = this.datePipe.transform(response.data.value[column], dataTableEntryObject.dateFormat); + }); + dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject }; + this.savingsService.editSavingsDatatableEntry(this.savingAccountId, this.datatableName, dataTableEntryObject).subscribe(() => { + this.savingsService.getSavingsDatatable(this.savingAccountId, this.datatableName).subscribe((dataObject: any) => { + this.dataObject = dataObject; + }); + }); + } + }); + } + + /** + * Deletes the current instance of single row data table. + */ + delete() { + const deleteDataTableDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `the contents of ${this.datatableName}` } + }); + deleteDataTableDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.savingsService.deleteDatatableContent(this.savingAccountId, this.datatableName) + .subscribe(() => { + this.savingsService.getSavingsDatatable(this.savingAccountId, this.datatableName).subscribe((dataObject: any) => { + this.dataObject = dataObject; + }); + }); + } + }); + } + + /** + * Maps API response to data table form fields. + * @param {any} columns Data Table Columns. + * @param {string[]} dateTransformColumns Columns transformed with date pipe. + * @param {any} dataTableEntryObject Additional data table details. + */ + getFormfields(columns: any, dateTransformColumns: string[], dataTableEntryObject: any) { + return columns.map((column: any) => { + switch (column.columnDisplayType) { + case 'INTEGER': + case 'STRING': + case 'DECIMAL': + case 'TEXT': return new InputBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + type: (column.columnDisplayType === 'INTEGER' || column.columnDisplayType === 'DECIMAL') ? 'number' : 'text', + required: (column.isColumnNullable) ? false : true + }); + case 'BOOLEAN': return new CheckboxBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + type: 'checkbox', + required: (column.isColumnNullable) ? false : true + }); + case 'CODELOOKUP': return new SelectBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + options: { label: 'value', value: 'id', data: column.columnValues }, + required: (column.isColumnNullable) ? false : true + }); + case 'DATE': { + dateTransformColumns.push(column.columnName); + dataTableEntryObject.dateFormat = 'yyyy-MM-dd'; + return new DatepickerBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + type: 'date', + required: (column.isColumnNullable) ? false : true + }); + } + case 'DATETIME': { + dateTransformColumns.push(column.columnName); + dataTableEntryObject.dateFormat = 'yyyy-MM-dd HH:mm'; + return new DatepickerBase({ + controlName: column.columnName, + label: column.columnName, + value: '', + type: 'datetime-local', + required: (column.isColumnNullable) ? false : true + }); + } + } + }); + } + +} diff --git a/src/app/savings/savings-account-view/savings-account-view.component.html b/src/app/savings/savings-account-view/savings-account-view.component.html index 59ba0b0fd..bce1b9cf6 100644 --- a/src/app/savings/savings-account-view/savings-account-view.component.html +++ b/src/app/savings/savings-account-view/savings-account-view.component.html @@ -280,6 +280,13 @@ Standing Instructions + + + {{savingsDatatable.registeredTableName}} + + diff --git a/src/app/savings/savings-account-view/savings-account-view.component.ts b/src/app/savings/savings-account-view/savings-account-view.component.ts index 2dd2a2f46..e1bdf4290 100644 --- a/src/app/savings/savings-account-view/savings-account-view.component.ts +++ b/src/app/savings/savings-account-view/savings-account-view.component.ts @@ -1,6 +1,8 @@ /** Angular Imports */ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; + +/** Custom Buttons Configuration */ import { SavingsButtonsConfiguration } from './savings-buttons.config'; /** @@ -15,6 +17,8 @@ export class SavingsAccountViewComponent implements OnInit { /** Savings Account Data */ savingsAccountData: any; + /** Savings Data Tables */ + savingsDatatables: any; /** Button Configurations */ buttonConfig: SavingsButtonsConfiguration; @@ -23,8 +27,9 @@ export class SavingsAccountViewComponent implements OnInit { * @param {ActivatedRoute} route Activated Route */ constructor(private route: ActivatedRoute) { - this.route.data.subscribe((data: { savingsAccountData: any }) => { + this.route.data.subscribe((data: { savingsAccountData: any, savingsDatatables: any }) => { this.savingsAccountData = data.savingsAccountData; + this.savingsDatatables = data.savingsDatatables; }); } diff --git a/src/app/savings/savings-routing.module.ts b/src/app/savings/savings-routing.module.ts index f1159ae59..16b8b6588 100644 --- a/src/app/savings/savings-routing.module.ts +++ b/src/app/savings/savings-routing.module.ts @@ -12,11 +12,14 @@ import { SavingAccountActionsComponent } from './saving-account-actions/saving-a import { AddSavingsChargeComponent } from './add-savings-charge/add-savings-charge.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'; +import { DatatableTabsComponent } from './savings-account-view/datatable-tabs/datatable-tabs.component'; /** Custom Resolvers */ import { SavingAccountTransactionTemplateResolver } from './common-resolvers/saving-transaction-template.resolver'; import { SavingsChargeTemplateResolver } from './common-resolvers/savings-charge-template.resolver'; 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'; const routes: Routes = [ { @@ -28,7 +31,8 @@ const routes: Routes = [ data: { title: extract('Saving Account View'), routeParamBreadcrumb: 'savingAccountId' }, component: SavingsAccountViewComponent, resolve: { - savingsAccountData: SavingsAccountViewResolver + savingsAccountData: SavingsAccountViewResolver, + savingsDatatables: SavingsDatatablesResolver }, children: [ { @@ -46,6 +50,19 @@ const routes: Routes = [ component: StandingInstructionsTabComponent, data: { title: extract('Savings Account SIH'), breadcrumb: 'Standing Instructions', routeParamBreadcrumb: false } }, + { + path: 'datatables', + children: [ + { + path: ':datatableName', + component: DatatableTabsComponent, + data: { title: extract('View Data Table'), routeParamBreadcrumb: 'datatableName' }, + resolve: { + savingsDatatable: SavingsDatatableResolver + } + } + ] + }, { path: 'add-savings-charge', component: AddSavingsChargeComponent, @@ -73,6 +90,8 @@ const routes: Routes = [ declarations: [], providers: [SavingAccountTransactionTemplateResolver, SavingsChargeTemplateResolver, - SavingsAccountViewResolver] + SavingsAccountViewResolver, + SavingsDatatablesResolver, + SavingsDatatableResolver] }) export class SavingsRoutingModule {} diff --git a/src/app/savings/savings.module.ts b/src/app/savings/savings.module.ts index 5d616427f..911a9fdba 100644 --- a/src/app/savings/savings.module.ts +++ b/src/app/savings/savings.module.ts @@ -16,6 +16,9 @@ import { TransactionsTabComponent } from './savings-account-view/transactions-ta import { SavingsAccountViewComponent } from './savings-account-view/savings-account-view.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'; +import { DatatableTabsComponent } from './savings-account-view/datatable-tabs/datatable-tabs.component'; +import { MultiRowComponent } from './savings-account-view/datatable-tabs/multi-row/multi-row.component'; +import { SingleRowComponent } from './savings-account-view/datatable-tabs/single-row/single-row.component'; /** * Savings Module @@ -36,7 +39,10 @@ import { StandingInstructionsTabComponent } from './savings-account-view/standin TransactionsTabComponent, SavingsAccountViewComponent, ChargesTabComponent, - StandingInstructionsTabComponent + StandingInstructionsTabComponent, + DatatableTabsComponent, + MultiRowComponent, + SingleRowComponent ], providers: [DatePipe] }) diff --git a/src/app/savings/savings.service.ts b/src/app/savings/savings.service.ts index 4b3db6dd9..a86a59161 100644 --- a/src/app/savings/savings.service.ts +++ b/src/app/savings/savings.service.ts @@ -59,8 +59,8 @@ export class SavingsService { } /** - * @param groupId Group Id of group to get data for. - * @returns {Observable} Group data. + * @param accountId Savings Account Id of account to get data for. + * @returns {Observable} Savings data. */ getSavingsAccountData(accountId: string): Observable { const httpParams = new HttpParams().set('associations', 'all'); @@ -88,4 +88,54 @@ export class SavingsService { return this.http.get(`/standinginstructions`, { params: httpParams }); } + /** + * @returns {Observable} + */ + getSavingsDatatables(): Observable { + const httpParams = new HttpParams().set('apptable', 'm_savings_account'); + 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} + */ + getSavingsDatatable(accountId: string, datatableName: string): Observable { + const httpParams = new HttpParams().set('genericResultSet', 'true'); + return this.http.get(`/datatables/${datatableName}/${accountId}`, { params: httpParams }); + } + + /** + * @param accountId account Id of savings account to get add datatable entry for. + * @param datatableName Data Table name. + * @param data Data. + * @returns {Observable} + */ + addSavingsDatatableEntry(accountId: string, datatableName: string, data: any): Observable { + const httpParams = new HttpParams().set('genericResultSet', 'true'); + return this.http.post(`/datatables/${datatableName}/${accountId}`, data, { params: httpParams }); + } + + /** + * @param accountId account Id of savings account to get add datatable entry for. + * @param datatableName Data Table name. + * @param data Data. + * @returns {Observable} + */ + editSavingsDatatableEntry(accountId: string, datatableName: string, data: any): Observable { + const httpParams = new HttpParams().set('genericResultSet', 'true'); + return this.http.put(`/datatables/${datatableName}/${accountId}`, data, { params: httpParams }); + } + + /** + * @param accountId account Id of savings account to get add datatable entry for. + * @param datatableName Data Table name. + * @returns {Observable} + */ + deleteDatatableContent(accountId: string, datatableName: string): Observable { + const httpParams = new HttpParams().set('genericResultSet', 'true'); + return this.http.delete(`/datatables/${datatableName}/${accountId}`, { params: httpParams }); + } + }