import { Component, OnInit, Optional } from '@angular/core'; import { RoleService } from '../shared/service/role.service'; import { IRole } from '../shared/core/IRole'; import { IOrganisationStaff } from '../shared/core/IOrganisationStaff'; import { DynamicDialogRef, DynamicDialogConfig } from 'primeng/api'; @Component({ selector: 'app-staff-additional-access', templateUrl: './staff-additional-access.component.html', styleUrls: ['./staff-additional-access.component.css'] }) export class StaffAdditionalAccessComponent implements OnInit { //roles list will bind to this roleList : IRole[]; //this will have organisation id organisationId : number =0; //right side staff list bind to this staffList :IOrganisationStaff[]; //when selecting staff, it assing to this selectedValues : any[]; constructor(private roleService:RoleService, @Optional() public ref: DynamicDialogRef, @Optional() public config: DynamicDialogConfig,) { } ngOnInit() { this.organisationId =this.config.data.organisationId; //calling and binding roles list this.getRoleList(); } //get organisation roles getRoleList(){ this.roleService.getRoleList(this.organisationId).subscribe(roles=>{ this.roleList = roles; }) } //when click on each role, staff list will display by this method showRoleStaffs(id : number){ //selected staff list reset this.selectedValues = []; //filter staff list from role list object this.staffList = this.roleList.find(x=>x.Id == id).StaffList; } // save button to save selected staff saveAdditionalAccess(){ console.log(this.selectedValues); } }