From 34e1f4da36e97c0a396622bdfc5ff8b9f3073d60 Mon Sep 17 00:00:00 2001 From: punwai Date: Tue, 24 Dec 2019 01:31:24 +0700 Subject: [PATCH] feat: add tellers component (#520) Fixes: #159 --- .../organization-routing.module.ts | 13 +++- .../organization/organization.component.html | 2 +- src/app/organization/organization.module.ts | 4 +- src/app/organization/organization.service.ts | 9 ++- .../tellers/tellers.component.html | 65 +++++++++++++++++++ .../tellers/tellers.component.scss | 15 +++++ .../tellers/tellers.component.spec.ts | 25 +++++++ .../organization/tellers/tellers.component.ts | 65 +++++++++++++++++++ .../organization/tellers/tellers.resolver.ts | 30 +++++++++ 9 files changed, 224 insertions(+), 4 deletions(-) create mode 100644 src/app/organization/tellers/tellers.component.html create mode 100644 src/app/organization/tellers/tellers.component.scss create mode 100644 src/app/organization/tellers/tellers.component.spec.ts create mode 100644 src/app/organization/tellers/tellers.component.ts create mode 100644 src/app/organization/tellers/tellers.resolver.ts diff --git a/src/app/organization/organization-routing.module.ts b/src/app/organization/organization-routing.module.ts index f191802de..403643318 100644 --- a/src/app/organization/organization-routing.module.ts +++ b/src/app/organization/organization-routing.module.ts @@ -16,6 +16,7 @@ import { EmployeesComponent } from './employees/employees.component'; import { CurrenciesComponent } from './currencies/currencies.component'; import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component'; import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component'; +import { TellersComponent } from './tellers/tellers.component'; /** Custom Resolvers */ import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver'; @@ -24,6 +25,7 @@ import { EmployeesResolver } from './employees/employees.resolver'; import { CurrenciesResolver } from './currencies/currencies.resolver'; import { SmsCampaignsResolver } from './sms-campaigns/sms-campaigns.resolver'; import { AdhocQueriesResolver } from './adhoc-query/adhoc-queries.resolver'; +import { TellersResolver } from './tellers/tellers.resolver'; /** Organization Routes */ const routes: Routes = [ @@ -88,6 +90,14 @@ const routes: Routes = [ } } ] + }, + { + path: 'tellers', + component: TellersComponent, + data: { title: extract('Tellers'), breadcrumb: 'Tellers' }, + resolve: { + tellers: TellersResolver + } } ] } @@ -108,7 +118,8 @@ const routes: Routes = [ EmployeesResolver, CurrenciesResolver, SmsCampaignsResolver, - AdhocQueriesResolver + AdhocQueriesResolver, + TellersResolver ] }) export class OrganizationRoutingModule { } diff --git a/src/app/organization/organization.component.html b/src/app/organization/organization.component.html index fc8c34088..971841cc0 100644 --- a/src/app/organization/organization.component.html +++ b/src/app/organization/organization.component.html @@ -105,7 +105,7 @@

Easy way to reassign all the loan from one LO to another LO

- + diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index 7c37f5fc8..3c4554dbd 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -14,6 +14,7 @@ import { EmployeesComponent } from './employees/employees.component'; import { CurrenciesComponent } from './currencies/currencies.component'; import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component'; import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component'; +import { TellersComponent } from './tellers/tellers.component'; /** * Organization Module @@ -33,7 +34,8 @@ import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component'; EmployeesComponent, CurrenciesComponent, SmsCampaignsComponent, - AdhocQueryComponent + AdhocQueryComponent, + TellersComponent ] }) export class OrganizationModule { } diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts index d6bd99396..a1770eee7 100644 --- a/src/app/organization/organization.service.ts +++ b/src/app/organization/organization.service.ts @@ -1,6 +1,6 @@ /** Angular Imports */ import { Injectable } from '@angular/core'; -import { HttpClient, HttpParams } from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; /** rxjs Imports */ import { Observable } from 'rxjs'; @@ -60,4 +60,11 @@ export class OrganizationService { return this.http.get('/adhocquery'); } + /** + * @returns {Observable} Tellers data + */ + getTellers(): Observable { + return this.http.get('/tellers'); + } + } diff --git a/src/app/organization/tellers/tellers.component.html b/src/app/organization/tellers/tellers.component.html new file mode 100644 index 000000000..5079a9762 --- /dev/null +++ b/src/app/organization/tellers/tellers.component.html @@ -0,0 +1,65 @@ +
+ + + +
+ +
+ +
+ + Filter + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Branch {{ teller.officeName }} Teller Name {{ teller.name }} Status +
+ +
+
Started On {{ teller.startDate | date }} Actions + +
+ + + +
+ +
diff --git a/src/app/organization/tellers/tellers.component.scss b/src/app/organization/tellers/tellers.component.scss new file mode 100644 index 000000000..9b40653e2 --- /dev/null +++ b/src/app/organization/tellers/tellers.component.scss @@ -0,0 +1,15 @@ +table { + width: 100%; + + .select-row:hover { + cursor: pointer; + } +} + +.true { + color: #32cd32; +} + +.false { + color: #f44366; +} diff --git a/src/app/organization/tellers/tellers.component.spec.ts b/src/app/organization/tellers/tellers.component.spec.ts new file mode 100644 index 000000000..2572890ff --- /dev/null +++ b/src/app/organization/tellers/tellers.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TellersComponent } from './tellers.component'; + +describe('TellersComponent', () => { + let component: TellersComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ TellersComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(TellersComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/tellers/tellers.component.ts b/src/app/organization/tellers/tellers.component.ts new file mode 100644 index 000000000..8d6fca8e6 --- /dev/null +++ b/src/app/organization/tellers/tellers.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'; + +/** + * Tellers component. + */ +@Component({ + selector: 'mifosx-tellers', + templateUrl: './tellers.component.html', + styleUrls: ['./tellers.component.scss'] +}) +export class TellersComponent implements OnInit { + + /** Tellers data. */ + tellersData: any; + /** Columns to be displayed in tellers table. */ + displayedColumns: string[] = ['officeName', 'name', 'status', 'startDate', 'actions']; + /** Data source for tellers table. */ + dataSource: MatTableDataSource; + + /** Paginator for tellers table. */ + @ViewChild(MatPaginator) paginator: MatPaginator; + /** Sorter for tellers table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the tellers data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe(( data: { tellers: any }) => { + this.tellersData = data.tellers; + }); + } + + /** + * Filters data in tellers table based on passed value. + * @param {string} filterValue Value to filter data. + */ + applyFilter(filterValue: string) { + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + /** + * Sets the tellers table. + */ + ngOnInit() { + this.setTellers(); + } + + /** + * Initializes the data source, paginator and sorter for tellers table. + */ + setTellers() { + this.dataSource = new MatTableDataSource(this.tellersData); + this.dataSource.paginator = this.paginator; + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/organization/tellers/tellers.resolver.ts b/src/app/organization/tellers/tellers.resolver.ts new file mode 100644 index 000000000..5e0f78fd8 --- /dev/null +++ b/src/app/organization/tellers/tellers.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'; + +/** + * Tellers data resolver. + */ +@Injectable() +export class TellersResolver implements Resolve { + + /** + * @param {OrganizationService} organizationService Organization service. + */ + constructor(private organizationService: OrganizationService) {} + + /** + * Returns the Tellers data. + * @returns {Observable} + */ + resolve(): Observable { + return this.organizationService.getTellers(); + } + +}