Remove some code

stable
David Barragán Merino 2016-09-01 19:23:56 +02:00
parent aaee97c4eb
commit 79f0ac8114
2 changed files with 22 additions and 35 deletions

View File

@ -68,7 +68,8 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
milestonesOrder: {}
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(@)
@.backlogOrder = {}
@ -329,22 +330,15 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
prepareBulkUpdateData: (uses, field="backlog_order") ->
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--
# if your are moving multiples USs you must use the bulk api
# if there is only one US you must use patch (repo.save)
# 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
# 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
# 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 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) ->
oldSprintId = usList[0].milestone
project = usList[0].project
@ -414,12 +408,17 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
else if previous
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,
# if they have the same value to order, the backend doens't know after which one do you want to drop the USs
# we must send the USs previous to the dropped USs to
# 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
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 = []
@ -444,7 +443,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
for sprint in @scope.closedSprints
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
data = modifiedUs.concat(setPreviousOrders)
promise = @rs.userstories.bulkUpdateMilestone(project, newSprintId, data)

View File

@ -23,16 +23,10 @@
###
taiga = @.taiga
mixOf = @.taiga.mixOf
toggleText = @.taiga.toggleText
scopeDefer = @.taiga.scopeDefer
bindOnce = @.taiga.bindOnce
groupBy = @.taiga.groupBy
module = angular.module("taigaBacklog")
#############################################################################
## Sortable Directive
#############################################################################
@ -42,7 +36,7 @@ deleteElement = (el) ->
$(el).off()
$(el).remove()
BacklogSortableDirective = ($repo, $rs, $rootscope, $tgConfirm) ->
BacklogSortableDirective = () ->
link = ($scope, $el, $attrs) ->
bindOnce $scope, "project", (project) ->
# 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}
module.directive("tgBacklogSortable", [
"$tgRepo",
"$tgResources",
"$rootScope",
"$tgConfirm",
BacklogSortableDirective
])
module.directive("tgBacklogSortable", BacklogSortableDirective)