diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index e2034522..4e946f5c 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -221,7 +221,13 @@ class TodosController < ApplicationController @saved = @todo.update_attributes params["todo"] @context_changed = @original_item_context_id != @todo.context_id @todo_was_activated_from_deferred_state = @original_item_was_deferred && @todo.active? - determine_remaining_in_context_count(@original_item_context_id) if @context_changed + + if @context_changed + determine_remaining_in_context_count(@original_item_context_id) + else + determine_remaining_in_context_count(@todo.context_id) + end + @project_changed = @original_item_project_id != @todo.project_id if (@project_changed && !@original_item_project_id.nil?) then @remaining_undone_in_project = current_user.projects.find(@original_item_project_id).not_done_todo_count; end determine_down_count @@ -390,7 +396,9 @@ class TodosController < ApplicationController @todo = Todo.find(params[:id]) @todo.show_from = (@todo.show_from || @todo.user.date) + numdays.days @saved = @todo.save - + + determine_down_count + determine_remaining_in_context_count(@todo.context_id) respond_to do |format| format.html { redirect_to :back } format.js {render :action => 'update'} diff --git a/app/views/todos/update.js.rjs b/app/views/todos/update.js.rjs index 582460ff..dae71f41 100644 --- a/app/views/todos/update.js.rjs +++ b/app/views/todos/update.js.rjs @@ -16,10 +16,18 @@ if @saved if (@remaining_in_context == 0) # remove context container from page if empty - source_view do |from| - from.todo { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 } - from.tag { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 } - from.context { page.show "c#{@original_item_context_id}empty-nd" } + if @context_changed + source_view do |from| + from.todo { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 } + from.tag { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 } + from.context { page.show "c#{@original_item_context_id}empty-nd" } + end + else + source_view do |from| + from.todo { page.visual_effect :fade, item_container_id(@todo), :duration => 0.4 } + from.tag { page.visual_effect :fade, item_container_id(@todo), :duration => 0.4 } + from.context { page.show "c#{@original_item_context_id}empty-nd" } + end end end diff --git a/test/selenium/home/defer_todo_empty_context.rsel b/test/selenium/home/defer_todo_empty_context.rsel new file mode 100644 index 00000000..afb56fd7 --- /dev/null +++ b/test/selenium/home/defer_todo_empty_context.rsel @@ -0,0 +1,10 @@ +setup :fixtures => :all +login :as => 'admin' +open "/" +click "edit_icon_todo_5" +wait_for_element_present "show_from_todo_5" +type "show_from_todo_5", "1/1/2030" +click "css=#submit_todo_5" +wait_for_element_not_present "todo_5" +assert_text 'badge_count', '9' +wait_for_not_visible "c5" diff --git a/test/selenium/home/defer_todo_with_button_empty_context.rsel b/test/selenium/home/defer_todo_with_button_empty_context.rsel new file mode 100644 index 00000000..3997c0fb --- /dev/null +++ b/test/selenium/home/defer_todo_with_button_empty_context.rsel @@ -0,0 +1,8 @@ +setup :fixtures => :all +login :as => 'admin' +open "/" +wait_for_element_present '//div[@id="line_todo_5"]//img[@alt="Defer_1"]/..' +click '//div[@id="line_todo_5"]//img[@alt="Defer_1"]/..' +wait_for_element_not_present "todo_5" +assert_text 'badge_count', '9' +wait_for_not_visible "c5"