Merge pull request #1313 from taigaio/fixing-ordering-on-archived

Fixing ordering in archived states
stable
Alejandro 2017-05-19 13:12:31 +02:00 committed by GitHub
commit 5b59792b91
2 changed files with 20 additions and 4 deletions

View File

@ -89,7 +89,6 @@ class KanbanUserstoriesService extends taiga.Service
@.order[it.id] = it.kanban_order for it in @.userstoriesRaw
assignOrders: (order) ->
order = _.invert(order)
@.order = _.assign(@.order, order)
@.refresh()
@ -117,8 +116,10 @@ class KanbanUserstoriesService extends taiga.Service
for it in previousWithTheSameOrder
setOrders[it.id] = @.order[it.id]
if !previous
if !previous and (!afterDestination or afterDestination.length == 0)
@.order[us.id] = 0
else if !previous and afterDestination and afterDestination.length > 0
@.order[us.id] = @.order[afterDestination[0].id] - 1
else if previous
@.order[us.id] = @.order[previous.id] + 1
@ -132,6 +133,18 @@ class KanbanUserstoriesService extends taiga.Service
return {"us_id": us.id, "order": @.order[us.id], "set_orders": setOrders}
moveToEnd: (id, statusId) ->
us = @.getUsModel(id)
@.order[us.id] = -1
us.status = statusId
us.kanban_order = @.order[us.id]
@.refresh()
return {"us_id": us.id, "order": -1}
replace: (us) ->
@.usByStatus = @.usByStatus.map (status) ->
findedIndex = status.findIndex (usItem) ->

View File

@ -293,8 +293,11 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
moveUs: (ctx, us, oldStatusId, newStatusId, index) ->
us = @kanbanUserstoriesService.getUsModel(us.get('id'))
moveUpdateData = @kanbanUserstoriesService.move(us.id, newStatusId, index)
newStatus = @scope.usStatusById[newStatusId]
if newStatus.is_archived and !@scope.usByStatus.get(newStatusId.toString())
moveUpdateData = @kanbanUserstoriesService.moveToEnd(us.id, newStatusId)
else
moveUpdateData = @kanbanUserstoriesService.move(us.id, newStatusId, index)
params = {
include_attachments: true,