/** Angular Imports */ import { Component , ViewChild } from '@angular/core' ; import { ActivatedRoute } from '@angular/router' ; import { MatDialog } from '@angular/material/dialog' ; import { MatTable } from '@angular/material/table' ; /** Custom Dialogs */ import { UnassignRoleDialogComponent } from '../custom-dialogs/unassign-role-dialog/unassign-role-dialog.component' ; /** Custom Services */ import { GroupsService } from 'app/groups/groups.service' ; /**
 * Groups Committee Tab Component
 */ @ Component ( { selector : 'mifosx-committee-tab' , templateUrl : './committee-tab.component.html' , styleUrls : [ './committee-tab.component.scss' ] } ) export class CommitteeTabComponent { /** Group Status */ groupStatus : any ; /** Group Roles Data */ groupRolesData : any [ ] ; /** Groups View Data */ groupViewData : any ; /** Columns to be Displayed for client members table */ groupRolesColumns : string [ ] = [ 'Name' , 'Role' , 'Client Id' , 'Actions' ] ; /** Roles Table */ @ ViewChild ( 'rolesTable' ) rolesTableRef : MatTable < Element > ; param { ActivatedRoute } route param { GroupsService } groupsService param { MatDialog } dialog constructor ( private route , private groupsService , public dialog ) { this . route . parent . data . subscribe ( ( data ) => { this . groupViewData = data . groupViewData ; this . groupRolesData = this . groupViewData . groupRoles ; this . groupStatus = this . groupViewData . status . value ; } ) ; } param { any } clientId param { any } roleId unassignRole ( clientId , roleId ) { const unAssignRoleDialogRef = this . dialog . open ( UnassignRoleDialogComponent , { data : { id : clientId } } ) ; unAssignRoleDialogRef . afterClosed ( ) . subscribe ( ( response ) => { if ( response . confirm ) { const clientIndex = this . groupRolesData . findIndex ( ( client ) => client . clientId === clientId ) ; this . groupRolesData . splice ( clientIndex , 1 ) ; this . rolesTableRef . renderRows ( ) ; this . groupsService . unAssignRoleCommand ( this . groupViewData . id , roleId ) . subscribe ( ( ) => { } ) ; } } ) ; } }