From bf700cc1009e04367294661c649e07cea58af887 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: Fri, 7 Apr 2023 20:35:27 -0600 Subject: [PATCH] Enhacement to management funds (#1735) Co-authored-by: Jose Alberto Hernandez --- .../datatable-tab/datatable-tab.component.ts | 5 +- .../multi-row/multi-row.component.html | 34 ---- .../multi-row/multi-row.component.scss | 10 -- .../multi-row/multi-row.component.spec.ts | 25 --- .../multi-row/multi-row.component.ts | 155 ------------------ .../create-fund/create-fund.component.html | 37 +++++ .../create-fund/create-fund.component.scss | 3 + .../create-fund/create-fund.component.spec.ts | 25 +++ .../create-fund/create-fund.component.ts | 53 ++++++ .../edit-fund/edit-fund.component.html | 37 +++++ .../edit-fund/edit-fund.component.scss | 3 + .../edit-fund/edit-fund.component.spec.ts | 25 +++ .../edit-fund/edit-fund.component.ts | 56 +++++++ .../manage-funds/manage-fund.resolver.spec.ts | 16 ++ .../manage-funds/manage-fund.resolver.ts | 23 +++ .../manage-funds/manage-funds.component.html | 65 ++++---- .../manage-funds/manage-funds.component.scss | 8 + .../manage-funds/manage-funds.component.ts | 25 ++- .../view-fund/view-fund.component.html | 41 +++++ .../view-fund/view-fund.component.scss | 10 ++ .../view-fund/view-fund.component.spec.ts | 25 +++ .../view-fund/view-fund.component.ts | 27 +++ .../organization-routing.module.ts | 45 ++++- src/app/organization/organization.module.ts | 6 + src/app/organization/organization.service.ts | 7 + .../datatable-multi-row.component.html | 4 +- .../datatable-multi-row.component.ts | 27 ++- .../users/view-user/view-user.component.html | 3 + 28 files changed, 530 insertions(+), 270 deletions(-) delete mode 100644 src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.html delete mode 100644 src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.scss delete mode 100644 src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.spec.ts delete mode 100644 src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.ts create mode 100644 src/app/organization/manage-funds/create-fund/create-fund.component.html create mode 100644 src/app/organization/manage-funds/create-fund/create-fund.component.scss create mode 100644 src/app/organization/manage-funds/create-fund/create-fund.component.spec.ts create mode 100644 src/app/organization/manage-funds/create-fund/create-fund.component.ts create mode 100644 src/app/organization/manage-funds/edit-fund/edit-fund.component.html create mode 100644 src/app/organization/manage-funds/edit-fund/edit-fund.component.scss create mode 100644 src/app/organization/manage-funds/edit-fund/edit-fund.component.spec.ts create mode 100644 src/app/organization/manage-funds/edit-fund/edit-fund.component.ts create mode 100644 src/app/organization/manage-funds/manage-fund.resolver.spec.ts create mode 100644 src/app/organization/manage-funds/manage-fund.resolver.ts create mode 100644 src/app/organization/manage-funds/view-fund/view-fund.component.html create mode 100644 src/app/organization/manage-funds/view-fund/view-fund.component.scss create mode 100644 src/app/organization/manage-funds/view-fund/view-fund.component.spec.ts create mode 100644 src/app/organization/manage-funds/view-fund/view-fund.component.ts diff --git a/src/app/loans/loans-view/datatable-tab/datatable-tab.component.ts b/src/app/loans/loans-view/datatable-tab/datatable-tab.component.ts index 4d0b17848..418686391 100644 --- a/src/app/loans/loans-view/datatable-tab/datatable-tab.component.ts +++ b/src/app/loans/loans-view/datatable-tab/datatable-tab.component.ts @@ -10,7 +10,7 @@ export class DatatableTabComponent { entityId: string; /** Loan Datatable */ - entityDatatable: any; + entityDatatable: any = null; /** Multi Row Datatable Flag */ multiRowDatatableFlag: boolean; @@ -20,9 +20,10 @@ export class DatatableTabComponent { */ constructor(private route: ActivatedRoute) { this.entityId = this.route.parent.parent.snapshot.paramMap.get('loanId'); - + this.entityDatatable = null; this.route.data.subscribe((data: { loanDatatable: any }) => { this.entityDatatable = data.loanDatatable; + console.log(this.entityDatatable); this.multiRowDatatableFlag = this.entityDatatable.columnHeaders[0].columnName === 'id' ? true : false; }); } diff --git a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.html b/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.html deleted file mode 100644 index 0ef067f5b..000000000 --- a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.html +++ /dev/null @@ -1,34 +0,0 @@ -
- -
-
-

{{datatableName}}

-
-
- - - - - - -
-
- - - - - - - - - - - - -
{{datatableColumn}} {{ formatValue(i, data.row[i]) }}
- -
diff --git a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.scss b/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.scss deleted file mode 100644 index b60aa2a1e..000000000 --- a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.scss +++ /dev/null @@ -1,10 +0,0 @@ -.tab-container { - padding: 1%; - margin: 1%; - .action-button{ - margin-left: auto; - } - table { - width: 100%; - } -} diff --git a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.spec.ts b/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.spec.ts deleted file mode 100644 index dd46589d8..000000000 --- a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -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/loans/loans-view/datatable-tab/multi-row/multi-row.component.ts b/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.ts deleted file mode 100644 index 5a4568f7f..000000000 --- a/src/app/loans/loans-view/datatable-tab/multi-row/multi-row.component.ts +++ /dev/null @@ -1,155 +0,0 @@ -/** 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/dialog'; - -/** Custom Dialogs */ -import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component'; -import { DeleteDialogComponent } from '../../../../shared/delete-dialog/delete-dialog.component'; -import { SettingsService } from 'app/settings/settings.service'; - -/** Custom Models */ -import { FormfieldBase } from 'app/shared/form-dialog/formfield/model/formfield-base'; - -/** Custom Services */ -import { LoansService } from '../../../loans.service'; -import { Dates } from 'app/core/utils/dates'; -import { Datatables } from 'app/core/utils/datatables'; -import { DateFormatPipe } from 'app/pipes/date-format.pipe'; -import { DatetimeFormatPipe } from 'app/pipes/datetime-format.pipe'; -import { DecimalPipe, NumberFormatStyle } from '@angular/common'; - -/** - * Loan 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; - /** Loan Id */ - loanId: string; - /** Toggle button visibility */ - showDeleteBotton: boolean; - - /** Data Table Reference */ - @ViewChild('dataTable', { static: true }) dataTableRef: MatTable; - - /** - * Fetches loan Id from parent route params. - * @param {ActivatedRoute} route Activated Route. - * @param {Dates} dateUtils Date Utils. - * @param {LoansService} loansService Loans Service. - * @param {MatDialog} dialog Mat Dialog. - * @param {SettingsService} settingsService Settings Service - * @param {Datatables} datatables Datatable utils - */ - constructor(private route: ActivatedRoute, - private dateUtils: Dates, - private loansService: LoansService, - private dialog: MatDialog, - private settingsService: SettingsService, - private datatables: Datatables, - private dateFormat: DateFormatPipe, - private dateTimeFormat: DatetimeFormatPipe, - private numberFormat: DecimalPipe) { - this.loanId = this.route.parent.parent.snapshot.paramMap.get('loanId'); - } - - /** - * 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: this.settingsService.language.code }; - const dateTransformColumns: string[] = []; - const columns = this.dataObject.columnHeaders.filter((column: any) => { - return ((column.columnName !== 'id') && (column.columnName !== 'loan_id') && (column.columnName !== 'created_at') && (column.columnName !== 'updated_at')); - }); - const formfields: FormfieldBase[] = this.datatables.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.dateUtils.formatDate(response.data.value[column], dataTableEntryObject.dateFormat); - }); - dataTableEntryObject = { ...response.data.value, ...dataTableEntryObject }; - this.loansService.addLoanDatatableEntry(this.loanId, this.datatableName, dataTableEntryObject).subscribe(() => { - this.loansService.getLoanDatatable(this.loanId, 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.loansService.deleteDatatableContent(this.loanId, this.datatableName).subscribe(() => { - this.loansService.getLoanDatatable(this.loanId, this.datatableName).subscribe((dataObject: any) => { - this.datatableData = dataObject.data; - this.showDeleteBotton = false; - this.dataTableRef.renderRows(); - }); - }); - } - }); - } - - formatValue(index: number, value: any): any { - const columnDisplayType = this.dataObject.columnHeaders[index].columnDisplayType; - if (columnDisplayType === 'DATE') { - return this.dateFormat.transform(value); - } else if (columnDisplayType === 'DATETIME') { - return this.dateTimeFormat.transform(value); - } else if (columnDisplayType === 'INTEGER' || columnDisplayType === 'DECIMAL') { - return this.numberFormat.transform(value); - } - return value; - } - -} diff --git a/src/app/organization/manage-funds/create-fund/create-fund.component.html b/src/app/organization/manage-funds/create-fund/create-fund.component.html new file mode 100644 index 000000000..7d16618ca --- /dev/null +++ b/src/app/organization/manage-funds/create-fund/create-fund.component.html @@ -0,0 +1,37 @@ +
+ + + +
+ + + +
+ + + Name + + + Name is required + + + + + External Id + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/organization/manage-funds/create-fund/create-fund.component.scss b/src/app/organization/manage-funds/create-fund/create-fund.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/organization/manage-funds/create-fund/create-fund.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/organization/manage-funds/create-fund/create-fund.component.spec.ts b/src/app/organization/manage-funds/create-fund/create-fund.component.spec.ts new file mode 100644 index 000000000..333a8ecb0 --- /dev/null +++ b/src/app/organization/manage-funds/create-fund/create-fund.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CreateFundComponent } from './create-fund.component'; + +describe('CreateFundComponent', () => { + let component: CreateFundComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ CreateFundComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(CreateFundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/manage-funds/create-fund/create-fund.component.ts b/src/app/organization/manage-funds/create-fund/create-fund.component.ts new file mode 100644 index 000000000..523e317b9 --- /dev/null +++ b/src/app/organization/manage-funds/create-fund/create-fund.component.ts @@ -0,0 +1,53 @@ +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { OrganizationService } from 'app/organization/organization.service'; + +@Component({ + selector: 'mifosx-create-fund', + templateUrl: './create-fund.component.html', + styleUrls: ['./create-fund.component.scss'] +}) +export class CreateFundComponent implements OnInit { + + /** Charge form. */ + fundForm: FormGroup; + + /** + * Retrieves the charge data from `resolve`. + * @param {ProductsService} productsService Products Service. + * @param {FormBuilder} formBuilder Form Builder. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + */ + constructor(private organizationService: OrganizationService, + private formBuilder: FormBuilder, + private router: Router, + private route: ActivatedRoute) { + } + + ngOnInit() { + this.createFundForm(); + } + + /** + * Edit Fund form. + */ + createFundForm() { + this.fundForm = this.formBuilder.group({ + 'name': ['', Validators.required], + 'externalId': [''] + }); + } + + + submit() { + const payload = this.fundForm.getRawValue(); + this.organizationService.createFund(payload) + .subscribe((response: any) => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } + + +} diff --git a/src/app/organization/manage-funds/edit-fund/edit-fund.component.html b/src/app/organization/manage-funds/edit-fund/edit-fund.component.html new file mode 100644 index 000000000..d15e424bc --- /dev/null +++ b/src/app/organization/manage-funds/edit-fund/edit-fund.component.html @@ -0,0 +1,37 @@ +
+ + + +
+ + + +
+ + + Name + + + Name is required + + + + + External Id + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/organization/manage-funds/edit-fund/edit-fund.component.scss b/src/app/organization/manage-funds/edit-fund/edit-fund.component.scss new file mode 100644 index 000000000..d774f68da --- /dev/null +++ b/src/app/organization/manage-funds/edit-fund/edit-fund.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/organization/manage-funds/edit-fund/edit-fund.component.spec.ts b/src/app/organization/manage-funds/edit-fund/edit-fund.component.spec.ts new file mode 100644 index 000000000..8d33f0dcd --- /dev/null +++ b/src/app/organization/manage-funds/edit-fund/edit-fund.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditFundComponent } from './edit-fund.component'; + +describe('EditFundComponent', () => { + let component: EditFundComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ EditFundComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(EditFundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/manage-funds/edit-fund/edit-fund.component.ts b/src/app/organization/manage-funds/edit-fund/edit-fund.component.ts new file mode 100644 index 000000000..61fa9b31d --- /dev/null +++ b/src/app/organization/manage-funds/edit-fund/edit-fund.component.ts @@ -0,0 +1,56 @@ +import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { OrganizationService } from 'app/organization/organization.service'; + +@Component({ + selector: 'mifosx-edit-fund', + templateUrl: './edit-fund.component.html', + styleUrls: ['./edit-fund.component.scss'] +}) +export class EditFundComponent implements OnInit { + + /** Selected Data. */ + fundData: any; + /** Charge form. */ + fundForm: FormGroup; + + /** + * Retrieves the charge data from `resolve`. + * @param {ProductsService} productsService Products Service. + * @param {FormBuilder} formBuilder Form Builder. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + */ + constructor(private organizationService: OrganizationService, + private formBuilder: FormBuilder, + private router: Router, + private route: ActivatedRoute) { + this.route.data.subscribe((data: { fundData: any }) => { + this.fundData = data.fundData; + }); + } + + ngOnInit() { + this.createFundForm(); + } + + /** + * Edit Fund form. + */ + createFundForm() { + this.fundForm = this.formBuilder.group({ + 'name': [this.fundData.name, Validators.required], + 'externalId': [this.fundData.externalId] + }); + } + + + submit() { + const payload = this.fundForm.getRawValue(); + this.organizationService.editFund(this.fundData.id.toString(), payload) + .subscribe((response: any) => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } +} diff --git a/src/app/organization/manage-funds/manage-fund.resolver.spec.ts b/src/app/organization/manage-funds/manage-fund.resolver.spec.ts new file mode 100644 index 000000000..8ff437a8f --- /dev/null +++ b/src/app/organization/manage-funds/manage-fund.resolver.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { ManageFundResolver } from './manage-fund.resolver'; + +describe('ManageFundResolver', () => { + let resolver: ManageFundResolver; + + beforeEach(() => { + TestBed.configureTestingModule({}); + resolver = TestBed.inject(ManageFundResolver); + }); + + it('should be created', () => { + expect(resolver).toBeTruthy(); + }); +}); diff --git a/src/app/organization/manage-funds/manage-fund.resolver.ts b/src/app/organization/manage-funds/manage-fund.resolver.ts new file mode 100644 index 000000000..5a95b1cd9 --- /dev/null +++ b/src/app/organization/manage-funds/manage-fund.resolver.ts @@ -0,0 +1,23 @@ +import { Injectable } from '@angular/core'; +import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; +import { Observable } from 'rxjs'; +import { OrganizationService } from '../organization.service'; + +@Injectable({ + providedIn: 'root' +}) +export class ManageFundResolver implements Resolve { + /** + * @param {OrganizationService} organizationService Organization service. + */ + constructor(private organizationService: OrganizationService) {} + + /** + * Returns the manage funds data. + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const fundId = route.paramMap.get('id'); + return this.organizationService.getFund(fundId); + } +} diff --git a/src/app/organization/manage-funds/manage-funds.component.html b/src/app/organization/manage-funds/manage-funds.component.html index dbba02ff2..3ea6780f6 100644 --- a/src/app/organization/manage-funds/manage-funds.component.html +++ b/src/app/organization/manage-funds/manage-funds.component.html @@ -1,49 +1,46 @@ +
+
+ +
+
+
- +
+ + {{ 'labels.inputs.Filter' | translate }} + + +
-
+
-
+ - - - - Required field - - + + + + -
- -
+ + + + - + + - +
Name {{ charge.name }} External Id {{ charge.externalId }}
- - - - - - -
- -
- -
- -
- - + +
+

Manage Funds

This form will be used to add fund. If you would like to add fund click on add funds button and fill the fund name then click on + button else click Next or Back. For more details click: Manage Funds

diff --git a/src/app/organization/manage-funds/manage-funds.component.scss b/src/app/organization/manage-funds/manage-funds.component.scss index 5911b9d88..9cb2c854a 100644 --- a/src/app/organization/manage-funds/manage-funds.component.scss +++ b/src/app/organization/manage-funds/manage-funds.component.scss @@ -1,3 +1,11 @@ .container{ width: 74rem; } + +table { + width: 100%; + + .select-row:hover { + cursor: pointer; + } +} diff --git a/src/app/organization/manage-funds/manage-funds.component.ts b/src/app/organization/manage-funds/manage-funds.component.ts index 0a506fa86..4415bbeaa 100644 --- a/src/app/organization/manage-funds/manage-funds.component.ts +++ b/src/app/organization/manage-funds/manage-funds.component.ts @@ -18,6 +18,9 @@ import { ConfigurationWizardService } from '../../configuration-wizard/configura /** Custom Dialog Component */ import { ContinueSetupDialogComponent } from '../../configuration-wizard/continue-setup-dialog/continue-setup-dialog.component'; +import { MatTableDataSource } from '@angular/material/table'; +import { MatPaginator } from '@angular/material/paginator'; +import { MatSort } from '@angular/material/sort'; /** * Manage Funds component. @@ -40,6 +43,15 @@ export class ManageFundsComponent implements OnInit, AfterViewInit { @ViewChild('fundFormRef') fundFormRef: ElementRef; /* Template for popover on funds form */ @ViewChild('templateFundFormRef') templateFundFormRef: TemplateRef; + /** Columns to be displayed in funds table. */ + displayedColumns: string[] = ['name', 'externalId']; + /** Data source for Funds table. */ + dataSource: MatTableDataSource; + + /** Paginator for charges table. */ + @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; + /** Sorter for charges table. */ + @ViewChild(MatSort, { static: true }) sort: MatSort; /** * Retrieves the manage funds data from `resolve`. @@ -64,7 +76,18 @@ export class ManageFundsComponent implements OnInit, AfterViewInit { } ngOnInit() { - this.createFundForm(); + this.dataSource = new MatTableDataSource(this.fundsData); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + + } + + /** + * Filters data in charges table based on passed value. + * @param {string} filterValue Value to filter data. + */ + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); } /** diff --git a/src/app/organization/manage-funds/view-fund/view-fund.component.html b/src/app/organization/manage-funds/view-fund/view-fund.component.html new file mode 100644 index 000000000..56bd361ab --- /dev/null +++ b/src/app/organization/manage-funds/view-fund/view-fund.component.html @@ -0,0 +1,41 @@ +
+ +
+ +
+ + + + + +
+ +
+ Name +
+ +
+ {{ fundData.name }} +
+ +
+ External Id +
+ +
+ {{ fundData.externalId }} +
+ +
+ +
+ +
+
+ +
+ +
diff --git a/src/app/organization/manage-funds/view-fund/view-fund.component.scss b/src/app/organization/manage-funds/view-fund/view-fund.component.scss new file mode 100644 index 000000000..46cf44760 --- /dev/null +++ b/src/app/organization/manage-funds/view-fund/view-fund.component.scss @@ -0,0 +1,10 @@ +.container { + max-width: 37rem; + + .content { + div { + margin: 1rem 0; + word-wrap: break-word; + } + } +} diff --git a/src/app/organization/manage-funds/view-fund/view-fund.component.spec.ts b/src/app/organization/manage-funds/view-fund/view-fund.component.spec.ts new file mode 100644 index 000000000..65604c00d --- /dev/null +++ b/src/app/organization/manage-funds/view-fund/view-fund.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ViewFundComponent } from './view-fund.component'; + +describe('ViewFundComponent', () => { + let component: ViewFundComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ViewFundComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ViewFundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/manage-funds/view-fund/view-fund.component.ts b/src/app/organization/manage-funds/view-fund/view-fund.component.ts new file mode 100644 index 000000000..45754e748 --- /dev/null +++ b/src/app/organization/manage-funds/view-fund/view-fund.component.ts @@ -0,0 +1,27 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +@Component({ + selector: 'mifosx-view-fund', + templateUrl: './view-fund.component.html', + styleUrls: ['./view-fund.component.scss'] +}) +export class ViewFundComponent implements OnInit { + + /** Fund data. */ + fundData: any; + + /** + * Retrieves the charge data from `resolve`. + * @param {Router} router Router for navigation. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: { fundData: any }) => { + this.fundData = data.fundData; + }); + } + + ngOnInit() { + } + +} diff --git a/src/app/organization/organization-routing.module.ts b/src/app/organization/organization-routing.module.ts index 49b79fade..a6bd2347c 100644 --- a/src/app/organization/organization-routing.module.ts +++ b/src/app/organization/organization-routing.module.ts @@ -101,6 +101,10 @@ import { LoanProvisioningCriteriaTemplateResolver } from './loan-provisioning-cr import { LoanProvisioningCriteriaAndTemplateResolver } from './loan-provisioning-criteria/common-resolvers/loan-provisioning-criteria-and-template.resolver'; import { StandingInstructionsTemplateResolver } from './standing-instructions-history/standing-instructions-template.resolver'; import { AdvanceSearchTemplateResolver } from './fund-mapping/advance-search-template.resolver'; +import { ManageFundResolver } from './manage-funds/manage-fund.resolver'; +import { ViewFundComponent } from './manage-funds/view-fund/view-fund.component'; +import { EditFundComponent } from './manage-funds/edit-fund/edit-fund.component'; +import { CreateFundComponent } from './manage-funds/create-fund/create-fund.component'; /** Organization Routes */ const routes: Routes = [ @@ -570,8 +574,45 @@ const routes: Routes = [ }, { path: 'manage-funds', - component: ManageFundsComponent, - data: { title: extract('Manage Funds Days'), breadcrumb: 'Manage Funds' }, + data: { title: extract('Manage Funds'), breadcrumb: 'Manage Funds' }, + children: [ + { + path: '', + component: ManageFundsComponent, + resolve: { + funds: ManageFundsResolver + }, + }, + { + path: 'create', + component: CreateFundComponent, + data: { title: extract('Create Fund'), breadcrumb: 'Create' } + }, + { + path: ':id', + data: { title: extract('View Fund'), breadcrumb: 'id', routeParamBreadcrumb: 'id' }, + resolve: { + fundData: ManageFundResolver + }, + children: [ + { + path: '', + component: ViewFundComponent, + resolve: { + fundData: ManageFundResolver + }, + }, + { + path: 'edit', + component: EditFundComponent, + data: { title: extract('Edit Fund'), breadcrumb: 'Edit', routeParamBreadcrumb: false }, + resolve: { + fundData: ManageFundResolver + } + }, + ] + }, + ], resolve: { funds: ManageFundsResolver } diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index 27be902aa..f028bdcc9 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -74,6 +74,9 @@ import { OfficeItemNode } from './holidays/create-holiday/office-item.class'; import { OfficeItemFlatNode } from './holidays/create-holiday/office-flat-item.class'; import { ChecklistDatabase } from './holidays/create-holiday/checklist-db.class'; import { CreateHoliday } from './holidays/create-holiday/create-holiday.service'; +import { CreateFundComponent } from './manage-funds/create-fund/create-fund.component'; +import { EditFundComponent } from './manage-funds/edit-fund/edit-fund.component'; +import { ViewFundComponent } from './manage-funds/view-fund/view-fund.component'; /** @@ -148,6 +151,9 @@ import { CreateHoliday } from './holidays/create-holiday/create-holiday.service' StandingInstructionsHistoryComponent, FundMappingComponent, CreateHolidayComponent, + CreateFundComponent, + EditFundComponent, + ViewFundComponent, ], providers: [ CreateHoliday, diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts index c10d14468..96c8a6ae3 100644 --- a/src/app/organization/organization.service.ts +++ b/src/app/organization/organization.service.ts @@ -680,6 +680,13 @@ export class OrganizationService { return this.http.get('/funds'); } + /** + * @returns {Observable} Fund data + */ + getFund(fundId: string): Observable { + return this.http.get(`/funds/${fundId}`); + } + /** * @param {any} fund Fund to be created. * @returns {Observable} diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.html b/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.html index 2f86d67f0..c54a5851a 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.html +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.html @@ -11,14 +11,14 @@ -
- +
diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.ts b/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.ts index 3a9aa5d16..c2c8ba888 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.ts +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-multi-row/datatable-multi-row.component.ts @@ -1,5 +1,5 @@ import { DecimalPipe } from '@angular/common'; -import { Component, Input, OnInit, ViewChild } from '@angular/core'; +import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { MatTable } from '@angular/material/table'; import { ActivatedRoute } from '@angular/router'; @@ -18,7 +18,7 @@ import { SystemService } from 'app/system/system.service'; templateUrl: './datatable-multi-row.component.html', styleUrls: ['./datatable-multi-row.component.scss'] }) -export class DatatableMultiRowComponent implements OnInit { +export class DatatableMultiRowComponent implements OnInit, OnDestroy { /** Data Object */ @Input() dataObject: any; @@ -34,6 +34,7 @@ export class DatatableMultiRowComponent implements OnInit { /** Toggle button visibility */ showDeleteBotton: boolean; + hasEntityData = false; /** Data Table Reference */ @ViewChild('dataTable', { static: true }) dataTableRef: MatTable; @@ -55,7 +56,9 @@ export class DatatableMultiRowComponent implements OnInit { private datatables: Datatables, private dateFormat: DateFormatPipe, private dateTimeFormat: DatetimeFormatPipe, - private numberFormat: DecimalPipe) { } + private numberFormat: DecimalPipe) { + + } /** * Fetches data table name from route params. @@ -69,7 +72,17 @@ export class DatatableMultiRowComponent implements OnInit { return columnHeader.columnName; }); this.datatableData = this.dataObject.data; - this.showDeleteBotton = this.datatableData[0] ? true : false; + this.hasEntityData = (this.datatableData && this.datatableData.length > 0); + console.log(this.hasEntityData); + console.log(this.dataObject.data); + } + + ngOnDestroy(): void { + this.datatableColumns = null; + this.datatableData = null; + this.hasEntityData = false; + console.log(this.hasEntityData); + console.log(this.dataObject.data); } /** @@ -128,7 +141,11 @@ export class DatatableMultiRowComponent implements OnInit { } else if (columnDisplayType === 'DATETIME') { return this.dateTimeFormat.transform(value); } else if (columnDisplayType === 'INTEGER' || columnDisplayType === 'DECIMAL') { - return this.numberFormat.transform(value); + if (typeof value === 'number') { + return this.numberFormat.transform(value); + } else { + return value; + } } return value; } diff --git a/src/app/users/view-user/view-user.component.html b/src/app/users/view-user/view-user.component.html index 0be1e944d..f41b8e733 100644 --- a/src/app/users/view-user/view-user.component.html +++ b/src/app/users/view-user/view-user.component.html @@ -74,6 +74,9 @@ +
+ +
{{datatableColumn}}