From 9fa5ead8de3946a66378d9037c88442b00f0b075 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Tue, 1 Dec 2009 23:39:07 -0500 Subject: [PATCH] Fixed another edge case that Luis caught Thanks for testing! --- app/controllers/todos_controller.rb | 2 ++ app/views/todos/destroy.js.rjs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 43c693f8..95e29b8c 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -368,10 +368,12 @@ class TodosController < ApplicationController # activate successors if they only depend on this todo activated_successor_count = 0 + @pending_to_activate = [] @todo.pending_successors.each do |successor| successor.uncompleted_predecessors.delete(@todo) if successor.uncompleted_predecessors.empty? successor.activate! + @pending_to_activate << successor activated_successor_count += 1 end end diff --git a/app/views/todos/destroy.js.rjs b/app/views/todos/destroy.js.rjs index 8d7d5666..f4e19622 100644 --- a/app/views/todos/destroy.js.rjs +++ b/app/views/todos/destroy.js.rjs @@ -23,6 +23,14 @@ if @saved end end end + + # Activate pending todos that are successors of the deleted + @pending_to_activate.each do |t| + logger.debug "#300: Removing #{t.description} from pending block and adding it to active" + page[t].remove if source_view_is(:project) or source_view_is(:tag) + page.insert_html :bottom, item_container_id(t), :partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type } + page.visual_effect :highlight, dom_id(t, 'line'), {'startcolor' => "'#99ff99'", :duration => 2} + end else page.notify :error, "There was an error deleting the item #{@todo.description}", 8.0 end