From 862ec3706db01996dc52ca238189c65a9fe36b86 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 11 May 2017 23:52:57 +0200 Subject: [PATCH] Fixed issue #1053 - Bulk Action -> JS Error - Bug. --- .../_application_controller_table.coffee | 39 ++++++++++++------- .../app/controllers/ticket_overview.coffee | 9 +++++ app/assets/javascripts/app/index.coffee | 2 +- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_table.coffee b/app/assets/javascripts/app/controllers/_application_controller_table.coffee index eeebc0cfd..7e4e256a1 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_table.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_table.coffee @@ -364,8 +364,8 @@ class App.ControllerTable extends App.Controller do (table, event, callback) -> table.delegate('input[name="bulk"]', event, (e) -> e.stopPropagation() - id = $(e.target).parents('tr').data('id') - checked = $(e.target).prop('checked') + id = $(e.currentTarget).parents('tr').data('id') + checked = $(e.currentTarget).prop('checked') callback(id, checked, e) ) @@ -382,27 +382,38 @@ class App.ControllerTable extends App.Controller if @checkbox # click first tr>td, catch click - table.delegate('tr > td:nth-child(1)', event, (e) -> + table.delegate('tr > td:nth-child(1)', 'click', (e) -> e.stopPropagation() ) # bind on full bulk click - table.delegate('input[name="bulk_all"]', 'change', (e) -> + table.delegate('input[name="bulk_all"]', 'change', (e) => e.stopPropagation() - if $(e.target).prop('checked') - $(e.target).parents('table').find('[name="bulk"]').each( -> - if !$(@).prop('checked') - #$(@).prop('checked', true) - $(@).trigger('click') + clicks = [] + if $(e.currentTarget).prop('checked') + $(e.currentTarget).parents('table').find('[name="bulk"]').each( -> + $element = $(@) + return if $element.prop('checked') + $element.prop('checked', true) + id = $element.parents('tr').data('id') + clicks.push [id, true] ) else - $(e.target).parents('table').find('[name="bulk"]').each( -> - if $(@).prop('checked') - #$(@).prop('checked', false) - $(@).trigger('click') + $(e.currentTarget).parents('table').find('[name="bulk"]').each( -> + $element = $(@) + return if !$element.prop('checked') + $element.prop('checked', false) + id = $element.parents('tr').data('id') + clicks.push [id, false] ) + return if !@bindCheckbox + return if !@bindCheckbox.events + return if _.isEmpty(clicks) + for event, callback of @bindCheckbox.events + if event == 'click' || event == 'change' + for click in clicks + callback(click..., e) ) - table sortList: (objects) => diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index 0d7d75176..66c5ec1ca 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -120,9 +120,18 @@ class App.TicketOverview extends App.Controller options: duration: 200 complete: => + if !@hoveredBatchEntry + @cleanUpDrag() + return + @hoveredBatchEntry.velocity 'reverse', duration: 200 complete: => + + if !@hoveredBatchEntry + @cleanUpDrag() + return + # clean scale action = @hoveredBatchEntry.attr('data-action') id = @hoveredBatchEntry.attr('data-id') diff --git a/app/assets/javascripts/app/index.coffee b/app/assets/javascripts/app/index.coffee index 933e01c90..3e6211d9b 100644 --- a/app/assets/javascripts/app/index.coffee +++ b/app/assets/javascripts/app/index.coffee @@ -195,7 +195,7 @@ class App extends Spine.Controller # if date is a object, get name of the object isObject = false - if typeof item is 'object' + if item && typeof item is 'object' isObject = true if item.displayNameLong resultLocal = item.displayNameLong()