Regression fix: better order handling on kanban.

stable
Andrey Antukh 2014-09-18 16:45:34 +02:00
parent f5ed7e9499
commit 0984cdb5e3
2 changed files with 4 additions and 2 deletions

View File

@ -133,6 +133,7 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
for status in @scope.usStatusList for status in @scope.usStatusList
if not @scope.usByStatus[status.id]? if not @scope.usByStatus[status.id]?
@scope.usByStatus[status.id] = [] @scope.usByStatus[status.id] = []
@scope.usByStatus[status.id] = _.sortBy(@scope.usByStatus[status.id], "kanban_order")
# The broadcast must be executed when the DOM has been fully reloaded. # The broadcast must be executed when the DOM has been fully reloaded.
# We can't assure when this exactly happens so we need a defer # We can't assure when this exactly happens so we need a defer
@ -217,7 +218,6 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
# Add us to new status column. # Add us to new status column.
@scope.usByStatus[statusId].splice(index, 0, us) @scope.usByStatus[statusId].splice(index, 0, us)
us.status = statusId us.status = statusId
else else
r = @scope.usByStatus[statusId].indexOf(us) r = @scope.usByStatus[statusId].indexOf(us)
@ -225,6 +225,7 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
@scope.usByStatus[statusId].splice(index, 0, us) @scope.usByStatus[statusId].splice(index, 0, us)
itemsToSave = @.resortUserStories(@scope.usByStatus[statusId]) itemsToSave = @.resortUserStories(@scope.usByStatus[statusId])
@scope.usByStatus[statusId] = _.sortBy(@scope.usByStatus[statusId], "kanban_order")
# Persist the userstory # Persist the userstory
promise = @repo.save(us) promise = @repo.save(us)
@ -232,6 +233,7 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
# Rehash userstories order field # Rehash userstories order field
# and persist in bulk all changes. # and persist in bulk all changes.
promise = promise.then => promise = promise.then =>
itemsToSave = _.reject(itemsToSave, {"id": us.id})
data = @.prepareBulkUpdateData(itemsToSave) data = @.prepareBulkUpdateData(itemsToSave)
return @rs.userstories.bulkUpdateKanbanOrder(us.project, data).then => return @rs.userstories.bulkUpdateKanbanOrder(us.project, data).then =>

View File

@ -26,6 +26,6 @@ div.kanban-table
tg-kanban-sortable, tg-kanban-sortable,
tg-kanban-wip-limit, tg-kanban-wip-limit,
tg-kanban-column-height-fixer) tg-kanban-column-height-fixer)
div.kanban-task(ng-repeat="us in usByStatus[status.id]|orderBy:'kanban_order' track by us.id", div.kanban-task(ng-repeat="us in usByStatus[status.id] track by us.id",
tg-kanban-userstory, ng-model="us", tg-kanban-userstory, ng-model="us",
ng-class="ctrl.getCardClass(status.id)") ng-class="ctrl.getCardClass(status.id)")