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)
|
@fetch( @ticket_id, false)
|
||||||
@interval( update, 30000, @key, 'ticket_zoom' )
|
@interval( update, 30000, @key, 'ticket_zoom' )
|
||||||
|
|
||||||
|
activate: =>
|
||||||
|
@navupdate '#'
|
||||||
|
@title 'Ticket Zoom ' + @ticket.number
|
||||||
|
|
||||||
release: =>
|
release: =>
|
||||||
@clearInterval( @key, 'ticket_zoom' )
|
@clearInterval( @key, 'ticket_zoom' )
|
||||||
@el.remove()
|
@el.remove()
|
||||||
|
@ -586,7 +590,7 @@ class TicketZoomRouter extends App.ControllerPermanent
|
||||||
constructor: (params) ->
|
constructor: (params) ->
|
||||||
super
|
super
|
||||||
@log 'zoom router', params
|
@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', TicketZoomRouter, 'Routes' )
|
||||||
App.Config.set( 'ticket/zoom/:ticket_id/nav/:nav', 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
|
for key, task of tasks
|
||||||
item = {}
|
item = {}
|
||||||
item.key = key
|
item.key = key
|
||||||
|
item.task = task
|
||||||
item.data = App[task.type].find( task.type_id )
|
item.data = App[task.type].find( task.type_id )
|
||||||
item_list.push item
|
item_list.push item
|
||||||
|
|
||||||
|
@ -34,9 +35,27 @@ class App.TaskWidget extends App.Controller
|
||||||
remove: (e) =>
|
remove: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
key = $(e.target).parent().data('id')
|
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 )
|
App.TaskManager.remove( key )
|
||||||
@render()
|
@render()
|
||||||
if _.isEmpty( App.TaskManager.all() )
|
|
||||||
|
# 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 '#'
|
@navigate '#'
|
||||||
|
|
||||||
App.Config.set( 'task', App.TaskWidget, 'Widgets' )
|
App.Config.set( 'task', App.TaskWidget, 'Widgets' )
|
||||||
|
|
|
@ -9,10 +9,10 @@ class App.TaskManager
|
||||||
_instance ?= new _Singleton
|
_instance ?= new _Singleton
|
||||||
_instance.all()
|
_instance.all()
|
||||||
|
|
||||||
@add: ( type, type_id, params ) ->
|
@add: ( type, type_id, callback, params ) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
_instance ?= new _Singleton
|
_instance ?= new _Singleton
|
||||||
_instance.add( type, type_id, params )
|
_instance.add( type, type_id, callback, params )
|
||||||
|
|
||||||
@remove: ( key ) ->
|
@remove: ( key ) ->
|
||||||
if _instance == undefined
|
if _instance == undefined
|
||||||
|
@ -34,26 +34,38 @@ class _Singleton extends Spine.Module
|
||||||
all: ->
|
all: ->
|
||||||
@tasks
|
@tasks
|
||||||
|
|
||||||
add: ( type, type_id, params ) ->
|
add: ( type, type_id, callback, params ) ->
|
||||||
for key, task of @tasks
|
for key, task of @tasks
|
||||||
if task.type is type && task.type_id is type_id
|
if task.type is type && task.type_id is type_id
|
||||||
$('#content').empty()
|
$('#content').empty()
|
||||||
$('.content_permanent').hide()
|
$('.content_permanent').hide()
|
||||||
$('#content_permanent_' + key ).show()
|
$('#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
|
return key
|
||||||
|
|
||||||
@task_count++
|
@task_count++
|
||||||
|
for task_key, task of @tasks
|
||||||
|
task.active = false
|
||||||
|
|
||||||
$('#content').empty()
|
$('#content').empty()
|
||||||
$('#content_permanent').append('<div id="content_permanent_' + @task_count + '" class="content_permanent"></div>')
|
$('#content_permanent').append('<div id="content_permanent_' + @task_count + '" class="content_permanent"></div>')
|
||||||
$('.content_permanent').hide()
|
$('.content_permanent').hide()
|
||||||
$('#content_permanent_' + @task_count ).show()
|
$('#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 =
|
task =
|
||||||
type: type
|
type: type
|
||||||
type_id: type_id
|
type_id: type_id
|
||||||
params: params
|
params: params
|
||||||
|
url: window.location.hash
|
||||||
worker: a
|
worker: a
|
||||||
|
active: true
|
||||||
@tasks[@task_count] = task
|
@tasks[@task_count] = task
|
||||||
App.Event.trigger 'ui:rerender'
|
App.Event.trigger 'ui:rerender'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="well taskbar">
|
<div class="well taskbar">
|
||||||
<% for item in @item_list: %>
|
<% 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 %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue