Added permission config support for permanent tasks.

This commit is contained in:
Martin Edenhofer 2016-08-18 07:24:58 +02:00
parent eeebb2709d
commit 3ea96e6f84
7 changed files with 16 additions and 8 deletions

View file

@ -770,5 +770,5 @@ class Setting extends App.ControllerModal
)
App.Config.set('customer_chat', CustomerChatRouter, 'Routes')
App.Config.set('CustomerChat', { controller: 'CustomerChat', authentication: true }, 'permanentTask')
App.Config.set('CustomerChat', { controller: 'CustomerChat', permission: ['chat.agent'] }, 'permanentTask')
App.Config.set('CustomerChat', { prio: 1200, parent: '', name: 'Customer Chat', target: '#customer_chat', key: 'CustomerChat', shown: false, permission: ['chat.agent'], class: 'chat' }, 'NavBar')

View file

@ -205,5 +205,5 @@ class CTIRouter extends App.ControllerPermanent
)
App.Config.set('cti', CTIRouter, 'Routes')
App.Config.set('CTI', { controller: 'CTI', authentication: true }, 'permanentTask')
App.Config.set('CTI', { controller: 'CTI', permission: ['cti.agent'] }, 'permanentTask')
App.Config.set('CTI', { prio: 1300, parent: '', name: 'Phone', target: '#cti', key: 'CTI', shown: false, permission: ['cti.agent'], class: 'phone' }, 'NavBar')

View file

@ -93,6 +93,8 @@ class App.Dashboard extends App.Controller
@$(".tab-content.#{target}").removeClass('hidden')
class DashboardRouter extends App.ControllerPermanent
requiredPermission: ['*']
constructor: (params) ->
super
@ -108,5 +110,5 @@ class DashboardRouter extends App.ControllerPermanent
)
App.Config.set('dashboard', DashboardRouter, 'Routes')
App.Config.set('Dashboard', { controller: 'Dashboard', permission: ['*'] }, 'permanentTask')
App.Config.set('Dashboard', { prio: 100, parent: '', name: 'Dashboard', target: '#dashboard', key: 'Dashboard', permission: ['ticket.agent'], class: 'dashboard' }, 'NavBar')
App.Config.set('Dashboard', { controller: 'Dashboard', authentication: true }, 'permanentTask')

View file

@ -1908,8 +1908,8 @@ class CustomerChatRef extends App.Controller
# )
App.Config.set( 'layout_ref/customer_chat', CustomerChatRef, 'Routes' )
# App.Config.set( 'CustomerChatRef', { controller: 'CustomerChatRef', authentication: true }, 'permanentTask' )
# App.Config.set( 'CustomerChatRef', { prio: 1200, parent: '', name: 'Customer Chat', target: '#layout_ref/customer_chat', key: 'CustomerChatRef', role: ['Agent'], class: 'chat' }, 'NavBar' )
# App.Config.set( 'CustomerChatRef', { controller: 'CustomerChatRef', permission: ['chat.agent'] }, 'permanentTask' )
# App.Config.set( 'CustomerChatRef', { prio: 1200, parent: '', name: 'Customer Chat', target: '#layout_ref/customer_chat', key: 'CustomerChatRef', permission: ['chat.agent'], class: 'chat' }, 'NavBar' )
class ChatWindowRef extends Spine.Controller
@extend Spine.Events

View file

@ -787,5 +787,5 @@ class TicketOverviewRouter extends App.ControllerPermanent
App.Config.set('ticket/view', TicketOverviewRouter, 'Routes')
App.Config.set('ticket/view/:view', TicketOverviewRouter, 'Routes')
App.Config.set('TicketOverview', { controller: 'TicketOverview', authentication: true }, 'permanentTask')
App.Config.set('TicketOverview', { controller: 'TicketOverview', permission: ['ticket.agent', 'ticket.customer'] }, 'permanentTask')
App.Config.set('TicketOverview', { prio: 1000, parent: '', name: 'Overviews', target: '#ticket/view', key: 'TicketOverview', permission: ['ticket.agent', 'ticket.customer'], class: 'overviews' }, 'NavBar')

View file

@ -533,12 +533,15 @@ class _taskManagerSingleton extends App.Controller
App.Event.trigger 'taskbar:init'
# initial load of permanent tasks
authentication = App.Session.get('id')
user_id = App.Session.get('id')
user = undefined
if user_id
user = App.User.find(user_id)
permanentTask = App.Config.get('permanentTask')
taskCount = 0
if permanentTask
for key, config of permanentTask
if !config.authentication || (config.authentication && authentication)
if !config.permission || (user && user.permission(config.permission))
taskCount += 1
do (key, config, taskCount) =>
App.Delay.set(

View file

@ -183,6 +183,9 @@ class App.User extends App.Model
if !_.isArray(key)
keys = [key]
# if any permission exists
return true if _.contains(keys, '*')
# get all permissions of user
permissions = {}
for role_id in @role_ids