diff --git a/src/app/organization/offices/offices.component.html b/src/app/organization/offices/offices.component.html new file mode 100644 index 000000000..cab6452c0 --- /dev/null +++ b/src/app/organization/offices/offices.component.html @@ -0,0 +1,62 @@ +
+ + + + + + + +
+ +
+ +
+ + Filter + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Office Name {{ offices.name }} External ID {{ offices.externalId }} Parent Office {{ offices.parentName }} Opened On {{ offices.openingDate | date }}
+ + + +
+ +
diff --git a/src/app/organization/offices/offices.component.scss b/src/app/organization/offices/offices.component.scss new file mode 100644 index 000000000..24edb63bb --- /dev/null +++ b/src/app/organization/offices/offices.component.scss @@ -0,0 +1,7 @@ +table { + width: 100%; + + .select-row:hover { + cursor: pointer; + } +} diff --git a/src/app/organization/offices/offices.component.spec.ts b/src/app/organization/offices/offices.component.spec.ts new file mode 100644 index 000000000..289a311d7 --- /dev/null +++ b/src/app/organization/offices/offices.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { OfficesComponent } from './offices.component'; + +describe('OfficesComponent', () => { + let component: OfficesComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ OfficesComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(OfficesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/offices/offices.component.ts b/src/app/organization/offices/offices.component.ts new file mode 100644 index 000000000..5e9901942 --- /dev/null +++ b/src/app/organization/offices/offices.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'; + +/** + * Offices component. + */ +@Component({ + selector: 'mifosx-offices', + templateUrl: './offices.component.html', + styleUrls: ['./offices.component.scss'] +}) +export class OfficesComponent implements OnInit { + + /** Offices data. */ + officesData: any; + /** Columns to be displayed in offices table. */ + displayedColumns: string[] = ['name', 'externalId', 'parentName', 'openingDate']; + /** Data source for offices table. */ + dataSource: MatTableDataSource; + + /** Paginator for offices table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + /** Sorter for offices table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the offices data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe(( data: { offices: any }) => { + this.officesData = data.offices; + }); + } + + /** + * Filters data in offices table based on passed value. + * @param {string} filterValue Value to filter data. + */ + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + /** + * Sets the offices table. + */ + ngOnInit() { + this.setOffices(); + } + + /** + * Initializes the data source, paginator and sorter for offices table. + */ + setOffices() { + this.dataSource = new MatTableDataSource(this.officesData); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/organization/offices/offices.resolver.ts b/src/app/organization/offices/offices.resolver.ts new file mode 100644 index 000000000..8438be6dc --- /dev/null +++ b/src/app/organization/offices/offices.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'; + +/** + * Manage Offices data resolver. + */ +@Injectable() +export class OfficesResolver implements Resolve { + + /** + * @param {OrganizationService} organizationService Organization service. + */ + constructor(private organizationService: OrganizationService) {} + + /** + * Returns the offices data. + * @returns {Observable} + */ + resolve(): Observable { + return this.organizationService.getOffices(); + } + +} diff --git a/src/app/organization/organization-routing.module.ts b/src/app/organization/organization-routing.module.ts index 7b085230e..20c58b967 100644 --- a/src/app/organization/organization-routing.module.ts +++ b/src/app/organization/organization-routing.module.ts @@ -11,9 +11,11 @@ import { extract } from '../core/i18n/i18n.service'; /** Custom Components */ import { OrganizationComponent } from './organization.component'; import { LoanProvisioningCriteriaComponent } from './loan-provisioning-criteria/loan-provisioning-criteria.component'; +import { OfficesComponent } from './offices/offices.component'; /** Custom Resolvers */ import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver'; +import { OfficesResolver } from './offices/offices.resolver'; /** Organization Routes */ const routes: Routes = [ @@ -33,6 +35,14 @@ const routes: Routes = [ resolve: { loanProvisioningCriteria: LoanProvisioningCriteriaResolver } + }, + { + path: 'offices', + component: OfficesComponent, + data: { title: extract('Manage Offices'), breadcrumb: 'Manage Offices' }, + resolve: { + offices: OfficesResolver + } } ] } @@ -48,7 +58,8 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule], providers: [ - LoanProvisioningCriteriaResolver + LoanProvisioningCriteriaResolver, + OfficesResolver ] }) export class OrganizationRoutingModule { } diff --git a/src/app/organization/organization.component.html b/src/app/organization/organization.component.html index 0b22a1327..7c168185d 100644 --- a/src/app/organization/organization.component.html +++ b/src/app/organization/organization.component.html @@ -8,7 +8,7 @@ - + diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index 7f8f80959..0cdf75e93 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -8,6 +8,7 @@ import { OrganizationRoutingModule } from './organization-routing.module'; /** Custom Components */ import { OrganizationComponent } from './organization.component'; import { LoanProvisioningCriteriaComponent } from './loan-provisioning-criteria/loan-provisioning-criteria.component'; +import { OfficesComponent } from './offices/offices.component'; /** * Organization Module @@ -21,7 +22,8 @@ import { LoanProvisioningCriteriaComponent } from './loan-provisioning-criteria/ ], declarations: [ OrganizationComponent, - LoanProvisioningCriteriaComponent + LoanProvisioningCriteriaComponent, + OfficesComponent ] }) export class OrganizationModule { } diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts index cc9c10c4e..4271fcc6c 100644 --- a/src/app/organization/organization.service.ts +++ b/src/app/organization/organization.service.ts @@ -25,4 +25,11 @@ export class OrganizationService { return this.http.get('/provisioningcriteria'); } + /** + * @returns {Observable} Offices data + */ + getOffices(): Observable { + return this.http.get('/offices'); + } + }