diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index c928a205e..11d160659 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -119,7 +119,8 @@ class Navbar extends App.Controller $(event.currentTarget).addClass('active') release: => - $(window).off 'resize.navbar', @autoFoldTabs + if @vertical + $(window).off 'resize.navbar', @autoFoldTabs if @bindId App.OverviewIndexCollection.unbind(@bindId) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index d66bd4b8c..b96804c59 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -305,26 +305,28 @@ class App.TicketZoom extends App.Controller new App.TicketZoomTitle( ticket: @ticket overview_id: @overview_id - el: @el.find('.ticket-title') + el: @$('.ticket-title') task_key: @task_key ) new App.TicketZoomMeta( ticket: @ticket - el: @el.find('.ticket-meta') + el: @$('.ticket-meta') ) new App.TicketZoomAttributeBar( - ticket: @ticket - el: @el.find('.js-attributeBar') - callback: @submit + ticket: @ticket + el: @$('.js-attributeBar') + overview_id: @overview_id + callback: @submit + task_key: @task_key ) @form_id = App.ControllerForm.formId() new App.TicketZoomArticleNew( ticket: @ticket - el: @el.find('.article-new') + el: @$('.article-new') form_meta: @form_meta form_id: @form_id defaults: @taskGet('article') @@ -338,7 +340,7 @@ class App.TicketZoom extends App.Controller @article_view = new App.TicketZoomArticleView( ticket: @ticket - el: @el.find('.ticket-article') + el: @$('.ticket-article') ui: @ highligher: @highligher ) @@ -351,7 +353,7 @@ class App.TicketZoom extends App.Controller size: 50 ) @sidebar = new App.TicketZoomSidebar( - el: @el.find('.tabsSidebar') + el: @$('.tabsSidebar') sidebarState: @sidebarState ticket: @ticket taskGet: @taskGet @@ -485,6 +487,9 @@ class App.TicketZoom extends App.Controller submit: (e, macro = {}) => e.stopPropagation() e.preventDefault() + + taskAction = @$('.js-secondaryActionButtonLabel').data('type') + ticketParams = @formParam( @$('.edit') ) # validate ticket @@ -638,6 +643,44 @@ class App.TicketZoom extends App.Controller # reset form after save @reset() + if taskAction is 'closeNextInOverview' + if @overview_id + current_position = 0 + overview = App.Overview.find(@overview_id) + list = App.OverviewCollection.get(overview.link) + for ticket_id in list.ticket_ids + current_position += 1 + if ticket_id is @ticket_id + next = list.ticket_ids[current_position] + if next + # close task + App.TaskManager.remove(@task_key) + + # open task via task manager to get overview information + App.TaskManager.execute( + key: 'Ticket-' + next + controller: 'TicketZoom' + params: + ticket_id: next + overview_id: @overview_id + show: true + ) + @navigate "ticket/zoom/#{next}" + return + + # fallback, close task + taskAction = 'closeTab' + + if taskAction is 'closeTab' + App.TaskManager.remove(@task_key) + nextTaskUrl = App.TaskManager.nextTaskUrl() + if nextTaskUrl + @navigate nextTaskUrl + return + + @navigate '#' + return + @autosaveStart() App.TaskManager.mute(@task_key) 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 4fc23b084..80a2ee262 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/attribute_bar.coffee @@ -1,6 +1,7 @@ class App.TicketZoomAttributeBar extends App.Controller elements: - '.buttonDropdown': 'buttonDropdown' + '.js-submitDropdown': 'buttonDropdown' + '.js-secondaryActionButtonLabel': 'secondaryActionButton' events: 'mousedown .js-openDropdownMacro': 'toggleDropdownMacro' @@ -8,10 +9,15 @@ class App.TicketZoomAttributeBar extends App.Controller 'mouseup .js-dropdownActionMacro': 'performTicketMacro' 'mouseenter .js-dropdownActionMacro': 'onActionMacroMouseEnter' 'mouseleave .js-dropdownActionMacro': 'onActionMacroMouseLeave' + 'click .js-secondaryAction': 'chooseSecondaryAction' constructor: -> super + @secondaryAction = @preferencesGet() || 'stayOnTab' + if !@overview_id && @secondaryAction is 'closeNextInOverview' + @secondaryAction = 'closeTab' + @subscribeId = App.Macro.subscribe(@render) @render() @@ -25,7 +31,9 @@ class App.TicketZoomAttributeBar extends App.Controller @html App.view('ticket_zoom/attribute_bar')( macros: macros macroDisabled: macroDisabled + overview_id: @overview_id ) + @setSecondaryAction() toggleDropdownMacro: => if @buttonDropdown.hasClass 'is-open' @@ -39,8 +47,8 @@ class App.TicketZoomAttributeBar extends App.Controller $(document).unbind 'click.buttonDropdown' performTicketMacro: (e) => - macroId = $(e.target).data('id') - console.log "perform action", @$(e.currentTarget).text(), macroId + macroId = $(e.currentTarget).data('id') + console.log 'perform action', @$(e.currentTarget).text(), macroId macro = App.Macro.find(macroId) @callback(e, macro.perform) @@ -50,4 +58,23 @@ class App.TicketZoomAttributeBar extends App.Controller @$(e.currentTarget).addClass('is-active') onActionMacroMouseLeave: (e) => - @$(e.currentTarget).removeClass('is-active') \ No newline at end of file + @$(e.currentTarget).removeClass('is-active') + + chooseSecondaryAction: (e) => + type = $(e.currentTarget).find('.js-secondaryActionLabel').data('type') + @setSecondaryAction(type) + + setSecondaryAction: (type = @secondaryAction) => + element = @$(".js-secondaryActionLabel[data-type=#{type}]") + text = element.text() + @$('.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) + App.LocalStorage.set(@preferencesStoreKey(), type, @Session.get('id')) + + preferencesGet: => + App.LocalStorage.get(@preferencesStoreKey(), @Session.get('id')) + + preferencesStoreKey: => + "ticketZoom:taskAktion:#{@ticket_id}" 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 213d6daf4..54d01394b 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,14 +1,38 @@
-<% if @macroDisabled: %> -