@@ -0,0 +1,66 @@
|
||||
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
|
||||
|
||||
<button mat-raised-button color="primary">
|
||||
<fa-icon icon="upload"></fa-icon>
|
||||
Import Employees
|
||||
</button>
|
||||
|
||||
<button mat-raised-button color="primary">
|
||||
<fa-icon icon="plus"></fa-icon>
|
||||
Create Employees
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div fxLayout="row" fxLayoutGap="20px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Filter</mat-label>
|
||||
<input matInput (keyup)="applyFilter($event.target.value)">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div class="mat-elevation-z8">
|
||||
|
||||
<table mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
<ng-container matColumnDef="displayName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name </th>
|
||||
<td mat-cell *matCellDef="let employee"> {{ employee.displayName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="isLoanOfficer">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Loan Officer </th>
|
||||
<td mat-cell *matCellDef="let employee">
|
||||
<div [className]="employee.isLoanOfficer === true ? 'true' : 'false'">
|
||||
<fa-icon *ngIf="employee.isLoanOfficer" icon="check-circle" size="lg" matTooltip="Yes" matTooltipPosition="right"></fa-icon>
|
||||
<fa-icon *ngIf="!employee.isLoanOfficer" icon="times-circle" size="lg" matTooltip="No" matTooltipPosition="right"></fa-icon>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="officeName">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Office </th>
|
||||
<td mat-cell *matCellDef="let employees"> {{ employees.officeName }} </td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="isActive">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header> Status </th>
|
||||
<td mat-cell *matCellDef="let employee">
|
||||
<div [className]="employee.isActive === true ? 'true' : 'false'">
|
||||
<fa-icon matTooltip="{{ employee.isActive === true ? 'Active' : 'Inactive' }}" matTooltipPosition="right" icon="circle" size="lg"></fa-icon>
|
||||
</div>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;" class="select-row"></tr>
|
||||
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons></mat-paginator>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
table {
|
||||
width: 100%;
|
||||
|
||||
.select-row:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.true {
|
||||
color: #32cd32;
|
||||
}
|
||||
|
||||
.false {
|
||||
color: #f44366;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EmployeesComponent } from './employees.component';
|
||||
|
||||
describe('EmployeesComponent', () => {
|
||||
let component: EmployeesComponent;
|
||||
let fixture: ComponentFixture<EmployeesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ EmployeesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EmployeesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -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';
|
||||
|
||||
/**
|
||||
* Employees component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-employees',
|
||||
templateUrl: './employees.component.html',
|
||||
styleUrls: ['./employees.component.scss']
|
||||
})
|
||||
export class EmployeesComponent implements OnInit {
|
||||
|
||||
/** Employees data. */
|
||||
employeesData: any;
|
||||
/** Columns to be displayed in employees table. */
|
||||
displayedColumns: string[] = ['displayName', 'isLoanOfficer', 'officeName', 'isActive'];
|
||||
/** Data source for employees table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for employees table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for employees table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
/**
|
||||
* Retrieves the employees data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { employees: any }) => {
|
||||
this.employeesData = data.employees;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters data in employees table based on passed value.
|
||||
* @param {string} filterValue Value to filter data.
|
||||
*/
|
||||
applyFilter(filterValue: string) {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the employees table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setEmployees();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for employees table.
|
||||
*/
|
||||
setEmployees() {
|
||||
this.dataSource = new MatTableDataSource(this.employeesData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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';
|
||||
|
||||
/**
|
||||
* Employees data resolver.
|
||||
*/
|
||||
@Injectable()
|
||||
export class EmployeesResolver implements Resolve<Object> {
|
||||
|
||||
/**
|
||||
* @param {OrganizationService} organizationService Organization service.
|
||||
*/
|
||||
constructor(private organizationService: OrganizationService) {}
|
||||
|
||||
/**
|
||||
* Returns the employees data.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
resolve(): Observable<any> {
|
||||
return this.organizationService.getEmployees();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,10 +12,12 @@ import { extract } from '../core/i18n/i18n.service';
|
||||
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';
|
||||
|
||||
/** Custom Resolvers */
|
||||
import { LoanProvisioningCriteriaResolver } from './loan-provisioning-criteria/loan-provisioning-criteria.resolver';
|
||||
import { OfficesResolver } from './offices/offices.resolver';
|
||||
import { EmployeesResolver } from './employees/employees.resolver';
|
||||
|
||||
/** Organization Routes */
|
||||
const routes: Routes = [
|
||||
@@ -43,6 +45,14 @@ const routes: Routes = [
|
||||
resolve: {
|
||||
offices: OfficesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'employees',
|
||||
component: EmployeesComponent,
|
||||
data: { title: extract('Manage Employees'), breadcrumb: 'Manage Employees' },
|
||||
resolve: {
|
||||
employees: EmployeesResolver
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -59,7 +69,8 @@ const routes: Routes = [
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
LoanProvisioningCriteriaResolver,
|
||||
OfficesResolver
|
||||
OfficesResolver,
|
||||
EmployeesResolver
|
||||
]
|
||||
})
|
||||
export class OrganizationRoutingModule { }
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<p matLine>Define holidays for office</p>
|
||||
</mat-list-item>
|
||||
|
||||
<mat-list-item>
|
||||
<mat-list-item [routerLink]="['employees']">
|
||||
<mat-icon matListIcon>
|
||||
<fa-icon icon="user" size="sm"></fa-icon>
|
||||
</mat-icon>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { OrganizationRoutingModule } from './organization-routing.module';
|
||||
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';
|
||||
|
||||
/**
|
||||
* Organization Module
|
||||
@@ -23,7 +24,8 @@ import { OfficesComponent } from './offices/offices.component';
|
||||
declarations: [
|
||||
OrganizationComponent,
|
||||
LoanProvisioningCriteriaComponent,
|
||||
OfficesComponent
|
||||
OfficesComponent,
|
||||
EmployeesComponent
|
||||
]
|
||||
})
|
||||
export class OrganizationModule { }
|
||||
|
||||
@@ -32,4 +32,11 @@ export class OrganizationService {
|
||||
return this.http.get('/offices');
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Observable<any>} Employees data
|
||||
*/
|
||||
getEmployees(): Observable<any> {
|
||||
return this.http.get('/staff');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user