diff --git a/app/assets/javascripts/app/controllers/taskbar_widget.coffee b/app/assets/javascripts/app/controllers/taskbar_widget.coffee index 1ddd316ff..fe3be2ffa 100644 --- a/app/assets/javascripts/app/controllers/taskbar_widget.coffee +++ b/app/assets/javascripts/app/controllers/taskbar_widget.coffee @@ -93,7 +93,8 @@ class App.TaskbarWidget extends App.Controller if worker.changed() new Remove( key: key - ui: @ + ui: @ + event: e ) return @@ -131,6 +132,6 @@ class Remove extends App.ControllerModal content: -> App.i18n.translateContent('Tab has changed, you really want to close it?') - onSubmit: (e) => + onSubmit: => @close() - @ui.remove(e, @key, true) + @ui.remove(@event, @key, true) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index e43864afa..563be1b4b 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -51,7 +51,7 @@ class App.TicketZoom extends App.Controller 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 ) + @delay(update, 1200, "ticket-zoom-#{@ticket_id}") ) # rerender view, e. g. on langauge change @@ -100,7 +100,7 @@ class App.TicketZoom extends App.Controller @activeState = true # start autosave - @autosaveStart() + @delay(@autosaveStart, 800, "ticket-zoom-auto-save-#{@ticket_id}") # if ticket is shown the first time if !@shown @@ -122,6 +122,7 @@ class App.TicketZoom extends App.Controller @positionPageHeaderStop() # stop autosave + @clearDelay("ticket-zoom-auto-save-#{@ticket_id}") @autosaveStop() changed: => @@ -687,12 +688,12 @@ class App.TicketZoom extends App.Controller processData: false ) - # reset edit ticket / reset new article - App.Event.trigger('ui::ticket::taskReset', { ticket_id: @ticket.id }) - # hide reset button @$('.js-reset').addClass('hide') + # reset edit ticket / reset new article + App.Event.trigger('ui::ticket::taskReset', { ticket_id: @ticket.id }) + # remove change flag on tab @$('.tabsSidebar-tab[data-tab="ticket"]').removeClass('is-changed') 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 c13687d92..c2f2f58af 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee @@ -1,7 +1,7 @@ class App.TicketZoomAttributeBar extends App.Controller elements: '.js-submitDropdown': 'buttonDropdown' - '.js-secondaryActionButtonLabel': 'secondaryActionButton' + '.js-reset': 'resetButton' events: 'mousedown .js-openDropdownMacro': 'toggleDropdownMacro' @@ -16,7 +16,7 @@ class App.TicketZoomAttributeBar extends App.Controller @secondaryAction = 'stayOnTab' - @subscribeId = App.Macro.subscribe(@render) + @subscribeId = App.Macro.subscribe(@checkMacroChanges) @render() # rerender, e. g. on language change @@ -28,15 +28,31 @@ class App.TicketZoomAttributeBar extends App.Controller App.Macro.unsubscribe(@subscribeId) render: => + + # remember current reset state + resetButtonShown = false + if @resetButton.get(0) && !@resetButton.hasClass('hide') + resetButtonShown = true + macros = App.Macro.all() + @macroLastUpdated = App.Macro.lastUpdatedAt() + if _.isEmpty(macros) || !@isRole('Agent') macroDisabled = true - @html App.view('ticket_zoom/attribute_bar')( + + localeEl = $(App.view('ticket_zoom/attribute_bar')( macros: macros macroDisabled: macroDisabled overview_id: @overview_id - ) - @setSecondaryAction() + resetButtonShown: resetButtonShown + )) + @setSecondaryAction(@secondaryAction, localeEl) + @html localeEl + + checkMacroChanges: => + macroLastUpdated = App.Macro.lastUpdatedAt() + return if macroLastUpdated is @macroLastUpdated + @render() toggleDropdownMacro: => if @buttonDropdown.hasClass 'is-open' @@ -65,12 +81,12 @@ class App.TicketZoomAttributeBar extends App.Controller chooseSecondaryAction: (e) => type = $(e.currentTarget).find('.js-secondaryActionLabel').data('type') - @setSecondaryAction(type) + @setSecondaryAction(type, @el) - setSecondaryAction: (type = @secondaryAction) => - element = @$(".js-secondaryActionLabel[data-type=#{type}]") + setSecondaryAction: (type, localEl) -> + element = localEl.find(".js-secondaryActionLabel[data-type=#{type}]") text = element.text() - @$('.js-secondaryAction .js-selectedIcon.is-selected').removeClass('is-selected') + localEl.find('.js-secondaryAction .js-selectedIcon.is-selected').removeClass('is-selected') element.closest('.js-secondaryAction').find('.js-selectedIcon').addClass('is-selected') - @secondaryActionButton.text(text) - @secondaryActionButton.data('type', type) + localEl.find('.js-secondaryActionButtonLabel').text(text) + localEl.find('.js-secondaryActionButtonLabel').data('type', type) diff --git a/app/assets/javascripts/app/models/_application_model.coffee b/app/assets/javascripts/app/models/_application_model.coffee index 1dda13a5e..8acd0b8f7 100644 --- a/app/assets/javascripts/app/models/_application_model.coffee +++ b/app/assets/javascripts/app/models/_application_model.coffee @@ -666,3 +666,13 @@ class App.Model extends Spine.Model activityMessage: (item) -> return "Need own activityMessage() in model to generate text (#{@objectDisplayName()}/#{item.type})." + + @lastUpdatedAt: -> + updated_at + for item in @all() + if item.updated_at + if !updated_at + updated_at = item.updated_at + else if item.updated_at > updated_at + updated_at = item.updated_at + updated_at diff --git a/app/assets/javascripts/app/views/ticket_zoom/attribute_bar.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/attribute_bar.jst.eco index 7863a278c..d78859188 100644 --- a/app/assets/javascripts/app/views/ticket_zoom/attribute_bar.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom/attribute_bar.jst.eco @@ -1,4 +1,4 @@ -
+