diff --git a/app/coffee/modules/kanban/kanban-usertories.coffee b/app/coffee/modules/kanban/kanban-usertories.coffee index dc699c43..9f92fc8f 100644 --- a/app/coffee/modules/kanban/kanban-usertories.coffee +++ b/app/coffee/modules/kanban/kanban-usertories.coffee @@ -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) -> diff --git a/app/coffee/modules/kanban/main.coffee b/app/coffee/modules/kanban/main.coffee index b7ad0597..6d331551 100644 --- a/app/coffee/modules/kanban/main.coffee +++ b/app/coffee/modules/kanban/main.coffee @@ -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,