@@ -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<any>;
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user