From 314271f2b4f4be92146524af36ded2abb32eb58b Mon Sep 17 00:00:00 2001 From: friflaj Date: Sun, 15 Aug 2010 02:33:17 +0200 Subject: [PATCH] Remove position from an issue when it is changed from a story into a task --- ...sk_position.rb => 015_order_tasks_using_tree.rb} | 2 +- db/migrate/016_remove_task_position.rb | 13 +++++++++++++ lib/backlogs_issue_patch.rb | 10 +++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) rename db/migrate/{015_remove_task_position.rb => 015_order_tasks_using_tree.rb} (89%) create mode 100644 db/migrate/016_remove_task_position.rb diff --git a/db/migrate/015_remove_task_position.rb b/db/migrate/015_order_tasks_using_tree.rb similarity index 89% rename from db/migrate/015_remove_task_position.rb rename to db/migrate/015_order_tasks_using_tree.rb index 3b1e8611ff..42950ed8fd 100644 --- a/db/migrate/015_remove_task_position.rb +++ b/db/migrate/015_order_tasks_using_tree.rb @@ -1,4 +1,4 @@ -class RemoveTaskPosition < ActiveRecord::Migration +class OrderTasksUsingTree < ActiveRecord::Migration def self.up last_task = {} ActiveRecord::Base.transaction do diff --git a/db/migrate/016_remove_task_position.rb b/db/migrate/016_remove_task_position.rb new file mode 100644 index 0000000000..1eed842cfb --- /dev/null +++ b/db/migrate/016_remove_task_position.rb @@ -0,0 +1,13 @@ +class RemoveTaskPosition < ActiveRecord::Migration + def self.up + ActiveRecord::Base.transaction do + Task.find(:all, :conditions => "id <> root_id and not position is null").each do |t| + t.remove_from_list + end + end + end + + def self.down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/lib/backlogs_issue_patch.rb b/lib/backlogs_issue_patch.rb index 1a99ba5547..7735e6ebcc 100755 --- a/lib/backlogs_issue_patch.rb +++ b/lib/backlogs_issue_patch.rb @@ -161,9 +161,13 @@ module Backlogs touched_sprint.touch_burndown end - if ! self.in_list? && self.is_story? - self.insert_at - self.move_to_bottom + if self.in_list? + self.remove_from_list if self.is_task? + else + if self.is_story? + self.insert_at + self.move_to_bottom + end end end