committed by
Abhay Chawla
parent
07573d011c
commit
ed94d7492d
@@ -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';
|
||||
|
||||
/**
|
||||
* Roles and Permissions component.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-roles-and-permissions',
|
||||
templateUrl: './roles-and-permissions.component.html',
|
||||
styleUrls: ['./roles-and-permissions.component.scss']
|
||||
})
|
||||
export class RolesAndPermissionsComponent implements OnInit {
|
||||
|
||||
/** Role data. */
|
||||
roleData: any;
|
||||
/** Columns to be displayed in roles and permissions table. */
|
||||
displayedColumns: string[] = ['name', 'description', 'disabled'];
|
||||
/** Data source for roles and permissions table. */
|
||||
dataSource: MatTableDataSource<any>;
|
||||
|
||||
/** Paginator for roles and permissions table. */
|
||||
@ViewChild(MatPaginator) paginator: MatPaginator;
|
||||
/** Sorter for roles and permissions table. */
|
||||
@ViewChild(MatSort) sort: MatSort;
|
||||
|
||||
/**
|
||||
* Retrieves the roles data from `resolve`.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute) {
|
||||
this.route.data.subscribe(( data: { roles: any }) => {
|
||||
this.roleData = data.roles;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters data in roles and permissions table based on passed value.
|
||||
* @param {string} filterValue Value to filter data.
|
||||
*/
|
||||
applyFilter(filterValue: string) {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the roles and permissions table.
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.setRoles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the data source, paginator and sorter for roles and permissions table.
|
||||
*/
|
||||
setRoles() {
|
||||
this.dataSource = new MatTableDataSource(this.roleData);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.dataSource.sort = this.sort;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user