File

C:/GoDev/src/TCSTK-Angular/projects/tibco-tcstk/tc-liveapps-lib/src/lib/services/tc-roles-service.ts.service.ts

Index

Properties
Methods

Constructor

constructor()

Methods

checkButton
checkButton(buttonId: string, access: RouteAccessControlConfigurationElement)
Parameters :
Name Type Optional
buttonId string No
access RouteAccessControlConfigurationElement No
Returns : boolean
checkRole
checkRole(roleId: string, roles: Roles)
Parameters :
Name Type Optional
roleId string No
roles Roles No
Returns : boolean

Properties

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;
    }
}

result-matching ""

    No results matching ""