feat: add functionality for codes component (#309)
This commit is contained in:
committed by
Abhay Chawla
parent
b517d015cc
commit
04ff1abcc4
@@ -1,5 +1,7 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatPaginator, MatSort, MatTableDataSource } from '@angular/material';
|
||||
import { MatTableDataSource, MatPaginator, MatSort } from '@angular/material';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-codes',
|
||||
@@ -11,7 +13,7 @@ export class CodesComponent implements OnInit {
|
||||
/** Codes data. */
|
||||
codesData: any;
|
||||
/** Columns to be displayed in codes table. */
|
||||
displayedColumns: string[] = ['codeName', 'systemDefined'];
|
||||
displayedColumns: string[] = ['name', 'systemDefined'];
|
||||
/** Data source for codes table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
@@ -20,9 +22,39 @@ export class CodesComponent implements OnInit {
|
||||
/** Sorter for codes table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
constructor() { }
|
||||
/**
|
||||
* Retrieves the codes data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { codes: any }) => {
|
||||
this.codesData = data.codes;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the codes table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setCodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for codes table.
|
||||
*/
|
||||
setCodes() {
|
||||
this.dataSource = new MatTableDataSource(this.codesData);
|
||||
console.log(this.codesData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters data in codes table based on passed value.
|
||||
* @param {string} filterValue Value to filter data.
|
||||
*/
|
||||
applyFilter(filterValue: string) {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user