Improved permanent task handling (check if controller need authentication first).

This commit is contained in:
Martin Edenhofer 2015-03-01 19:30:14 +01:00
parent 08bc3bda3e
commit 7bf4f3e91c
4 changed files with 36 additions and 39 deletions

View file

@ -1,11 +1,7 @@
class App.Dashboard extends App.Controller
constructor: ->
super
# check authentication
return if !@authenticate()
if @isRole('Customer')
@navigate '#'
return
@ -158,6 +154,9 @@ class DashboardRouter extends App.ControllerPermanent
constructor: (params) ->
super
# check authentication
return if !@authenticate()
App.TaskManager.execute(
key: 'Dashboard'
controller: 'Dashboard'
@ -166,8 +165,6 @@ class DashboardRouter extends App.ControllerPermanent
persistent: true
)
App.Config.set( 'dashboard', DashboardRouter, 'Routes' )
App.Config.set( 'Dashboard', { prio: 100, parent: '', name: 'Dashboard', target: '#dashboard', role: ['Agent'], class: 'dashboard' }, 'NavBar' )
App.Config.set( 'Dashboard', 'Dashboard', 'permanentTask' )
App.Config.set( 'Dashboard', { controller: 'Dashboard', authentication: true }, 'permanentTask' )

View file

@ -2,9 +2,6 @@ class App.TicketOverview extends App.Controller
constructor: ->
super
# check authentication
return if !@authenticate()
@render()
render: ->
@ -515,7 +512,7 @@ class App.OverviewSettings extends App.ControllerModal
constructor: ->
super
@overview = App.Overview.find(@overview_id)
console.log('overview_id', @overview_id)
@configure_attributes_article = []
if @view_mode is 'd'
@configure_attributes_article.push({
@ -795,6 +792,9 @@ class TicketOverviewRouter extends App.ControllerPermanent
constructor: (params) ->
super
# check authentication
return if !@authenticate()
# cleanup params
clean_params =
view: params.view
@ -809,8 +809,5 @@ class TicketOverviewRouter extends App.ControllerPermanent
App.Config.set( 'ticket/view', TicketOverviewRouter, 'Routes' )
App.Config.set( 'ticket/view/:view', TicketOverviewRouter, 'Routes' )
#App.Config.set( 'ticket/view/:view/:position/:direction', Router, 'Routes' )
App.Config.set( 'TicketOverview', 'TicketOverview', 'permanentTask' )
App.Config.set( 'TicketOverview', { controller: 'TicketOverview', authentication: true }, 'permanentTask' )
App.Config.set( 'TicketOverview', { prio: 1000, parent: '', name: 'Overviews', target: '#ticket/view', role: ['Agent', 'Customer'], class: 'overviews' }, 'NavBar' )

View file

@ -80,6 +80,7 @@ class _taskManagerSingleton extends Spine.Module
App.Event.bind(
'auth:login'
=>
@reset()
@tasksInitial()
'task'
)
@ -202,7 +203,7 @@ class _taskManagerSingleton extends Spine.Module
startController: (params) =>
@log 'debug', 'controller start try...', params
#console.log 'debug', 'controller start try...', params
# create clean params
params_app = _.clone(params.params)
@ -444,31 +445,33 @@ class _taskManagerSingleton extends Spine.Module
App.Event.trigger 'taskbar:init'
# initial load of permanent tasks
task_count = 0
permanentTask = App.Config.get( 'permanentTask' )
authentication = App.Session.get('id')
permanentTask = App.Config.get( 'permanentTask' )
task_count = 0
if permanentTask
for key, callback of permanentTask
task_count += 1
do (task) =>
App.Delay.set(
=>
@execute(
key: key
controller: callback
params: {}
show: false
persistent: true
init: true
)
task_count * 50
undefined
'task'
)
for key, config of permanentTask
if !config.authentication || ( config.authentication && authentication )
task_count += 1
do (key, config, task_count) =>
App.Delay.set(
=>
@execute(
key: key
controller: config.controller
params: {}
show: false
persistent: true
init: true
)
task_count * 350
undefined
'task'
)
# initial load of taskbar collection
for task in @allTasks
task_count += 1
do (task) =>
do (task, task_count) =>
App.Delay.set(
=>
@execute(

View file

@ -30,10 +30,10 @@ class AgentTicketOverviewLevel0Test < TestCase
:body => 'overview count test #3',
}
)
sleep 6 # till overview is updated
click( :css => '#navigation li.overviews a' )
click( :css => '.content.active .sidebar a[href="#ticket/view/all_unassigned"]' )
sleep 10
sleep 2 # till overview is rendered
# select both via bulk action
click(
@ -62,7 +62,7 @@ class AgentTicketOverviewLevel0Test < TestCase
click(
:css => '.active .bulkAction .js-submit',
)
sleep 6
sleep 8
exists_not(
:css => '.active table tr td input[value="' + ticket1[:id] + '"]',