diff --git a/src/app/organization/organization-routing.module.ts b/src/app/organization/organization-routing.module.ts index b9369d48e..dbd4abae6 100644 --- a/src/app/organization/organization-routing.module.ts +++ b/src/app/organization/organization-routing.module.ts @@ -20,6 +20,7 @@ import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component'; import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component'; import { ViewAdhocQueryComponent } from './adhoc-query/view-adhoc-query/view-adhoc-query.component'; import { TellersComponent } from './tellers/tellers.component'; +import { ViewTellerComponent } from './tellers/view-teller/view-teller.component'; import { PaymentTypesComponent } from './payment-types/payment-types.component'; import { PasswordPreferencesComponent } from './password-preferences/password-preferences.component'; import { EntityDataTableChecksComponent } from './entity-data-table-checks/entity-data-table-checks.component'; @@ -37,6 +38,7 @@ import { SmsCampaignsResolver } from './sms-campaigns/sms-campaigns.resolver'; import { AdhocQueriesResolver } from './adhoc-query/adhoc-queries.resolver'; import { AdhocQueryResolver } from './adhoc-query/adhoc-query.resolver'; import { TellersResolver } from './tellers/tellers.resolver'; +import { TellerResolver } from './tellers/teller.resolver'; import { PaymentTypesResolver } from './payment-types/payment-types.resolver'; import { PasswordPreferencesTemplateResolver } from './password-preferences/password-preferences-template.resolver'; import { EntityDataTableChecksResolver } from './entity-data-table-checks/entity-data-table-checks.resolver'; @@ -150,11 +152,24 @@ const routes: Routes = [ }, { path: 'tellers', - component: TellersComponent, data: { title: extract('Tellers'), breadcrumb: 'Tellers' }, - resolve: { - tellers: TellersResolver - } + children: [ + { + path: '', + component: TellersComponent, + resolve: { + tellers: TellersResolver + } + }, + { + path: ':id', + component: ViewTellerComponent, + data: { title: extract('View Teller'), routeResolveBreadcrumb: ['teller', 'name'] }, + resolve: { + teller: TellerResolver + } + } + ] }, { path: 'payment-types', @@ -221,6 +236,7 @@ const routes: Routes = [ AdhocQueriesResolver, AdhocQueryResolver, TellersResolver, + TellerResolver, PaymentTypesResolver, PasswordPreferencesTemplateResolver, EntityDataTableChecksResolver, diff --git a/src/app/organization/organization.module.ts b/src/app/organization/organization.module.ts index b676e0564..a72a8ed95 100644 --- a/src/app/organization/organization.module.ts +++ b/src/app/organization/organization.module.ts @@ -16,6 +16,7 @@ import { SmsCampaignsComponent } from './sms-campaigns/sms-campaigns.component'; import { AdhocQueryComponent } from './adhoc-query/adhoc-query.component'; import { ViewAdhocQueryComponent } from './adhoc-query/view-adhoc-query/view-adhoc-query.component'; import { TellersComponent } from './tellers/tellers.component'; +import { ViewTellerComponent } from './tellers/view-teller/view-teller.component'; import { PaymentTypesComponent } from './payment-types/payment-types.component'; import { PasswordPreferencesComponent } from './password-preferences/password-preferences.component'; import { EntityDataTableChecksComponent } from './entity-data-table-checks/entity-data-table-checks.component'; @@ -46,6 +47,7 @@ import { ViewEmployeeComponent } from './employees/view-employee/view-employee.c AdhocQueryComponent, ViewAdhocQueryComponent, TellersComponent, + ViewTellerComponent, PaymentTypesComponent, PasswordPreferencesComponent, EntityDataTableChecksComponent, diff --git a/src/app/organization/organization.service.ts b/src/app/organization/organization.service.ts index 573c7130f..d975c910d 100644 --- a/src/app/organization/organization.service.ts +++ b/src/app/organization/organization.service.ts @@ -107,6 +107,22 @@ export class OrganizationService { return this.http.get('/tellers'); } + /** + * @param {string} tellerId Teller ID of teller. + * @returns {Observable} Teller. + */ + getTeller(tellerId: string): Observable { + return this.http.get(`/tellers/${tellerId}`); + } + + /** + * @param {string} tellerId Teller ID of teller to be deleted. + * @returns {Observable} + */ + deleteTeller(tellerId: string): Observable { + return this.http.delete(`/tellers/${tellerId}`); + } + /** * @returns {Observable} Payment Types data */ diff --git a/src/app/organization/tellers/teller.resolver.ts b/src/app/organization/tellers/teller.resolver.ts new file mode 100644 index 000000000..35bf0edd7 --- /dev/null +++ b/src/app/organization/tellers/teller.resolver.ts @@ -0,0 +1,31 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve, ActivatedRouteSnapshot } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { OrganizationService } from 'app/organization/organization.service'; + +/** + * Teller data resolver. + */ +@Injectable() +export class TellerResolver implements Resolve { + + /** + * @param {OrganizationService} organizationService Organization service. + */ + constructor(private organizationService: OrganizationService) {} + + /** + * Returns the teller data. + * @returns {Observable} + */ + resolve(route: ActivatedRouteSnapshot): Observable { + const tellerId = route.paramMap.get('id'); + return this.organizationService.getTeller(tellerId); + } + +} diff --git a/src/app/organization/tellers/tellers.component.html b/src/app/organization/tellers/tellers.component.html index 5079a9762..ed708dda6 100644 --- a/src/app/organization/tellers/tellers.component.html +++ b/src/app/organization/tellers/tellers.component.html @@ -46,7 +46,7 @@ Actions - + @@ -54,7 +54,7 @@ - + diff --git a/src/app/organization/tellers/view-teller/view-teller.component.html b/src/app/organization/tellers/view-teller/view-teller.component.html new file mode 100644 index 000000000..219536225 --- /dev/null +++ b/src/app/organization/tellers/view-teller/view-teller.component.html @@ -0,0 +1,66 @@ +
+ + +
+ +
+ + + + + +
+ +
+ Office +
+ +
+ {{ tellerData.officeName }} +
+ +
+ Description +
+ +
+ {{ tellerData.description }} +
+ +
+ Start Date +
+ +
+ {{ tellerData.startDate | date }} +
+ +
+ End Date +
+ +
+ {{ tellerData.endDate | date }} +
+ +
+ Status +
+ +
+ {{ tellerData.status | titlecase }} +
+ +
+ +
+ +
+ +
diff --git a/src/app/organization/tellers/view-teller/view-teller.component.scss b/src/app/organization/tellers/view-teller/view-teller.component.scss new file mode 100644 index 000000000..56668f14f --- /dev/null +++ b/src/app/organization/tellers/view-teller/view-teller.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/tellers/view-teller/view-teller.component.spec.ts b/src/app/organization/tellers/view-teller/view-teller.component.spec.ts new file mode 100644 index 000000000..77a2ae9ed --- /dev/null +++ b/src/app/organization/tellers/view-teller/view-teller.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ViewTellerComponent } from './view-teller.component'; + +describe('ViewTellerComponent', () => { + let component: ViewTellerComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ViewTellerComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ViewTellerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/organization/tellers/view-teller/view-teller.component.ts b/src/app/organization/tellers/view-teller/view-teller.component.ts new file mode 100644 index 000000000..546f7aaa6 --- /dev/null +++ b/src/app/organization/tellers/view-teller/view-teller.component.ts @@ -0,0 +1,61 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { MatDialog } from '@angular/material'; + +/** Custom Services */ +import { OrganizationService } from 'app/organization/organization.service'; + +/** Custom Components */ +import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dialog.component'; + +/** + * View Teller Component. + */ +@Component({ + selector: 'mifosx-view-teller', + templateUrl: './view-teller.component.html', + styleUrls: ['./view-teller.component.scss'] +}) +export class ViewTellerComponent implements OnInit { + + /** Teller data. */ + tellerData: any; + + /** + * Retrieves the Teller data from `resolve`. + * @param {OrganizationService} organizationService Organization Service. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + * @param {MatDialog} dialog Dialog reference. + */ + constructor(private organizationService: OrganizationService, + private route: ActivatedRoute, + private router: Router, + public dialog: MatDialog) { + this.route.data.subscribe((data: { teller: any }) => { + this.tellerData = data.teller; + }); + } + + ngOnInit() { + } + + /** + * Deletes the teller and redirects to tellers. + */ + deleteTeller() { + const deleteTellerDialogRef = this.dialog.open(DeleteDialogComponent, { + data: { deleteContext: `teller ${this.tellerData.id}` } + }); + deleteTellerDialogRef.afterClosed().subscribe((response: any) => { + if (response.delete) { + this.organizationService.deleteTeller(this.tellerData.id) + .subscribe(() => { + this.router.navigate(['/organization/tellers']); + }); + } + }); + } + +}