Follow up for issue #641 - make macro working also on slower network connections (close tab if macro is executed sucessfully). And disable update button until macro is executed.
This commit is contained in:
parent
c61dd3eab4
commit
45ed1b3638
6 changed files with 78 additions and 87 deletions
|
@ -556,6 +556,10 @@ class App.Controller extends Spine.Controller
|
|||
stopPropagation: (e) ->
|
||||
e.stopPropagation()
|
||||
|
||||
preventDefaultAndstopPropagation: (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
startLoading: (el) =>
|
||||
return if @initLoadingDone && !el
|
||||
@initLoadingDone = true
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class App.TicketZoom extends App.Controller
|
||||
@include App.TicketNavigable
|
||||
|
||||
elements:
|
||||
'.main': 'main'
|
||||
'.ticketZoom': 'ticketZoom'
|
||||
|
@ -763,19 +765,20 @@ class App.TicketZoom extends App.Controller
|
|||
for key, value of ticketParams
|
||||
ticket[key] = value
|
||||
|
||||
App.Ticket.macro(
|
||||
macro: macro
|
||||
ticket: ticket
|
||||
callback:
|
||||
tagAdd: (tag) =>
|
||||
return if !@sidebarWidget
|
||||
return if !@sidebarWidget.reload
|
||||
@sidebarWidget.reload(tagAdd: tag, source: 'macro')
|
||||
tagRemove: (tag) =>
|
||||
return if !@sidebarWidget
|
||||
return if !@sidebarWidget.reload
|
||||
@sidebarWidget.reload(tagRemove: tag)
|
||||
)
|
||||
if macro.perform
|
||||
App.Ticket.macro(
|
||||
macro: macro.perform
|
||||
ticket: ticket
|
||||
callback:
|
||||
tagAdd: (tag) =>
|
||||
return if !@sidebarWidget
|
||||
return if !@sidebarWidget.reload
|
||||
@sidebarWidget.reload(tagAdd: tag, source: 'macro')
|
||||
tagRemove: (tag) =>
|
||||
return if !@sidebarWidget
|
||||
return if !@sidebarWidget.reload
|
||||
@sidebarWidget.reload(tagRemove: tag)
|
||||
)
|
||||
|
||||
# set defaults
|
||||
if !@permissionCheck('ticket.customer')
|
||||
|
@ -823,23 +826,23 @@ class App.TicketZoom extends App.Controller
|
|||
ticket.article = article
|
||||
|
||||
if !ticket.article
|
||||
@submitPost(e, ticket)
|
||||
@submitPost(e, ticket, macro)
|
||||
return
|
||||
|
||||
# verify if time accounting is enabled
|
||||
if @Config.get('time_accounting') isnt true
|
||||
@submitPost(e, ticket)
|
||||
@submitPost(e, ticket, macro)
|
||||
return
|
||||
|
||||
# verify if time accounting is active for ticket
|
||||
time_accounting_selector = @Config.get('time_accounting_selector')
|
||||
if !App.Ticket.selector(ticket, time_accounting_selector['condition'])
|
||||
@submitPost(e, ticket)
|
||||
@submitPost(e, ticket, macro)
|
||||
return
|
||||
|
||||
# time tracking
|
||||
if @permissionCheck('ticket.customer')
|
||||
@submitPost(e, ticket)
|
||||
@submitPost(e, ticket, macro)
|
||||
return
|
||||
|
||||
new App.TicketZoomTimeAccounting(
|
||||
|
@ -850,13 +853,15 @@ class App.TicketZoom extends App.Controller
|
|||
submitCallback: (params) =>
|
||||
if params.time_unit
|
||||
ticket.article.time_unit = params.time_unit
|
||||
@submitPost(e, ticket)
|
||||
@submitPost(e, ticket, macro)
|
||||
)
|
||||
|
||||
submitPost: (e, ticket) =>
|
||||
|
||||
submitPost: (e, ticket, macro) =>
|
||||
taskAction = @$('.js-secondaryActionButtonLabel').data('type')
|
||||
|
||||
if macro && macro.ux_flow_next_up
|
||||
taskAction = macro.ux_flow_next_up
|
||||
|
||||
# submit changes
|
||||
@ajax(
|
||||
id: "ticket_update_#{ticket.id}"
|
||||
|
@ -878,53 +883,27 @@ class App.TicketZoom extends App.Controller
|
|||
if @sidebarWidget
|
||||
@sidebarWidget.commit()
|
||||
|
||||
if taskAction is 'closeNextInOverview'
|
||||
if @overview_id
|
||||
current_position = 0
|
||||
overview = App.Overview.find(@overview_id)
|
||||
list = App.OverviewListCollection.get(overview.link)
|
||||
for ticket in list.tickets
|
||||
current_position += 1
|
||||
if ticket.id is @ticket_id
|
||||
next = list.tickets[current_position]
|
||||
if next
|
||||
# close task
|
||||
App.TaskManager.remove(@taskKey)
|
||||
if taskAction is 'closeNextInOverview' || taskAction is 'next_from_overview'
|
||||
App.Event.trigger('overview:fetch')
|
||||
@taskOpenNextTicketInOverview()
|
||||
return
|
||||
|
||||
# open task via task manager to get overview information
|
||||
App.TaskManager.execute(
|
||||
key: 'Ticket-' + next.id
|
||||
controller: 'TicketZoom'
|
||||
params:
|
||||
ticket_id: next.id
|
||||
overview_id: @overview_id
|
||||
show: true
|
||||
)
|
||||
@navigate "ticket/zoom/#{next.id}"
|
||||
return
|
||||
|
||||
# fallback, close task
|
||||
taskAction = 'closeTab'
|
||||
|
||||
if taskAction is 'closeTab'
|
||||
App.TaskManager.remove(@taskKey)
|
||||
nextTaskUrl = App.TaskManager.nextTaskUrl()
|
||||
if nextTaskUrl
|
||||
@navigate nextTaskUrl
|
||||
return
|
||||
|
||||
@navigate '#'
|
||||
if taskAction is 'closeTab' || taskAction is 'next_task'
|
||||
App.Event.trigger('overview:fetch')
|
||||
@taskCloseTicket(true)
|
||||
return
|
||||
|
||||
@autosaveStart()
|
||||
@muteTask()
|
||||
@formEnable(e)
|
||||
App.Event.trigger('overview:fetch')
|
||||
|
||||
error: (settings, details) =>
|
||||
error = undefined
|
||||
if settings && settings.responseJSON && settings.responseJSON.error
|
||||
error = settings.responseJSON.error
|
||||
App.Event.trigger 'notify', {
|
||||
type: 'error'
|
||||
msg: App.i18n.translateContent(details.error_human || details.error || settings.responseJSON.error || 'Unable to update!')
|
||||
msg: App.i18n.translateContent(details.error_human || details.error || error || 'Unable to update!')
|
||||
timeout: 2000
|
||||
}
|
||||
@autosaveStart()
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
class App.TicketZoomAttributeBar extends App.Controller
|
||||
@include App.TicketNavigable
|
||||
|
||||
elements:
|
||||
'.js-submitDropdown': 'buttonDropdown'
|
||||
'.js-reset': 'resetButton'
|
||||
|
||||
events:
|
||||
'mousedown .js-openDropdownMacro': 'toggleMacroMenu'
|
||||
'click .js-openDropdownMacro': 'stopPropagation'
|
||||
'click .js-openDropdownMacro': 'preventDefaultAndstopPropagation'
|
||||
'mouseup .js-dropdownActionMacro': 'performTicketMacro'
|
||||
'mouseenter .js-dropdownActionMacro': 'onActionMacroMouseEnter'
|
||||
'mouseleave .js-dropdownActionMacro': 'onActionMacroMouseLeave'
|
||||
|
@ -72,7 +70,10 @@ class App.TicketZoomAttributeBar extends App.Controller
|
|||
@render()
|
||||
|
||||
toggleMacroMenu: =>
|
||||
if @buttonDropdown.hasClass('is-open') then @closeMacroMenu() else @openMacroMenu()
|
||||
if @buttonDropdown.hasClass('is-open')
|
||||
@closeMacroMenu()
|
||||
return
|
||||
@openMacroMenu()
|
||||
|
||||
openMacroMenu: =>
|
||||
@buttonDropdown.addClass 'is-open'
|
||||
|
@ -86,19 +87,8 @@ class App.TicketZoomAttributeBar extends App.Controller
|
|||
macroId = $(e.currentTarget).data('id')
|
||||
macro = App.Macro.find(macroId)
|
||||
|
||||
@callback(e, macro.perform)
|
||||
@callback(e, macro)
|
||||
@closeMacroMenu()
|
||||
@replaceTabWith(macro.ux_flow_next_up)
|
||||
|
||||
replaceTabWith: (dest) =>
|
||||
switch dest
|
||||
when 'none'
|
||||
return
|
||||
when 'next_task'
|
||||
@closeTab()
|
||||
when 'next_from_overview'
|
||||
@closeTab()
|
||||
@openNextTicketInOverview()
|
||||
|
||||
onActionMacroMouseEnter: (e) =>
|
||||
@$(e.currentTarget).addClass('is-active')
|
||||
|
|
|
@ -70,4 +70,4 @@ class App.TicketZoomOverviewNavigator extends App.Controller
|
|||
else
|
||||
return
|
||||
|
||||
@openTicket(id, url)
|
||||
@taskOpenTicket(id, url)
|
||||
|
|
|
@ -5,23 +5,39 @@
|
|||
#
|
||||
# Relies on @overview_id and @ticket_id instance variables
|
||||
App.TicketNavigable =
|
||||
openTicket: (ticket_id, url) ->
|
||||
taskOpenTicket: (ticket_id, url) ->
|
||||
# coerce Ticket objects to id
|
||||
ticket_id = ticket_id.id if (ticket_id instanceof App.Ticket)
|
||||
|
||||
@loadTicketTask(ticket_id)
|
||||
@navigate url ? "ticket/zoom/#{ticket_id}"
|
||||
@taskLoadTicket(ticket_id)
|
||||
@navigate(url ? "ticket/zoom/#{ticket_id}")
|
||||
|
||||
# preserves overview information
|
||||
loadTicketTask: (ticket_id) ->
|
||||
taskLoadTicket: (ticket_id) ->
|
||||
App.TaskManager.execute(
|
||||
key: "Ticket-#{ticket_id}"
|
||||
controller: 'TicketZoom'
|
||||
params: { ticket_id: ticket_id, overview_id: @overview_id }
|
||||
params:
|
||||
ticket_id: ticket_id
|
||||
overview_id: @overview_id
|
||||
show: true
|
||||
)
|
||||
|
||||
openNextTicketInOverview: ->
|
||||
return if !(@overview_id? && @ticket?)
|
||||
taskOpenNextTicketInOverview: ->
|
||||
if !(@overview_id? && @ticket?)
|
||||
@taskCloseTicket(true)
|
||||
return
|
||||
next_ticket = App.Overview.find(@overview_id).nextTicket(@ticket)
|
||||
@openTicket(next_ticket.id)
|
||||
if next_ticket
|
||||
@taskCloseTicket()
|
||||
@taskLoadTicket(next_ticket.id)
|
||||
return
|
||||
@taskCloseTicket(true)
|
||||
|
||||
taskCloseTicket: (openNext = false) ->
|
||||
App.TaskManager.remove(@taskKey)
|
||||
return if !openNext
|
||||
nextTaskUrl = App.TaskManager.nextTaskUrl()
|
||||
if nextTaskUrl
|
||||
@navigate nextTaskUrl
|
||||
return
|
||||
@navigate '#'
|
||||
|
|
|
@ -24,16 +24,18 @@
|
|||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
<form class="buttonDropdown">
|
||||
<% if @macroDisabled: %>
|
||||
<div class="btn btn--primary js-submit"><%- @T('Update') %></div>
|
||||
<button class="btn btn--primary js-submit"><%- @T('Update') %></button>
|
||||
<% else: %>
|
||||
<div class="buttonDropdown dropdown dropup js-submitDropdown">
|
||||
<div class="btn btn--primary btn--split--first js-submit"><%- @T('Update') %></div>
|
||||
<div class="btn btn--primary btn--slim btn--split--last js-openDropdownMacro"><%- @Icon('arrow-up') %></div>
|
||||
<button class="btn btn--primary btn--split--first js-submit"><%- @T('Update') %></button>
|
||||
<button class="btn btn--primary btn--slim btn--split--last js-openDropdownMacro"><%- @Icon('arrow-up') %></button>
|
||||
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="userAction">
|
||||
<% for macro in @macros: %>
|
||||
<li class="js-dropdownActionMacro" role="menuitem" data-id="<%= macro.id %>"><%- @T(macro.displayName()) %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</form>
|
Loading…
Reference in a new issue