Remove some code
parent
aaee97c4eb
commit
79f0ac8114
|
@ -68,7 +68,8 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
milestonesOrder: {}
|
milestonesOrder: {}
|
||||||
|
|
||||||
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appMetaService, @navUrls,
|
constructor: (@scope, @rootscope, @repo, @confirm, @rs, @params, @q, @location, @appMetaService, @navUrls,
|
||||||
@events, @analytics, @translate, @loading, @rs2, @modelTransform, @errorHandlingService, @storage, @filterRemoteStorageService) ->
|
@events, @analytics, @translate, @loading, @rs2, @modelTransform, @errorHandlingService,
|
||||||
|
@storage, @filterRemoteStorageService) ->
|
||||||
bindMethods(@)
|
bindMethods(@)
|
||||||
|
|
||||||
@.backlogOrder = {}
|
@.backlogOrder = {}
|
||||||
|
@ -329,22 +330,15 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
prepareBulkUpdateData: (uses, field="backlog_order") ->
|
prepareBulkUpdateData: (uses, field="backlog_order") ->
|
||||||
return _.map(uses, (x) -> {"us_id": x.id, "order": x[field]})
|
return _.map(uses, (x) -> {"us_id": x.id, "order": x[field]})
|
||||||
|
|
||||||
resortUserStories: (uses, field="backlog_order") ->
|
|
||||||
items = []
|
|
||||||
|
|
||||||
for item, index in uses
|
|
||||||
item[field] = index
|
|
||||||
if item.isModified()
|
|
||||||
items.push(item)
|
|
||||||
|
|
||||||
return items
|
|
||||||
|
|
||||||
# --move us api behavior--
|
# --move us api behavior--
|
||||||
# if your are moving multiples USs you must use the bulk api
|
# if your are moving multiples USs you must use the bulk api
|
||||||
# if there is only one US you must use patch (repo.save)
|
# if there is only one US you must use patch (repo.save)
|
||||||
# the new US position is the position of the previous US + 1
|
# the new US position is the position of the previous US + 1
|
||||||
# if the previous US has a position value that it is equal to other USs, you must send all the USs with that position value only if they are before of the target position
|
# if the previous US has a position value that it is equal to
|
||||||
# with this USs if it's a patch you must add them to the header, if is a bulk you must send them with the other USs
|
# other USs, you must send all the USs with that position value
|
||||||
|
# only if they are before of the target position with this USs
|
||||||
|
# if it's a patch you must add them to the header, if is a bulk
|
||||||
|
# you must send them with the other USs.
|
||||||
moveUs: (ctx, usList, newUsIndex, newSprintId) ->
|
moveUs: (ctx, usList, newUsIndex, newSprintId) ->
|
||||||
oldSprintId = usList[0].milestone
|
oldSprintId = usList[0].milestone
|
||||||
project = usList[0].project
|
project = usList[0].project
|
||||||
|
@ -414,12 +408,17 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
else if previous
|
else if previous
|
||||||
startIndex = orderList[previous.id] + 1
|
startIndex = orderList[previous.id] + 1
|
||||||
|
|
||||||
previousWithTheSameOrder = _.filter beforeDestination, (it) -> it[orderField] == orderList[previous.id]
|
previousWithTheSameOrder = _.filter beforeDestination, (it) ->
|
||||||
|
return it[orderField] == orderList[previous.id]
|
||||||
|
|
||||||
# we must send the USs previous to the dropped USs to tell the backend which USs are before the dropped USs,
|
# we must send the USs previous to the dropped USs to
|
||||||
# if they have the same value to order, the backend doens't know after which one do you want to drop the USs
|
# tell the backend which USs are before the dropped
|
||||||
|
# USs, if they have the same value to order, the backend
|
||||||
|
# doens't know after which one do you want to drop
|
||||||
|
# the USs
|
||||||
if previousWithTheSameOrder.length > 1
|
if previousWithTheSameOrder.length > 1
|
||||||
setPreviousOrders = _.map previousWithTheSameOrder, (it) -> {us_id: it.id, order: orderList[it.id]}
|
setPreviousOrders = _.map previousWithTheSameOrder, (it) ->
|
||||||
|
return {us_id: it.id, order: orderList[it.id]}
|
||||||
|
|
||||||
modifiedUs = []
|
modifiedUs = []
|
||||||
|
|
||||||
|
@ -444,7 +443,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
|
||||||
for sprint in @scope.closedSprints
|
for sprint in @scope.closedSprints
|
||||||
sprint.user_stories = _.sortBy sprint.user_stories, (it) => @.milestonesOrder[sprint.id][it.id]
|
sprint.user_stories = _.sortBy sprint.user_stories, (it) => @.milestonesOrder[sprint.id][it.id]
|
||||||
|
|
||||||
#saving
|
# saving
|
||||||
if usList.length > 1 && (newSprintId != oldSprintId) # drag multiple to sprint
|
if usList.length > 1 && (newSprintId != oldSprintId) # drag multiple to sprint
|
||||||
data = modifiedUs.concat(setPreviousOrders)
|
data = modifiedUs.concat(setPreviousOrders)
|
||||||
promise = @rs.userstories.bulkUpdateMilestone(project, newSprintId, data)
|
promise = @rs.userstories.bulkUpdateMilestone(project, newSprintId, data)
|
||||||
|
|
|
@ -23,16 +23,10 @@
|
||||||
###
|
###
|
||||||
|
|
||||||
taiga = @.taiga
|
taiga = @.taiga
|
||||||
|
|
||||||
mixOf = @.taiga.mixOf
|
|
||||||
toggleText = @.taiga.toggleText
|
|
||||||
scopeDefer = @.taiga.scopeDefer
|
|
||||||
bindOnce = @.taiga.bindOnce
|
bindOnce = @.taiga.bindOnce
|
||||||
groupBy = @.taiga.groupBy
|
|
||||||
|
|
||||||
module = angular.module("taigaBacklog")
|
module = angular.module("taigaBacklog")
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## Sortable Directive
|
## Sortable Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
@ -42,7 +36,7 @@ deleteElement = (el) ->
|
||||||
$(el).off()
|
$(el).off()
|
||||||
$(el).remove()
|
$(el).remove()
|
||||||
|
|
||||||
BacklogSortableDirective = ($repo, $rs, $rootscope, $tgConfirm) ->
|
BacklogSortableDirective = () ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
bindOnce $scope, "project", (project) ->
|
bindOnce $scope, "project", (project) ->
|
||||||
# If the user has not enough permissions we don't enable the sortable
|
# If the user has not enough permissions we don't enable the sortable
|
||||||
|
@ -138,10 +132,4 @@ BacklogSortableDirective = ($repo, $rs, $rootscope, $tgConfirm) ->
|
||||||
|
|
||||||
return {link: link}
|
return {link: link}
|
||||||
|
|
||||||
module.directive("tgBacklogSortable", [
|
module.directive("tgBacklogSortable", BacklogSortableDirective)
|
||||||
"$tgRepo",
|
|
||||||
"$tgResources",
|
|
||||||
"$rootScope",
|
|
||||||
"$tgConfirm",
|
|
||||||
BacklogSortableDirective
|
|
||||||
])
|
|
||||||
|
|
Loading…
Reference in New Issue