From dc73835c7bbec9c506b8af860397b3ea1f6e0efd Mon Sep 17 00:00:00 2001 From: lukemelia Date: Fri, 25 Aug 2006 03:57:26 +0000 Subject: [PATCH] Fix the Ajax corner case described in #353 : "change of todo's context on home page should work like marking complete" git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@316 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/todo_controller.rb | 1 + tracks/app/views/todo/update.rjs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index f0fb3a2f..3a9f48a7 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -133,6 +133,7 @@ class TodoController < ApplicationController params["item"]["due"] = "" end @saved = @item.update_attributes params["item"] + @remaining_undone_in_original_context = Todo.count(:conditions => ['user_id = ? and context_id = ? and type = ? and done = ?', @user.id, @original_item_context_id, "Immediate", false]) end def update_context diff --git a/tracks/app/views/todo/update.rjs b/tracks/app/views/todo/update.rjs index ebf006ff..dc954510 100644 --- a/tracks/app/views/todo/update.rjs +++ b/tracks/app/views/todo/update.rjs @@ -7,6 +7,13 @@ if @saved page.visual_effect :highlight, item_container_id, :duration => 3 else page[item_container_id].remove + if (@remaining_undone_in_original_context == 0) + source_view do |from| + from.todo { page.visual_effect :fade, "c#{@original_item_context_id}", :duration => 0.4 } + from.context { page.show "c#{@original_item_context_id}empty-nd" } + end + end + page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@item.context_id}" page.call "todoItems.expandNextActionListingByContext", "c#{@item.context_id}items", true page.insert_html :bottom, "c#{@item.context_id}items", :partial => 'todo/item', :locals => { :parent_container_type => "context" } page.delay(0.5) do