diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 6705389e6..48258cd0a 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -309,6 +309,17 @@ class App.Controller extends Spine.Controller ws_send: (data) -> App.Event.trigger( 'ws:send', JSON.stringify(data) ) +class App.ControllerPermanent extends App.Controller + constructor: -> + super + $('#content_permanent').show() + @el.find('#content').empty() + +class App.ControllerContent extends App.Controller + constructor: -> + super + $('#content_permanent').hide() + class App.ControllerModal extends App.Controller className: 'modal hide fade', tag: 'div', diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index 669ad9d83..d1a22dd8a 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -106,7 +106,7 @@ class App.ControllerGenericEdit extends App.ControllerModal ui.modalHide() ) -class App.ControllerGenericIndex extends App.Controller +class App.ControllerGenericIndex extends App.ControllerContent events: 'click [data-type=edit]': 'edit' 'click [data-type=destroy]': 'destroy' @@ -195,7 +195,7 @@ class App.ControllerGenericIndex extends App.Controller genericObject: @genericObject ) -class App.ControllerLevel2 extends App.Controller +class App.ControllerLevel2 extends App.ControllerContent events: 'click [data-toggle="tabnav"]': 'toggle', diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index b6adab31e..996511de4 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent events: 'click .customer_new': 'userNew' 'submit form': 'submit' diff --git a/app/assets/javascripts/app/controllers/agent_ticket_view.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_view.js.coffee index 109504f1e..aff38b14e 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_view.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_view.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent events: 'click [data-type=edit]': 'zoom' 'click [data-type=settings]': 'settings' diff --git a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee index 294ab2377..6bc6b8711 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class TicketZoom extends App.Controller events: 'click .submit': 'update' 'click [data-type=reply]': 'reply' @@ -34,7 +32,11 @@ class Index extends App.Controller @load(cache) update = => @fetch( @ticket_id, false) - @interval( update, 30000, 'zoom_check', 'page' ) + @interval( update, 30000, @key, 'ticket_zoom' ) + + release: => + @clearInterval( @key, 'ticket_zoom' ) + @el.remove() fetch: (ticket_id, force) -> @@ -143,7 +145,7 @@ class Index extends App.Controller ) new App.ControllerForm( - el: @el.find('#form-ticket-update') + el: @el.find('[data-id="form-ticket-update"]') form_id: @form_id model: configure_attributes: @configure_attributes_ticket @@ -153,7 +155,7 @@ class Index extends App.Controller ) new App.ControllerForm( - el: @el.find('#form-article-update') + el: @el.find('[data-id="form-article-update"]') form_id: @form_id model: configure_attributes: @configure_attributes_article @@ -184,7 +186,7 @@ class Index extends App.Controller # start customer info controller if !@isRole('Customer') new App.UserInfo( - el: @el.find('#customer_info') + el: @el.find('[data-id="customer_info"]') user_id: @ticket.customer_id ticket: @ticket ) @@ -192,7 +194,7 @@ class Index extends App.Controller # start action controller if !@isRole('Customer') new TicketActionRow( - el: @el.find('#action_info') + el: @el.find('[data-id="action_info"]') ticket: @ticket zoom: @ ) @@ -200,7 +202,7 @@ class Index extends App.Controller # start tag controller if !@isRole('Customer') new App.TagWidget( - el: @el.find('#tag_info') + el: @el.find('[data-id="tag_info"]') object_type: 'Ticket' object: @ticket ) @@ -208,7 +210,7 @@ class Index extends App.Controller # start link info controller if !@isRole('Customer') new App.LinkInfo( - el: @el.find('#link_info') + el: @el.find('[data-id="link_info"]') object_type: 'Ticket' object: @ticket ) @@ -216,7 +218,7 @@ class Index extends App.Controller # show text module UI if !@isRole('Customer') new App.TextModuleUI( - el: @el.find('#text_module') + el: @el.find('[data-id="text_module"]') data: ticket: @ticket ) @@ -580,6 +582,12 @@ class TicketActionRow extends App.Controller e.preventDefault() new App.TicketCustomer( ticket_id: @ticket.id, zoom: @zoom ) -App.Config.set( 'ticket/zoom/:ticket_id', Index, 'Routes' ) -App.Config.set( 'ticket/zoom/:ticket_id/nav/:nav', Index, 'Routes' ) -App.Config.set( 'ticket/zoom/:ticket_id/:article_id', Index, 'Routes' ) \ No newline at end of file +class TicketZoomRouter extends App.ControllerPermanent + constructor: (params) -> + super + @log 'zoom router', params + App.TaskManager.add( 'Ticket', @ticket_id, { callback: TicketZoom } ) + +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/:article_id', TicketZoomRouter, 'Routes' ) \ No newline at end of file diff --git a/app/assets/javascripts/app/controllers/channel.js.coffee b/app/assets/javascripts/app/controllers/channel.js.coffee index 31b541e7d..fbd779725 100644 --- a/app/assets/javascripts/app/controllers/channel.js.coffee +++ b/app/assets/javascripts/app/controllers/channel.js.coffee @@ -1,5 +1,3 @@ -$ = jQuery.sub() - class Index extends App.ControllerLevel2 # toggleable: true toggleable: false diff --git a/app/assets/javascripts/app/controllers/chat_widget.js.coffee b/app/assets/javascripts/app/controllers/chat_widget.js.coffee index f9d9b6d98..a55596606 100644 --- a/app/assets/javascripts/app/controllers/chat_widget.js.coffee +++ b/app/assets/javascripts/app/controllers/chat_widget.js.coffee @@ -1,5 +1,3 @@ -$ = jQuery.sub() - class App.ChatWidget extends App.Controller events: 'submit #chat_form': 'submitMessage' diff --git a/app/assets/javascripts/app/controllers/content_permanent_widget.js.coffee b/app/assets/javascripts/app/controllers/content_permanent_widget.js.coffee new file mode 100644 index 000000000..d7c30f0fe --- /dev/null +++ b/app/assets/javascripts/app/controllers/content_permanent_widget.js.coffee @@ -0,0 +1,7 @@ +class App.ContentPermanentWidget extends App.ControllerPermanent + className: 'container aaa' + + constructor: -> + super + +App.Config.set( 'content_permanent', App.ContentPermanentWidget, 'Widgets' ) diff --git a/app/assets/javascripts/app/controllers/customer_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/customer_ticket_create.js.coffee index c4fb49d87..ad2e0afb4 100644 --- a/app/assets/javascripts/app/controllers/customer_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/customer_ticket_create.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent events: 'submit form': 'submit', 'click .submit': 'submit', @@ -112,7 +110,6 @@ class Index extends App.Controller # generate form configure_attributes = [ -# { name: 'customer_id', display: 'Customer', tag: 'autocompletion', type: 'text', limit: 100, null: false, relation: 'User', class: 'span7', autocapitalize: false, help: 'Select the customer of the Ticket or create one.', link: '»', callback: @userInfo }, { name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, filter: groupFilter, nulloption: true, relation: 'Group', default: defaults['group_id'], class: 'span7', }, # { name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, null: true, filter: @edit_form, nulloption: true, relation: 'User', default: defaults['owner_id'], class: 'span7', }, { name: 'subject', display: 'Subject', tag: 'input', type: 'text', limit: 100, null: false, default: defaults['subject'], class: 'span7', }, @@ -120,7 +117,7 @@ class Index extends App.Controller # { name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: false, filter: @edit_form, relation: 'TicketState', default: defaults['ticket_state_id'], translate: true, class: 'medium' }, # { name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, filter: @edit_form, relation: 'TicketPriority', default: defaults['ticket_priority_id'], translate: true, class: 'medium' }, ] - @html App.view('agent_ticket_create')( head: 'New Ticket' ) + @html App.view('customer_ticket_create')( head: 'New Ticket' ) new App.ControllerForm( el: @el.find('#form_create') @@ -146,7 +143,6 @@ class Index extends App.Controller # get params params = @formParam(e.target) - @log 'CustomerTicketCreate', 'notice', 'params', params # set customer id params.customer_id = @Session.get('id') @@ -183,7 +179,6 @@ class Index extends App.Controller ticket_article_sender_id: sender.id form_id: @form_id } -# console.log('params', params) object.load(params) diff --git a/app/assets/javascripts/app/controllers/dashboard.js.coffee b/app/assets/javascripts/app/controllers/dashboard.js.coffee index 532d9f4f4..abd74d4b3 100644 --- a/app/assets/javascripts/app/controllers/dashboard.js.coffee +++ b/app/assets/javascripts/app/controllers/dashboard.js.coffee @@ -1,4 +1,4 @@ -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super diff --git a/app/assets/javascripts/app/controllers/groups.js.coffee b/app/assets/javascripts/app/controllers/groups.js.coffee index a827e2caa..ab7a44436 100644 --- a/app/assets/javascripts/app/controllers/groups.js.coffee +++ b/app/assets/javascripts/app/controllers/groups.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super diff --git a/app/assets/javascripts/app/controllers/link_info_widget.js.coffee b/app/assets/javascripts/app/controllers/link_info_widget.js.coffee index 42aec038e..c6edce44e 100644 --- a/app/assets/javascripts/app/controllers/link_info_widget.js.coffee +++ b/app/assets/javascripts/app/controllers/link_info_widget.js.coffee @@ -1,5 +1,3 @@ -$ = jQuery.sub() - class App.LinkInfo extends App.Controller events: 'click [data-type=add]': 'add', diff --git a/app/assets/javascripts/app/controllers/login.js.coffee b/app/assets/javascripts/app/controllers/login.js.coffee index 7f03f9b76..1cd55c6dd 100644 --- a/app/assets/javascripts/app/controllers/login.js.coffee +++ b/app/assets/javascripts/app/controllers/login.js.coffee @@ -1,4 +1,4 @@ -class Index extends App.Controller +class Index extends App.ControllerContent events: 'submit #login': 'login', diff --git a/app/assets/javascripts/app/controllers/logout.js.coffee b/app/assets/javascripts/app/controllers/logout.js.coffee index f5adda8e9..63baa4182 100644 --- a/app/assets/javascripts/app/controllers/logout.js.coffee +++ b/app/assets/javascripts/app/controllers/logout.js.coffee @@ -1,4 +1,4 @@ -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super @signout() diff --git a/app/assets/javascripts/app/controllers/network.js.coffee b/app/assets/javascripts/app/controllers/network.js.coffee index b41676d0e..a574f089d 100644 --- a/app/assets/javascripts/app/controllers/network.js.coffee +++ b/app/assets/javascripts/app/controllers/network.js.coffee @@ -6,7 +6,7 @@ $.fn.item = -> elementID or= $(@).parents('[data-id]').data('id') Note.find(elementID) -class Index extends App.Controller +class Index extends App.ControllerContent events: 'click [data-type=network-new]': 'network_new' 'click [data-type=network-edit]': 'network_edit' diff --git a/app/assets/javascripts/app/controllers/organizations.js.coffee b/app/assets/javascripts/app/controllers/organizations.js.coffee index 79496f313..976c19ed4 100644 --- a/app/assets/javascripts/app/controllers/organizations.js.coffee +++ b/app/assets/javascripts/app/controllers/organizations.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super diff --git a/app/assets/javascripts/app/controllers/overview.js.coffee b/app/assets/javascripts/app/controllers/overview.js.coffee index 1d9993ccd..ed794fa39 100644 --- a/app/assets/javascripts/app/controllers/overview.js.coffee +++ b/app/assets/javascripts/app/controllers/overview.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super diff --git a/app/assets/javascripts/app/controllers/package.js.coffee b/app/assets/javascripts/app/controllers/package.js.coffee index bc174fab8..50b8ceb0b 100644 --- a/app/assets/javascripts/app/controllers/package.js.coffee +++ b/app/assets/javascripts/app/controllers/package.js.coffee @@ -1,4 +1,4 @@ -class Index extends App.Controller +class Index extends App.ControllerContent events: 'click .action': 'action' diff --git a/app/assets/javascripts/app/controllers/reset_password.js.coffee b/app/assets/javascripts/app/controllers/reset_password.js.coffee index 03b9dd2e2..e5dc751f9 100644 --- a/app/assets/javascripts/app/controllers/reset_password.js.coffee +++ b/app/assets/javascripts/app/controllers/reset_password.js.coffee @@ -1,4 +1,4 @@ -class Index extends App.Controller +class Index extends App.ControllerContent className: 'container' events: @@ -66,7 +66,7 @@ class Index extends App.Controller App.Config.set( 'reset_password', Index, 'Routes' ) -class Verify extends App.Controller +class Verify extends App.ControllerContent className: 'container' events: diff --git a/app/assets/javascripts/app/controllers/scheduler.js.coffee b/app/assets/javascripts/app/controllers/scheduler.js.coffee index 2c93da79b..356554ae1 100644 --- a/app/assets/javascripts/app/controllers/scheduler.js.coffee +++ b/app/assets/javascripts/app/controllers/scheduler.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super diff --git a/app/assets/javascripts/app/controllers/signup.js.coffee b/app/assets/javascripts/app/controllers/signup.js.coffee index 56ce68d15..4098e5286 100644 --- a/app/assets/javascripts/app/controllers/signup.js.coffee +++ b/app/assets/javascripts/app/controllers/signup.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent className: 'container signup' events: diff --git a/app/assets/javascripts/app/controllers/sla.js.coffee b/app/assets/javascripts/app/controllers/sla.js.coffee index acefecbdf..333eabe93 100644 --- a/app/assets/javascripts/app/controllers/sla.js.coffee +++ b/app/assets/javascripts/app/controllers/sla.js.coffee @@ -1,4 +1,4 @@ -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super diff --git a/app/assets/javascripts/app/controllers/task_widget.js.coffee b/app/assets/javascripts/app/controllers/task_widget.js.coffee new file mode 100644 index 000000000..eed4a12dc --- /dev/null +++ b/app/assets/javascripts/app/controllers/task_widget.js.coffee @@ -0,0 +1,42 @@ +class App.TaskWidget extends App.Controller + events: + 'click [data-type="close"]': 'remove' + + constructor: -> + super + @render() + + # rerender view + App.Event.bind 'ui:rerender', (data) => + @render() + + # rebuild chat widget + App.Event.bind 'auth', (user) => + App.TaskManager.reset() + @el.html('') + + render: -> + + return if _.isEmpty( @Session.all() ) + + tasks = App.TaskManager.all() + item_list = [] + for key, task of tasks + item = {} + item.key = key + item.data = App[task.type].find( task.type_id ) + item_list.push item + + @html App.view('task_widget')( + item_list: item_list + ) + + remove: (e) => + e.preventDefault() + key = $(e.target).parent().data('id') + App.TaskManager.remove( key ) + @render() + if _.isEmpty( App.TaskManager.all() ) + @navigate '#' + +App.Config.set( 'task', App.TaskWidget, 'Widgets' ) diff --git a/app/assets/javascripts/app/controllers/text_module.js.coffee b/app/assets/javascripts/app/controllers/text_module.js.coffee index 52b15b64e..8ebc17bad 100644 --- a/app/assets/javascripts/app/controllers/text_module.js.coffee +++ b/app/assets/javascripts/app/controllers/text_module.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super diff --git a/app/assets/javascripts/app/controllers/trigger.js.coffee b/app/assets/javascripts/app/controllers/trigger.js.coffee index 680d03bf5..a3266e683 100644 --- a/app/assets/javascripts/app/controllers/trigger.js.coffee +++ b/app/assets/javascripts/app/controllers/trigger.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super diff --git a/app/assets/javascripts/app/controllers/users.js.coffee b/app/assets/javascripts/app/controllers/users.js.coffee index 481cdece6..b6754b747 100644 --- a/app/assets/javascripts/app/controllers/users.js.coffee +++ b/app/assets/javascripts/app/controllers/users.js.coffee @@ -1,6 +1,4 @@ -$ = jQuery.sub() - -class Index extends App.Controller +class Index extends App.ControllerContent constructor: -> super @@ -30,5 +28,4 @@ class Index extends App.Controller ) App.Config.set( 'users', Index, 'Routes' ) - App.Config.set( 'User', { prio: 1000, parent: '#admin', name: 'Users', target: '#users', role: ['Admin'] }, 'NavBar' ) diff --git a/app/assets/javascripts/app/lib/app_post/auth.js.coffee b/app/assets/javascripts/app/lib/app_post/auth.js.coffee index d6cf4c855..874c81992 100644 --- a/app/assets/javascripts/app/lib/app_post/auth.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/auth.js.coffee @@ -113,12 +113,19 @@ class App.Auth @_logout: (data) -> App.Log.log 'Auth', 'notice', '_logout' + # empty session + App.Session.init() + # update websocket auth info App.WebSocket.auth() # clear store App.Store.clear('all') + # rebuild navbar + App.Event.trigger( 'auth' ) + App.Event.trigger( 'ui:rerender' ) + @_loginError: (xhr, statusText, error) -> App.Log.log 'Auth', 'notice', '_loginError:error' @@ -129,4 +136,8 @@ class App.Auth App.WebSocket.auth() # clear store - App.Store.clear('all') \ No newline at end of file + App.Store.clear('all') + + # rebuild navbar + App.Event.trigger( 'auth' ) + App.Event.trigger( 'ui:rerender' ) diff --git a/app/assets/javascripts/app/lib/app_post/i18n.js.coffee b/app/assets/javascripts/app/lib/app_post/i18n.js.coffee index 91bdc3655..8779f32e6 100644 --- a/app/assets/javascripts/app/lib/app_post/i18n.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/i18n.js.coffee @@ -1,5 +1,3 @@ -$ = jQuery.sub() - class App.i18n _instance = undefined diff --git a/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee b/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee index 4e9542606..a8202256f 100644 --- a/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/interface_handle.js.coffee @@ -1,4 +1,3 @@ - class App.Run extends App.Controller constructor: -> super diff --git a/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee new file mode 100644 index 000000000..5ca664133 --- /dev/null +++ b/app/assets/javascripts/app/lib/app_post/task_manager.js.coffee @@ -0,0 +1,72 @@ +class App.TaskManager + _instance = undefined + + @init: -> + _instance ?= new _Singleton + + @all: -> + if _instance == undefined + _instance ?= new _Singleton + _instance.all() + + @add: ( type, type_id, params ) -> + if _instance == undefined + _instance ?= new _Singleton + _instance.add( type, type_id, params ) + + @remove: ( key ) -> + if _instance == undefined + _instance ?= new _Singleton + _instance.remove( key ) + + @reset: -> + if _instance == undefined + _instance ?= new _Singleton + _instance.reset() + +class _Singleton extends Spine.Module + @include App.Log + + constructor: -> + @tasks = {} + @task_count = 0 + + all: -> + @tasks + + add: ( type, type_id, 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() + return key + + @task_count++ + + $('#content').empty() + $('#content_permanent').append('
') + $('.content_permanent').hide() + $('#content_permanent_' + @task_count ).show() + a = new params.callback( el: $('#content_permanent_' + @task_count ), ticket_id: type_id ) + task = + type: type + type_id: type_id + params: params + worker: a + @tasks[@task_count] = task + App.Event.trigger 'ui:rerender' + + @task_count + + remove: ( key ) => + if @tasks[key] + console.log('rrrelease', @tasks[key], @tasks[key].worker) + @tasks[key].worker.release() + delete @tasks[key] + App.Event.trigger 'ui:rerender' + + reset: => + @tasks = {} + App.Event.trigger 'ui:rerender' + diff --git a/app/assets/javascripts/app/views/agent_ticket_zoom.jst.eco b/app/assets/javascripts/app/views/agent_ticket_zoom.jst.eco index ae1fc9e6d..1ef1b9baa 100644 --- a/app/assets/javascripts/app/views/agent_ticket_zoom.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_zoom.jst.eco @@ -83,8 +83,8 @@ @@ -93,11 +93,11 @@