From e6e2fa1850e3e2167160093e32733bf8eee37f77 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 21 Oct 2013 21:00:58 +0200 Subject: [PATCH] Init version of user zoom. --- .../_application_controller_generic.js.coffee | 57 +++++++++ .../agent_ticket_history.js.coffee | 74 ------------ .../app/controllers/ticket_history.js.coffee | 20 ++++ .../app/controllers/ticket_zoom.js.coffee | 16 +-- .../app/controllers/user_history.js.coffee | 20 ++++ .../app/controllers/user_zoom.js.coffee | 112 ++++++++++++++++++ .../app/views/agent_ticket_create.jst.eco | 2 +- .../history.jst.eco} | 2 +- .../javascripts/app/views/ticket_zoom.jst.eco | 4 +- .../app/views/ticket_zoom/actions.jst.eco | 2 +- .../javascripts/app/views/user_zoom.jst.eco | 21 ++++ .../app/views/user_zoom/actions.jst.eco | 8 ++ .../app/views/user_zoom/widgets.jst.eco | 1 + app/assets/stylesheets/zzz.css | 8 +- app/controllers/users_controller.rb | 19 +++ config/routes/user.rb | 1 + 16 files changed, 276 insertions(+), 91 deletions(-) delete mode 100644 app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee create mode 100644 app/assets/javascripts/app/controllers/ticket_history.js.coffee create mode 100644 app/assets/javascripts/app/controllers/user_history.js.coffee create mode 100644 app/assets/javascripts/app/controllers/user_zoom.js.coffee rename app/assets/javascripts/app/views/{agent_ticket_history.jst.eco => generic/history.jst.eco} (99%) create mode 100644 app/assets/javascripts/app/views/user_zoom.jst.eco create mode 100644 app/assets/javascripts/app/views/user_zoom/actions.jst.eco create mode 100644 app/assets/javascripts/app/views/user_zoom/widgets.jst.eco 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 9efd77c9c..3a88da7c6 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -366,3 +366,60 @@ class App.ControllerNavSidbar extends App.ControllerContent @el.find('li').removeClass('active') @el.find('a[href="' + selectedItem.target + '"]').parent().addClass('active') +class App.GenericHistory extends App.ControllerModal + events: + 'click [data-type=sortorder]': 'sortorder', + 'click .cancel': 'modalHide', + 'click .close': 'modalHide', + + constructor: -> + super + + render: ( items, orderClass = '' ) -> + + for item in items + + item.link = '' + item.title = '???' + + if item.object is 'Ticket::Article' + item.object = 'Article' + article = App.TicketArticle.find( item.o_id ) + ticket = App.Ticket.find( article.ticket_id ) + item.title = article.subject || ticket.title + item.link = article.uiUrl() + + if App[item.object] + object = App[item.object].find( item.o_id ) + item.link = object.uiUrl() + item.title = object.displayName() + + item.created_by = App.User.find( item.created_by_id ) + + # set cache + @historyListCache = items + + @html App.view('generic/history')( + items: items + orderClass: orderClass + + @historyListCache + ) + + @modalShow() + + # enable user popups + @userPopups() + + # show frontend times + @delay( @frontendTimeUpdate, 300, 'ui-time-update' ) + + sortorder: (e) -> + e.preventDefault() + isDown = @el.find('[data-type="sortorder"]').hasClass('down') + + if isDown + @render( @historyListCache, 'up' ) + else + @render( @historyListCache.reverse(), 'down' ) + diff --git a/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee deleted file mode 100644 index 1d2767d67..000000000 --- a/app/assets/javascripts/app/controllers/agent_ticket_history.js.coffee +++ /dev/null @@ -1,74 +0,0 @@ -class App.TicketHistory extends App.ControllerModal - events: - 'click [data-type=sortorder]': 'sortorder', - 'click .cancel': 'modalHide', - 'click .close': 'modalHide', - - constructor: -> - super - @fetch(@ticket_id) - - fetch: (@ticket_id) -> - - # get data - @ajax( - id: 'ticket_history', - type: 'GET', - url: @apiPath + '/ticket_history/' + ticket_id, - success: (data, status, xhr) => - - # load collections - App.Event.trigger 'loadAssets', data.assets - - - # render page - @render(data.history) - ) - - render: ( items, orderClass = '' ) -> - - for item in items - - item.link = '' - item.title = '???' - - if item.object is 'Ticket::Article' - item.object = 'Article' - article = App.TicketArticle.find( item.o_id ) - ticket = App.Ticket.find( article.ticket_id ) - item.title = article.subject || ticket.title - item.link = article.uiUrl() - - if App[item.object] - object = App[item.object].find( item.o_id ) - item.link = object.uiUrl() - item.title = object.displayName() - - item.created_by = App.User.find( item.created_by_id ) - - # set cache - @historyListCache = items - - @html App.view('agent_ticket_history')( - items: items - orderClass: orderClass - - @historyListCache - ) - - @modalShow() - - # enable user popups - @userPopups() - - # show frontend times - @delay( @frontendTimeUpdate, 300, 'ui-time-update' ) - - sortorder: (e) -> - e.preventDefault() - isDown = @el.find('[data-type="sortorder"]').hasClass('down') - - if isDown - @render( @historyListCache, 'up' ) - else - @render( @historyListCache.reverse(), 'down' ) diff --git a/app/assets/javascripts/app/controllers/ticket_history.js.coffee b/app/assets/javascripts/app/controllers/ticket_history.js.coffee new file mode 100644 index 000000000..216cfeffd --- /dev/null +++ b/app/assets/javascripts/app/controllers/ticket_history.js.coffee @@ -0,0 +1,20 @@ +class App.TicketHistory extends App.GenericHistory + constructor: -> + super + @fetch() + + fetch: -> + + # get data + @ajax( + id: 'ticket_history', + type: 'GET', + url: @apiPath + '/ticket_history/' + @ticket_id, + success: (data, status, xhr) => + + # load collections + App.Event.trigger 'loadAssets', data.assets + + # render page + @render(data.history) + ) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 5ddbd9ee4..99f326405 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -140,7 +140,7 @@ class App.TicketZoom extends App.Controller @frontendTimeUpdate() @TicketTitle() - @TicketWidgets() + @Widgets() @TicketAction() @ArticleView() @@ -196,20 +196,20 @@ class App.TicketZoom extends App.Controller ui: @ ) - TicketWidgets: => + Widgets: => # show ticket action row - new TicketWidgets( + new Widgets( ticket: @ticket task_key: @task_key - el: @el.find('.ticket-widgets') + el: @el.find('.widgets') ui: @ ) TicketAction: => # start action controller if !@isRole('Customer') - new TicketActionRow( - el: @el.find('.ticket-action') + new ActionRow( + el: @el.find('.action') ticket: @ticket ui: @ ) @@ -271,7 +271,7 @@ class TicketInfo extends App.ControllerDrox object: @ticket ) -class TicketWidgets extends App.Controller +class Widgets extends App.Controller constructor: -> super @render() @@ -779,7 +779,7 @@ class Article extends App.Controller for attachment in @article.attachments attachment.size = @humanFileSize(attachment.size) -class TicketActionRow extends App.Controller +class ActionRow extends App.Controller events: 'click [data-type=history]': 'history_dialog' 'click [data-type=merge]': 'merge_dialog' diff --git a/app/assets/javascripts/app/controllers/user_history.js.coffee b/app/assets/javascripts/app/controllers/user_history.js.coffee new file mode 100644 index 000000000..625b92580 --- /dev/null +++ b/app/assets/javascripts/app/controllers/user_history.js.coffee @@ -0,0 +1,20 @@ +class App.UserHistory extends App.GenericHistory + constructor: -> + super + @fetch() + + fetch: -> + + # get data + @ajax( + id: 'user_history', + type: 'GET', + url: @apiPath + '/users/history/' + @user_id, + success: (data, status, xhr) => + + # load collections + App.Event.trigger 'loadAssets', data.assets + + # render page + @render(data.history) + ) diff --git a/app/assets/javascripts/app/controllers/user_zoom.js.coffee b/app/assets/javascripts/app/controllers/user_zoom.js.coffee new file mode 100644 index 000000000..3a008bbf0 --- /dev/null +++ b/app/assets/javascripts/app/controllers/user_zoom.js.coffee @@ -0,0 +1,112 @@ +class App.UserZoom extends App.Controller + constructor: (params) -> + super + + # check authentication + return if !@authenticate() + + @navupdate '#' + + start = (user) => + @user = user + @render() + + App.User.retrieve( @user_id, start ) + + meta: => + meta = + url: @url() + id: @user_id + if @user + meta.head = @user.displayName() + meta.title = @user.displayName() + meta + + url: => + '#user/zoom/' + @user_id + + activate: => + @navupdate '#' + @el.find('textarea').elastic() + + changed: => + formCurrent = @formParam( @el.find('.ticket-update') ) + diff = difference( @formDefault, formCurrent ) + return false if !diff || _.isEmpty( diff ) + return true + + release: => + # nothing + + render: => + # update taskbar with new meta data + App.Event.trigger 'task:render' + + @html App.view('user_zoom')( + user: @user + ) + + # start action controller + new ActionRow( + el: @el.find('.action') + user: @user + ui: @ + ) + + new Widgets( + el: @el.find('.widgets') + user: @user + ui: @ + ) + + +class Widgets extends App.Controller + constructor: -> + super + @render() + + render: -> + + @html App.view('user_zoom/widgets')() + + new App.WidgetUser( + el: @el.find('.user_info') + user_id: @user.id + ) + +class ActionRow extends App.Controller + events: + 'click [data-type=history]': 'history_dialog' + 'click [data-type=merge]': 'merge_dialog' + + constructor: -> + super + @render() + + render: -> + @html App.view('user_zoom/actions')() + + history_dialog: (e) -> + e.preventDefault() + new App.UserHistory( user_id: @user.id ) + + merge_dialog: (e) -> + e.preventDefault() + new App.TicketMerge( ticket_id: @ticket.id, task_key: @ui.task_key ) + + customer_dialog: (e) -> + e.preventDefault() + new App.TicketCustomer( ticket_id: @ticket.id, ui: @ui ) + + +class Router extends App.ControllerPermanent + constructor: (params) -> + super + + # cleanup params + clean_params = + user_id: params.user_id + + App.TaskManager.add( 'User-' + @user_id, 'UserZoom', clean_params ) + +App.Config.set( 'user/zoom/:user_id', Router, 'Routes' ) diff --git a/app/assets/javascripts/app/views/agent_ticket_create.jst.eco b/app/assets/javascripts/app/views/agent_ticket_create.jst.eco index 70cd905b2..2462ec549 100644 --- a/app/assets/javascripts/app/views/agent_ticket_create.jst.eco +++ b/app/assets/javascripts/app/views/agent_ticket_create.jst.eco @@ -1,6 +1,6 @@
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/ticket_zoom.jst.eco b/app/assets/javascripts/app/views/ticket_zoom.jst.eco index fa3f2d96d..cd39103f4 100644 --- a/app/assets/javascripts/app/views/ticket_zoom.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom.jst.eco @@ -1,7 +1,7 @@
diff --git a/app/assets/javascripts/app/views/ticket_zoom/actions.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/actions.jst.eco index bb6f9bd08..7106c41ee 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/actions.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/actions.jst.eco @@ -1,5 +1,5 @@
-