C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-liveapps-lib/src/lib/services/tc-roles-service.ts.service.ts
Properties |
|
Methods |
constructor()
|
checkButton | |||||||||
checkButton(buttonId: string, access: RouteAccessControlConfigurationElement)
|
|||||||||
Parameters :
Returns :
boolean
|
checkRole |
checkRole(roleId: string, roles: Roles)
|
Returns :
boolean
|
amIConfigurator |
Default value : () => {...}
|
Private currentRole |
Default value : undefined
|
getCurrentRole |
Default value : () => {...}
|
Private hasButtonAccess |
Default value : () => {...}
|
Private hasRoleAccess |
Default value : () => {...}
|
setCurrentRole |
Default value : () => {...}
|
import { Injectable } from '@angular/core';
import {Roles, RouteAccessControlConfigurationElement} from '../models/tc-groups-data';
import { RoleAttribute } from '@tibco-tcstk/tc-core-lib';
@Injectable({
providedIn: 'root'
})
export class TcRolesService {
constructor() { }
private currentRole = undefined;
private hasRoleAccess = (roleReq: string, roles: Roles): boolean => {
const reqRole = roles.roles.find(role => {
return (role.id === roleReq);
})
return reqRole ? true : false;
}
private hasButtonAccess = (buttonId: string, access: RouteAccessControlConfigurationElement): boolean => {
return access.buttonIds.indexOf(buttonId) > -1;
}
checkRole(roleId: string, roles: Roles): boolean {
return this.hasRoleAccess(roleId, roles);
}
checkButton(buttonId: string, access: RouteAccessControlConfigurationElement): boolean {
return this.hasButtonAccess(buttonId, access);
}
amIConfigurator = (roles: Roles): boolean => {
const reqRole = roles.roles.find(role => {
return (role.configuration === true);
})
return reqRole ? true : false;
}
getCurrentRole = (): RoleAttribute => {
return this.currentRole;
}
setCurrentRole = (role: RoleAttribute): void => {
this.currentRole = role;
}
}