diff --git a/src/app/organization/currencies/currencies.component.html b/src/app/organization/currencies/currencies.component.html new file mode 100644 index 000000000..c116a7065 --- /dev/null +++ b/src/app/organization/currencies/currencies.component.html @@ -0,0 +1,40 @@ +
+ +
+ +
+ +
+ + Filter + + +
+ +
+ + + + + + + + + + + + + + + + +
Currency Name {{ currency.name }} Currency Code {{ currency.code }}
+ + + +
+ +
diff --git a/src/app/organization/currencies/currencies.component.scss b/src/app/organization/currencies/currencies.component.scss new file mode 100644 index 000000000..1922e7ffa --- /dev/null +++ b/src/app/organization/currencies/currencies.component.scss @@ -0,0 +1,3 @@ +table { + width: 100%; +} diff --git a/src/app/organization/currencies/currencies.component.spec.ts b/src/app/organization/currencies/currencies.component.spec.ts new file mode 100644 index 000000000..e0d1232a8 --- /dev/null +++ b/src/app/organization/currencies/currencies.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CurrenciesComponent } from './currencies.component'; + +describe('CurrenciesComponent', () => { + let component: CurrenciesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CurrenciesComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CurrenciesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/currencies/currencies.component.ts b/src/app/organization/currencies/currencies.component.ts new file mode 100644 index 000000000..4800e0441 --- /dev/null +++ b/src/app/organization/currencies/currencies.component.ts @@ -0,0 +1,65 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material'; +import { ActivatedRoute } from '@angular/router'; + +/** rxjs Imports */ +import { of } from 'rxjs'; + +/** + * Currencies component. + */ +@Component({ + selector: 'mifosx-currencies', + templateUrl: './currencies.component.html', + styleUrls: ['./currencies.component.scss'] +}) +export class CurrenciesComponent implements OnInit { + + /** Currencies data. */ + currenciesData: any; + /** Columns to be displayed in currencies table. */ + displayedColumns: string[] = ['name', 'code']; + /** Data source for currencies table. */ + dataSource: MatTableDataSource; + + /** Paginator for currencies table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + /** Sorter for currencies table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the currencies data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe(( data: { currencies: any }) => { + this.currenciesData = data.currencies.selectedCurrencyOptions; + }); + } + + /** + * Filters data in currencies table based on passed value. + * @param {string} filterValue Value to filter data. + */ + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + /** + * Sets the currencies table. + */ + ngOnInit() { + this.setCurrencies(); + } + + /** + * Initializes the data source, paginator and sorter for currencies table. + */ + setCurrencies() { + this.dataSource = new MatTableDataSource(this.currenciesData); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/organization/currencies/currencies.resolver.ts b/src/app/organization/currencies/currencies.resolver.ts new file mode 100644 index 000000000..1f674072e --- /dev/null +++ b/src/app/organization/currencies/currencies.resolver.ts @@ -0,0 +1,30 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { OrganizationService } from '../organization.service'; + +/** + * Currencies data resolver. + */ +@Injectable() +export class CurrenciesResolver implements Resolve { + + /** + * @param {OrganizationService} organizationService Organization service. + */ + constructor(private organizationService: OrganizationService) {} + + /** + * Returns the currencies data. + * @returns {Observable} + */ + resolve(): Observable { + return this.organizationService.getCurrencies(); + } + +} diff --git a/src/app/organization/organization-routing.module.ts b/src/app/organization/organization-routing.module.ts index dc9f6aede..a3b809791 100644 --- a/src/app/organization/organization-routing.module.ts +++ b/src/app/organization/organization-routing.module.ts @@ -13,11 +13,13 @@ import { OrganizationComponent } from './organization.component'; import { LoanProvisioningCriteriaComponent } from './loan-provisioning-criteria/loan-provisioning-criteria.component'; import { OfficesComponent } from './offices/offices.component'; import { EmployeesComponent } from './employees/employees.component'; +import { CurrenciesComponent } from './currencies/currencies.component'; /** Custom Resolvers */ import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver'; import { OfficesResolver } from './offices/offices.resolver'; import { EmployeesResolver } from './employees/employees.resolver'; +import { CurrenciesResolver } from './currencies/currencies.resolver'; /** Organization Routes */ const routes: Routes = [ @@ -53,6 +55,14 @@ const routes: Routes = [ resolve: { employees: EmployeesResolver } + }, + { + path: 'currencies', + component: CurrenciesComponent, + data: { title: extract('Currency Configuration'), breadcrumb: 'Currency Configuration' }, + resolve: { + currencies: CurrenciesResolver + } } ] } @@ -70,7 +80,8 @@ const routes: Routes = [ providers: [ LoanProvisioningCriteriaResolver, OfficesResolver, - EmployeesResolver + EmployeesResolver, + CurrenciesResolver ] }) export class OrganizationRoutingModule { } diff --git a/src/app/organization/organization.component.html b/src/app/organization/organization.component.html index eeedb4bb6..f5b4075ba 100644 --- a/src/app/organization/organization.component.html +++ b/src/app/organization/organization.component.html @@ -80,7 +80,7 @@ - + diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index a0e650c4e..54fd47c97 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -10,6 +10,7 @@ import { OrganizationComponent } from './organization.component'; import { LoanProvisioningCriteriaComponent } from './loan-provisioning-criteria/loan-provisioning-criteria.component'; import { OfficesComponent } from './offices/offices.component'; import { EmployeesComponent } from './employees/employees.component'; +import { CurrenciesComponent } from './currencies/currencies.component'; /** * Organization Module @@ -25,7 +26,8 @@ import { EmployeesComponent } from './employees/employees.component'; OrganizationComponent, LoanProvisioningCriteriaComponent, OfficesComponent, - EmployeesComponent + EmployeesComponent, + CurrenciesComponent ] }) export class OrganizationModule { } diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts index f9034a3c5..c5912e44f 100644 --- a/src/app/organization/organization.service.ts +++ b/src/app/organization/organization.service.ts @@ -39,4 +39,11 @@ export class OrganizationService { return this.http.get('/staff'); } + /** + * @returns {Observable} Currencies data + */ + getCurrencies(): Observable { + return this.http.get('/currencies'); + } + }