Improved task bar issue #57.
This commit is contained in:
parent
6433f7faee
commit
ad2e06b5b4
4 changed files with 43 additions and 8 deletions
|
@ -34,6 +34,10 @@ class TicketZoom extends App.Controller
|
|||
@fetch( @ticket_id, false)
|
||||
@interval( update, 30000, @key, 'ticket_zoom' )
|
||||
|
||||
activate: =>
|
||||
@navupdate '#'
|
||||
@title 'Ticket Zoom ' + @ticket.number
|
||||
|
||||
release: =>
|
||||
@clearInterval( @key, 'ticket_zoom' )
|
||||
@el.remove()
|
||||
|
@ -586,7 +590,7 @@ class TicketZoomRouter extends App.ControllerPermanent
|
|||
constructor: (params) ->
|
||||
super
|
||||
@log 'zoom router', params
|
||||
App.TaskManager.add( 'Ticket', @ticket_id, { callback: TicketZoom } )
|
||||
App.TaskManager.add( 'Ticket', @ticket_id, TicketZoom, params )
|
||||
|
||||
App.Config.set( 'ticket/zoom/:ticket_id', TicketZoomRouter, 'Routes' )
|
||||
App.Config.set( 'ticket/zoom/:ticket_id/nav/:nav', TicketZoomRouter, 'Routes' )
|
||||
|
|
|
@ -24,6 +24,7 @@ class App.TaskWidget extends App.Controller
|
|||
for key, task of tasks
|
||||
item = {}
|
||||
item.key = key
|
||||
item.task = task
|
||||
item.data = App[task.type].find( task.type_id )
|
||||
item_list.push item
|
||||
|
||||
|
@ -34,9 +35,27 @@ class App.TaskWidget extends App.Controller
|
|||
remove: (e) =>
|
||||
e.preventDefault()
|
||||
key = $(e.target).parent().data('id')
|
||||
|
||||
# check if active task is closed
|
||||
task_last = undefined
|
||||
tasks_all = App.TaskManager.all()
|
||||
active_is_closed = false
|
||||
for task_key, task of tasks_all
|
||||
console.log('--', task_key, task)
|
||||
if task.active && task_key.toString() is key.toString()
|
||||
active_is_closed = true
|
||||
|
||||
# remove task
|
||||
App.TaskManager.remove( key )
|
||||
@render()
|
||||
if _.isEmpty( App.TaskManager.all() )
|
||||
@navigate '#'
|
||||
|
||||
# navigate to next task if needed
|
||||
if active_is_closed
|
||||
for key, task of tasks_all
|
||||
task_last = task
|
||||
if task_last
|
||||
@navigate task_last.url
|
||||
if _.isEmpty( tasks_all )
|
||||
@navigate '#'
|
||||
|
||||
App.Config.set( 'task', App.TaskWidget, 'Widgets' )
|
||||
|
|
|
@ -9,10 +9,10 @@ class App.TaskManager
|
|||
_instance ?= new _Singleton
|
||||
_instance.all()
|
||||
|
||||
@add: ( type, type_id, params ) ->
|
||||
@add: ( type, type_id, callback, params ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance.add( type, type_id, params )
|
||||
_instance.add( type, type_id, callback, params )
|
||||
|
||||
@remove: ( key ) ->
|
||||
if _instance == undefined
|
||||
|
@ -34,26 +34,38 @@ class _Singleton extends Spine.Module
|
|||
all: ->
|
||||
@tasks
|
||||
|
||||
add: ( type, type_id, params ) ->
|
||||
add: ( type, type_id, callback, params ) ->
|
||||
for key, task of @tasks
|
||||
if task.type is type && task.type_id is type_id
|
||||
$('#content').empty()
|
||||
$('.content_permanent').hide()
|
||||
$('#content_permanent_' + key ).show()
|
||||
@tasks[key].worker.activate()
|
||||
for task_key, task of @tasks
|
||||
if task_key isnt key
|
||||
task.active = false
|
||||
else
|
||||
task.active = true
|
||||
App.Event.trigger 'ui:rerender'
|
||||
return key
|
||||
|
||||
@task_count++
|
||||
for task_key, task of @tasks
|
||||
task.active = false
|
||||
|
||||
$('#content').empty()
|
||||
$('#content_permanent').append('<div id="content_permanent_' + @task_count + '" class="content_permanent"></div>')
|
||||
$('.content_permanent').hide()
|
||||
$('#content_permanent_' + @task_count ).show()
|
||||
a = new params.callback( el: $('#content_permanent_' + @task_count ), ticket_id: type_id )
|
||||
params['el'] = $('#content_permanent_' + @task_count )
|
||||
a = new callback( params )
|
||||
task =
|
||||
type: type
|
||||
type_id: type_id
|
||||
params: params
|
||||
url: window.location.hash
|
||||
worker: a
|
||||
active: true
|
||||
@tasks[@task_count] = task
|
||||
App.Event.trigger 'ui:rerender'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="well taskbar">
|
||||
<% for item in @item_list: %>
|
||||
<span class="label label-success" data-id="<%- item.key %>"><span class="task"><a href="#ticket/zoom/<%- item.data.id %>" title="<%= item.data.title %>"><%= item.data.title %></a></span> <a href="#" data-type="close" class="icon-remove-circle" title="<%- @T('close') %>"></a></span>
|
||||
<span class="label <% if item.task.active: %>label-success<% else: %>label-info<% end %>" data-id="<%- item.key %>"><span class="task"><a href="#ticket/zoom/<%- item.data.id %>" title="<%= item.data.title %>"><%= item.data.title %></a></span><a href="#" data-type="close" class="icon-remove-circle" title="<%- @T('close') %>"></a></span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue