Merge pull request #500 from taigaio/enhancement/2807/multiple-backlog-check-with-shift

if the user check one item in the backlog the items between this item…
stable
Alejandro 2015-06-08 05:59:28 -07:00
commit 53fbc41116
1 changed files with 33 additions and 3 deletions

View File

@ -603,9 +603,11 @@ BacklogDirective = ($repo, $rootscope, $translate) ->
$ctrl.loadProjectStats() $ctrl.loadProjectStats()
# Enable move to current sprint only when there are selected us's shiftPressed = false
$el.on "change", ".backlog-table-body .user-stories input:checkbox", (event) -> lastChecked = null
target = angular.element(event.currentTarget)
checkSelected = (target) ->
lastChecked = target.closest(".us-item-row")
moveToCurrentSprintDom = $el.find("#move-to-current-sprint") moveToCurrentSprintDom = $el.find("#move-to-current-sprint")
selectedUsDom = $el.find(".backlog-table-body .user-stories input:checkbox:checked") selectedUsDom = $el.find(".backlog-table-body .user-stories input:checkbox:checked")
@ -616,6 +618,33 @@ BacklogDirective = ($repo, $rootscope, $translate) ->
target.closest('.us-item-row').toggleClass('ui-multisortable-multiple') target.closest('.us-item-row').toggleClass('ui-multisortable-multiple')
$(window).on "keydown.shift-pressed keyup.shift-pressed", (event) ->
shiftPressed = !!event.shiftKey
return true
# Enable move to current sprint only when there are selected us's
$el.on "change", ".backlog-table-body .user-stories input:checkbox", (event) ->
# check elements between the last two if shift is pressed
if lastChecked && shiftPressed
elements = []
current = $(event.currentTarget).closest(".us-item-row")
nextAll = lastChecked.nextAll()
prevAll = lastChecked.prevAll()
if _.some(nextAll, (next) -> next == current[0])
elements = lastChecked.nextUntil(current)
else if _.some(prevAll, (prev) -> prev == current[0])
elements = lastChecked.prevUntil(current)
_.map elements, (elm) ->
input = $(elm).find("input:checkbox")
input.prop('checked', true);
checkSelected(input)
target = angular.element(event.currentTarget)
checkSelected(target)
$el.on "click", "#move-to-current-sprint", (event) => $el.on "click", "#move-to-current-sprint", (event) =>
# Calculating the us's to be modified # Calculating the us's to be modified
ussDom = $el.find(".backlog-table-body .user-stories input:checkbox:checked") ussDom = $el.find(".backlog-table-body .user-stories input:checkbox:checked")
@ -701,6 +730,7 @@ BacklogDirective = ($repo, $rootscope, $translate) ->
$scope.$on "$destroy", -> $scope.$on "$destroy", ->
$el.off() $el.off()
$(window).off(".shift-pressed")
return {link: link} return {link: link}