diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index 48d0243b8..f364256db 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -463,7 +463,7 @@ class App.Controller extends Spine.Controller fetch = (params) => @ajax( type: 'GET' - url: @Config.get('api_path') + '/ticket_customer' + url: "#{@Config.get('api_path')}/ticket_customer" data: customer_id: params.user_id processData: true diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee index b31c72acf..5358a2eac 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee @@ -768,6 +768,7 @@ class App.CollectionController extends App.Controller sortBy: 'name' order: 'ASC', insertPosition: 'after' + globalRerender: true constructor: -> @events = @constructor.events unless @events @@ -788,10 +789,11 @@ class App.CollectionController extends App.Controller @subscribeId = App[@model].subscribe(@collectionSync) # render on generic ui call - @bind('ui:rerender', => - @queue.push ['renderAll'] - @uIRunner() - ) + if @globalRerender + @bind('ui:rerender', => + @queue.push ['renderAll'] + @uIRunner() + ) # render on login @bind('auth:login', => @@ -1074,6 +1076,7 @@ class App.CollectionController extends App.Controller class App.ObserverController extends App.Controller model: 'Ticket' template: 'ticket_zoom/title' + globalRerender: true ### observe: @@ -1096,11 +1099,13 @@ class App.ObserverController extends App.Controller @maybeRender(object) # rerender, e. g. on language change - @bind('ui:rerender', => - @lastAttributres = undefined - object = App[@model].fullLocal(@object_id) - @maybeRender(object) - ) + if @globalRerender + @bind('ui:rerender', => + console.log('REREN') + @lastAttributres = undefined + object = App[@model].fullLocal(@object_id) + @maybeRender(object) + ) subscribe: (object) => @maybeRender(object) diff --git a/app/assets/javascripts/app/controllers/organization_profile.coffee b/app/assets/javascripts/app/controllers/organization_profile.coffee index 21642f002..2c4f25f15 100644 --- a/app/assets/javascripts/app/controllers/organization_profile.coffee +++ b/app/assets/javascripts/app/controllers/organization_profile.coffee @@ -10,11 +10,6 @@ class App.OrganizationProfile extends App.Controller # fetch new data if needed App.Organization.full(@organization_id, @render) - # rerender view, e. g. on langauge change - @bind 'ui:rerender', => - return if !@authenticate(true) - @render(App.Organization.fullLocal(@organization_id)) - meta: => meta = url: @url() @@ -48,6 +43,11 @@ class App.OrganizationProfile extends App.Controller organization: organization )) + new ActionRow( + el: elLocal.find('.js-action') + object_id: organization.id + ) + new Object( el: elLocal.find('.js-object-container') object_id: organization.id @@ -65,6 +65,50 @@ class App.OrganizationProfile extends App.Controller genericObject: organization ) +class ActionRow extends App.ObserverController + model: 'Organization' + observe: + member_ids: true + + render: (organization) => + + # start action controller + showHistory = -> + new App.OrganizationHistory( + organization_id: organization.id + container: @el.closest('.content') + ) + + editOrganization = => + new App.ControllerGenericEdit( + id: organization.id + genericObject: 'Organization' + screen: 'edit' + pageData: + title: 'Organizations' + object: 'Organization' + objects: 'Organizations' + container: @el.closest('.content') + ) + + actions = [ + { + name: 'edit' + title: 'Edit' + callback: editOrganization + } + { + name: 'history' + title: 'History' + callback: showHistory + } + ] + + new App.ActionRow( + el: @el + items: actions + ) + class Object extends App.ObserverController model: 'Organization' observeNot: @@ -124,43 +168,6 @@ class Object extends App.ObserverController members.push el @$('.js-userList').html(members) - # start action controller - showHistory = -> - new App.OrganizationHistory( - organization_id: organization.id - container: @el.closest('.content') - ) - - editOrganization = => - new App.ControllerGenericEdit( - id: organization.id - genericObject: 'Organization' - screen: 'edit' - pageData: - title: 'Organizations' - object: 'Organization' - objects: 'Organizations' - container: @el.closest('.content') - ) - - actions = [ - { - name: 'edit' - title: 'Edit' - callback: editOrganization - } - { - name: 'history' - title: 'History' - callback: showHistory - } - ] - - new App.ActionRow( - el: @el.find('.js-action') - items: actions - ) - update: (e) => name = $(e.target).attr('data-name') value = $(e.target).html() @@ -179,6 +186,7 @@ class Member extends App.ObserverController lastname: true login: true email: true + globalRerender: false render: (user) => @html App.view('organization_profile/member')( diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index a4403010e..5e2c8faf7 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -53,17 +53,10 @@ class App.TicketZoom extends App.Controller @delay(update, 1200, "ticket-zoom-#{@ticket_id}") ) - # rerender view, e. g. on langauge change - @bind('ui:rerender', => - @fetch(true) - ) - - fetchStart: (force) => - if !force && @fetchIsRunning + fetchStart: => + if @fetchIsRunning @fetchIsRunningAgain = true return false - if force - @fetchIsRunningAgain = false @fetchIsRunning = true true @@ -73,9 +66,9 @@ class App.TicketZoom extends App.Controller @fetchIsRunningAgain = false @fetch() - fetch: (force) => + fetch: => return if !@Session.get() - return if !@fetchStart(force) + return if !@fetchStart() # get data @ajax( @@ -88,7 +81,7 @@ class App.TicketZoom extends App.Controller # check if ticket has changed newTicketRaw = data.assets.Ticket[@ticket_id] - if @ticketUpdatedAtLastCall && !force + if @ticketUpdatedAtLastCall # return if ticket hasnt changed return if @ticketUpdatedAtLastCall is newTicketRaw.updated_at diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee index c6544ac8d..8e967c390 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee @@ -244,7 +244,7 @@ class ArticleViewItem extends App.ObserverController metaTop = article.find('.article-content-meta.top') metaBottom = article.find('.article-content-meta.bottom') - if @elementContainsSelection( article.get(0) ) + if @elementContainsSelection(article.get(0)) @stopPropagation(e) return false diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/customer_avatar.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/customer_avatar.coffee index f9a632078..1b1e7b07e 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/customer_avatar.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/customer_avatar.coffee @@ -2,6 +2,7 @@ class App.TicketCustomerAvatar extends App.ObserverController model: 'Ticket' observe: customer_id: true + globalRerender: false render: (ticket) => new App.WidgetAvatar( diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar.coffee index bfcccce30..b1d734ed2 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar.coffee @@ -3,6 +3,7 @@ class Edit extends App.ObserverController observeNot: created_at: true updated_at: true + globalRerender: false render: (ticket, diff) => defaults = ticket.attributes() diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee index 5c45aa4a0..3840243c4 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee @@ -3,6 +3,7 @@ class App.TicketZoomTitle extends App.ObserverController template: 'ticket_zoom/title' observe: title: true + globalRerender: false events: 'blur .js-objectTitle': 'update' diff --git a/app/assets/javascripts/app/controllers/user_profile.coffee b/app/assets/javascripts/app/controllers/user_profile.coffee index cb8a9d422..72cffa4df 100644 --- a/app/assets/javascripts/app/controllers/user_profile.coffee +++ b/app/assets/javascripts/app/controllers/user_profile.coffee @@ -10,11 +10,6 @@ class App.UserProfile extends App.Controller # fetch new data if needed App.User.full(@user_id, @render) - # rerender view, e. g. on langauge change - @bind 'ui:rerender', => - return if !@authenticate(true) - @render(App.User.fullLocal(@user_id)) - meta: => meta = url: @url() @@ -48,6 +43,11 @@ class App.UserProfile extends App.Controller user: user )) + new ActionRow( + el: elLocal.find('.js-action') + object_id: user.id + ) + new Object( el: elLocal.find('.js-object-container') object_id: user.id @@ -65,6 +65,50 @@ class App.UserProfile extends App.Controller genericObject: user ) +class ActionRow extends App.ObserverController + model: 'User' + observe: + organization_id: true + + render: (user) => + + # start action controller + showHistory = => + new App.UserHistory( + user_id: user.id + container: @el.closest('.content') + ) + + editUser = => + new App.ControllerGenericEdit( + id: user.id + genericObject: 'User' + screen: 'edit' + pageData: + title: 'Users' + object: 'User' + objects: 'Users' + container: @el.closest('.content') + ) + + actions = [ + { + name: 'edit' + title: 'Edit' + callback: editUser + } + { + name: 'history' + title: 'History' + callback: showHistory + } + ] + + new App.ActionRow( + el: @el + items: actions + ) + class Object extends App.ObserverController model: 'User' observeNot: @@ -122,43 +166,6 @@ class Object extends App.ObserverController el: @$('.js-organization') ) - # start action controller - showHistory = => - new App.UserHistory( - user_id: user.id - container: @el.closest('.content') - ) - - editUser = => - new App.ControllerGenericEdit( - id: user.id - genericObject: 'User' - screen: 'edit' - pageData: - title: 'Users' - object: 'User' - objects: 'Users' - container: @el.closest('.content') - ) - - actions = [ - { - name: 'edit' - title: 'Edit' - callback: editUser - } - { - name: 'history' - title: 'History' - callback: showHistory - } - ] - - new App.ActionRow( - el: @el.find('.js-action') - items: actions - ) - update: (e) => name = $(e.target).attr('data-name') value = $(e.target).html() diff --git a/app/assets/javascripts/app/controllers/widget/avatar.coffee b/app/assets/javascripts/app/controllers/widget/avatar.coffee index 5111a4ed9..077619525 100644 --- a/app/assets/javascripts/app/controllers/widget/avatar.coffee +++ b/app/assets/javascripts/app/controllers/widget/avatar.coffee @@ -6,6 +6,7 @@ class App.WidgetAvatar extends App.ObserverController lastname: true email: true image: true + globalRerender: false render: (user) => @html(user.avatar @size, @position, undefined, false, false, @type) diff --git a/app/assets/javascripts/app/controllers/widget/online_notification.coffee b/app/assets/javascripts/app/controllers/widget/online_notification.coffee index 26f274adb..2a43371cf 100644 --- a/app/assets/javascripts/app/controllers/widget/online_notification.coffee +++ b/app/assets/javascripts/app/controllers/widget/online_notification.coffee @@ -51,6 +51,12 @@ class App.OnlineNotificationWidget extends App.Controller @createContainer() + # rerender view, e. g. on langauge change + @bind('ui:rerender', => + @createContainer() + 'online_notification' + ) + release: -> $(window).off 'click.notifications' $(window).off 'keydown.notifications' @@ -202,6 +208,7 @@ class App.OnlineNotificationContentWidget extends App.CollectionController order: 'DESC' alreadyShown: {} insertPosition: 'before' + globalRerender: false onRenderEnd: => @container.counterGen() diff --git a/app/assets/javascripts/app/controllers/widget/ticket_stats.coffee b/app/assets/javascripts/app/controllers/widget/ticket_stats.coffee index 7ec299050..e0f3773f2 100644 --- a/app/assets/javascripts/app/controllers/widget/ticket_stats.coffee +++ b/app/assets/javascripts/app/controllers/widget/ticket_stats.coffee @@ -14,9 +14,14 @@ class App.TicketStats extends App.Controller # subscribe and reload data / fetch new data if triggered if @user - @subscribeIdUser = App.User.full( @user.id, @load, false, true ) + @subscribeIdUser = App.User.full(@user.id, @load, false, true) else if @organization - @subscribeIdOrganization = App.Organization.full( @organization.id, @load, false, true ) + @subscribeIdOrganization = App.Organization.full(@organization.id, @load, false, true) + + # rerender view, e. g. on langauge change + @bind 'ui:rerender', => + return if !@authenticate(true) + @render() release: => if @subscribeIdUser @@ -35,13 +40,14 @@ class App.TicketStats extends App.Controller user_id: @user.id organization_id: @user.organization_id @ajax( - id: 'ticket_stats_' + ajaxKey + id: "ticket_stats_#{ajaxKey}" type: 'GET' - url: @apiPath + '/ticket_stats' + url: "#{@apiPath}/ticket_stats" data: data processData: true success: (data) => - App.Collection.loadAssets( data.assets ) + App.Collection.loadAssets(data.assets) + @data = data @render(data) ) @@ -58,6 +64,8 @@ class App.TicketStats extends App.Controller @orgTab.addClass('hide') render: (data) => + if !data + data = @data @html App.view('widget/ticket_stats')( user: @user diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index 24901b29a..507d524d5 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -359,8 +359,8 @@ class App.Model extends Spine.Model if param.clear is true || param.clear is false clear = param.clear if !@initFetchActive - @one 'refresh', (collection) => - @initFetchActive = true + @initFetchActive = true + @one 'refresh', (collection) -> callback(collection) @fetchFull( -> diff --git a/app/assets/javascripts/app/views/organization_profile/index.jst.eco b/app/assets/javascripts/app/views/organization_profile/index.jst.eco index 79fadb99a..53c9f63c1 100644 --- a/app/assets/javascripts/app/views/organization_profile/index.jst.eco +++ b/app/assets/javascripts/app/views/organization_profile/index.jst.eco @@ -1,5 +1,12 @@
+
+
+
+ <%- @Icon('organization') %> +
+

<%= @organization.displayName() %>

+
diff --git a/app/assets/javascripts/app/views/organization_profile/object.jst.eco b/app/assets/javascripts/app/views/organization_profile/object.jst.eco index 3a5955214..1c52d89ef 100644 --- a/app/assets/javascripts/app/views/organization_profile/object.jst.eco +++ b/app/assets/javascripts/app/views/organization_profile/object.jst.eco @@ -1,23 +1,16 @@ -
-
-
- <%- @Icon('organization') %> -
-

<%= @organization.displayName() %>

-
<% for row in @organizationData: %> <% if row.tag is 'richtext': %>
- +
<%- @organization[row.name] %>
<% else: %> <% if @organization[row.name]: %>
- - <%- @P( @organization, row.name ) %> + + <%- @P(@organization, row.name) %>
<% end %> <% end %> diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco index 211208998..4ec147742 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/article_view.jst.eco @@ -3,25 +3,25 @@