diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index 5d388b32e..87b35f944 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -40,33 +40,23 @@ class App.TicketZoom extends App.Controller @interval(update, 1800000, 'pull_check') # fetch new data if triggered - @bind( - 'Ticket:update Ticket:touch' - (data) => + @bind('Ticket:update Ticket:touch', (data) => - # check if current ticket has changed - return if data.id.toString() isnt @ticket_id.toString() + # check if current ticket has changed + return if data.id.toString() isnt @ticket_id.toString() - # check if we already have the request queued - #@log 'notice', 'TRY', @ticket_id, new Date(data.updated_at), new Date(@ticketUpdatedAtLastCall) - update = => - @fetch( @ticket_id, false ) - if !@ticketUpdatedAtLastCall || ( new Date(data.updated_at).toString() isnt new Date(@ticketUpdatedAtLastCall).toString() ) - @delay( update, 1200, 'ticket-zoom-' + @ticket_id ) + # check if we already have the request queued + #@log 'notice', 'TRY', @ticket_id, new Date(data.updated_at), new Date(@ticketUpdatedAtLastCall) + update = => + @fetch(@ticket_id, false) + if !@ticketUpdatedAtLastCall || ( new Date(data.updated_at).toString() isnt new Date(@ticketUpdatedAtLastCall).toString() ) + @delay( update, 1200, 'ticket-zoom-' + @ticket_id ) ) # rerender view, e. g. on langauge change - @bind 'ui:rerender', => - return if !@authenticate(true) - - # reset controllers state vars - @shown = false - @initDone = false - @activeState = false - @renderDone = false - - # rerender view - @render() + @bind('ui:rerender', => + @fetch(@ticket_id, true) + ) meta: => @@ -343,7 +333,7 @@ class App.TicketZoom extends App.Controller ticket_id: @ticket.id ) - @article_view = new App.TicketZoomArticleView( + @articleView = new App.TicketZoomArticleView( ticket: @ticket el: @$('.ticket-article') ui: @ @@ -369,7 +359,7 @@ class App.TicketZoom extends App.Controller ) # show article - @article_view.execute( + @articleView.execute( ticket_article_ids: @ticket_article_ids ) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index 38a7d3d48..3045db8a4 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -93,31 +93,32 @@ class App.TicketZoomArticleNew extends App.Controller @openTextarea(null, true) # set article type and expand text area - @bind( - 'ui::ticket::setArticleType' - (data) => - return if data.ticket.id isnt @ticket_id - #@setArticleType(data.type.name) + @bind('ui::ticket::setArticleType', (data) => + return if data.ticket.id isnt @ticket_id + #@setArticleType(data.type.name) - @openTextarea(null, true) - for key, value of data.article - if key is 'body' - @$('[data-name="' + key + '"]').html(value) - else - @$('[name="' + key + '"]').val(value) + @openTextarea(null, true) + for key, value of data.article + if key is 'body' + @$('[data-name="' + key + '"]').html(value) + else + @$('[name="' + key + '"]').val(value) - # preselect article type - @setArticleType('email') + # preselect article type + @setArticleType('email') ) # reset new article screen - @bind( - 'ui::ticket::taskReset' - (data) => - return if data.ticket_id isnt @ticket_id - @type = 'note' - @defaults = {} - @render() + @bind('ui::ticket::taskReset', (data) => + return if data.ticket_id isnt @ticket_id + @type = 'note' + @defaults = {} + @render() + ) + + # rerender, e. g. on language change + @bind('ui:rerender', => + @render() ) isIE10: -> @@ -135,7 +136,7 @@ class App.TicketZoomArticleNew extends App.Controller render: -> - ticket = App.Ticket.fullLocal( @ticket_id ) + ticket = App.Ticket.fullLocal(@ticket_id) @html App.view('ticket_zoom/article_new')( ticket: ticket 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 fd0aa00fe..7133018be 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee @@ -40,16 +40,19 @@ class ArticleViewItem extends App.Controller @render() # set expand of text area only once - @bind( - 'ui::ticket::shown' - (data) => - return if data.ticket_id.toString() isnt @ticket.id.toString() + @bind('ui::ticket::shown', (data) => + return if data.ticket_id.toString() isnt @ticket.id.toString() - # set highlighter - @setHighlighter() + # set highlighter + @setHighlighter() - # set see more - @setSeeMore() + # set see more + @setSeeMore() + ) + + # rerender, e. g. on language change + @bind('ui:rerender', => + @render(undefined, true) ) # subscribe to changes @@ -84,7 +87,7 @@ class ArticleViewItem extends App.Controller @articleAttributesLastUpdate = articleAttributesLastUpdateCheck true - render: (article) => + render: (article, force = false) => # get articles @article = App.TicketArticle.fullLocal( @ticket_article_id ) @@ -103,7 +106,7 @@ class ArticleViewItem extends App.Controller @el.removeClass('is-internal') # check if rerender is needed - if !@hasChanged(@article) + if !force && !@hasChanged(@article) @lastArticle = @article.attributes() return diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee index b6dce1c03..c13687d92 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee @@ -19,6 +19,11 @@ class App.TicketZoomAttributeBar extends App.Controller @subscribeId = App.Macro.subscribe(@render) @render() + # rerender, e. g. on language change + @bind('ui:rerender', => + @render() + ) + release: => App.Macro.unsubscribe(@subscribeId) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/meta.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/meta.coffee index edfe2ba71..715147886 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/meta.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/meta.coffee @@ -1,12 +1,20 @@ class App.TicketZoomMeta extends App.Controller constructor: -> super + @render() - @ticket = App.Ticket.fullLocal(@ticket.id) - @render(@ticket) - @subscribeId = @ticket.subscribe(@render) + # rerender, e. g. on language change + @bind('ui:rerender', => + @render() + ) render: (ticket) => + if !ticket + ticket = App.Ticket.fullLocal(@ticket.id) + + if !@subscribeId + @subscribeId = @ticket.subscribe(@render) + @html App.view('ticket_zoom/meta')( ticket: ticket isCustomer: @isRole('Customer') diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee index a450f77b3..b44ef7bd8 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/title.coffee @@ -4,12 +4,21 @@ class App.TicketZoomTitle extends App.Controller constructor: -> super + @render() - @ticket = App.Ticket.fullLocal( @ticket.id ) - @subscribeId = @ticket.subscribe(@render) - @render(@ticket) + # rerender, e. g. on language change + @bind('ui:rerender', => + @render() + ) render: (ticket) => + if !ticket + ticket = App.Ticket.fullLocal(@ticket.id) + + if !@subscribeId + @subscribeId = @ticket.subscribe(@render) + + @title = ticket.title # check if render is needed if @lastTitle && @lastTitle is ticket.title @@ -30,18 +39,19 @@ class App.TicketZoomTitle extends App.Controller title = $(e.target).ceg() || '' # update title - if title isnt @ticket.title - @ticket.title = title + if title isnt @title + ticket = App.Ticket.find(@ticket.id) + ticket.title = title # reset article - should not be resubmited on next ticket update - @ticket.article = undefined + ticket.article = undefined - @ticket.save() + ticket.save() - App.TaskManager.mute( @task_key ) + App.TaskManager.mute(@task_key) # update taskbar with new meta data App.Event.trigger 'task:render' release: => - App.Ticket.unsubscribe( @subscribeId ) \ No newline at end of file + App.Ticket.unsubscribe(@subscribeId)