feat: add view employee component (#546)

Fixes: #534
This commit is contained in:
Rishabh Verma
2020-01-05 19:10:47 +03:00
committed by Abhay Chawla
parent 4ac086381f
commit df12a6b4ba
9 changed files with 198 additions and 2 deletions
@@ -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';
/**
* Employee data resolver.
*/
@Injectable()
export class EmployeeResolver implements Resolve<Object> {
/**
* @param {OrganizationService} organizationService Organization service.
*/
constructor(private organizationService: OrganizationService) {}
/**
* Returns the employee data.
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const employeeId = route.paramMap.get('id');
return this.organizationService.getEmployee(employeeId);
}
}
@@ -55,7 +55,7 @@
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="[row.id]" class="select-row"></tr>
</table>
@@ -0,0 +1,78 @@
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
<button mat-raised-button color="primary">
<fa-icon icon="edit"></fa-icon>&nbsp;&nbsp;
Edit
</button>
</div>
<div class="container">
<mat-card>
<mat-card-content>
<div fxLayout="row wrap" class="content">
<div fxFlex="50%" class="mat-body-strong">
First Name
</div>
<div fxFlex="50%">
{{ employeeData.firstname }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Last Name
</div>
<div fxFlex="50%">
{{ employeeData.lastname }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Office
</div>
<div fxFlex="50%">
{{ employeeData.officeName }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Is Loan Officer
</div>
<div fxFlex="50%">
{{ employeeData.isLoanOfficer === true ? 'Yes' : 'No' }}
</div>
<div fxFlex="50%" class="mat-body-strong" *ngIf="employeeData.mobileNo">
Mobile Number for SMS
</div>
<div fxFlex="50%" *ngIf="employeeData.mobileNo">
{{ employeeData.mobileNo }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Status
</div>
<div fxFlex="50%">
{{ employeeData.isActive === true ? 'Active' : 'Inactive' }}
</div>
<div fxFlex="50%" class="mat-body-strong">
Joining Date
</div>
<div fxFlex="50%">
{{ employeeData.joiningDate | date }}
</div>
</div>
</mat-card-content>
</mat-card>
</div>
@@ -0,0 +1,10 @@
.container {
max-width: 37rem;
.content {
div {
margin: 1rem 0;
word-wrap: break-word;
}
}
}
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ViewEmployeeComponent } from './view-employee.component';
describe('ViewEmployeeComponent', () => {
let component: ViewEmployeeComponent;
let fixture: ComponentFixture<ViewEmployeeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewEmployeeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ViewEmployeeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,31 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
/**
* View Employee Component.
*/
@Component({
selector: 'mifosx-view-employee',
templateUrl: './view-employee.component.html',
styleUrls: ['./view-employee.component.scss']
})
export class ViewEmployeeComponent implements OnInit {
/** Employee data. */
employeeData: any;
/**
* Retrieves the employee data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
*/
constructor(private route: ActivatedRoute) {
this.route.data.subscribe((data: { employee: any }) => {
this.employeeData = data.employee;
});
}
ngOnInit() {
}
}