Fixed #523 (updating context in tickler does not move todo on screen)

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@583 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2007-09-10 04:17:01 +00:00
parent c3ccae9f9e
commit 0e53ea5890
10 changed files with 71 additions and 14 deletions

View file

@ -120,7 +120,7 @@ class TodosController < ApplicationController
respond_to do |format|
format.js do
if @saved
@remaining_undone_in_context = current_user.contexts.find(@todo.context_id).not_done_todo_count
determine_remaining_in_context_count(@todo.context_id)
determine_down_count
determine_completed_count
end
@ -192,7 +192,7 @@ 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?
if @context_changed then @remaining_undone_in_context = current_user.contexts.find(@original_item_context_id).not_done_todo_count; end
determine_remaining_in_context_count(@original_item_context_id) if @context_changed
@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
@ -231,7 +231,7 @@ class TodosController < ApplicationController
determine_down_count
source_view do |from|
from.todo do
@remaining_undone_in_context = current_user.contexts.find(@context_id).not_done_todo_count
determine_remaining_in_context_count(@context_id)
end
end
end
@ -459,6 +459,14 @@ class TodosController < ApplicationController
end
end
def determine_remaining_in_context_count(context_id = @todo.context_id)
if source_view_is :deferred
@remaining_in_context = current_user.contexts.find(context_id).deferred_todo_count
else
@remaining_in_context = current_user.contexts.find(context_id).not_done_todo_count
end
end
def determine_completed_count
source_view do |from|
from.todo do

View file

@ -181,7 +181,6 @@ module TodosHelper
def empty_container_msg_div_id
return "tickler-empty-nd" if source_view_is(:project) && @todo.deferred?
return "p#{@todo.project_id}empty-nd" if source_view_is :project
return "tickler-empty-nd" if source_view_is :deferred
return "c#{@todo.context_id}empty-nd"
end

View file

@ -69,7 +69,7 @@ function initializeNamesForAutoComplete(contextNamesForAutoComplete) {
Event.observe($('todo_context_name'), "click", contextAutoCompleter.activate.bind(contextAutoCompleter));
}
function updateContextNamesForAutoComplete(contextNamesForAutoComplete) {
if (contextAutoCompleter) // if we're already initialized
if (contextAutoCompleter) // i.e. if we're already initialized
{
contextAutoCompleter.options.array = contextNamesForAutoComplete
}

View file

@ -1,7 +1,7 @@
if @saved
page[@todo].remove
page['badge_count'].replace_html @down_count
page.visual_effect :fade, item_container_id, :duration => 0.4 if source_view_is(:todo) && @remaining_undone_in_context == 0
page.visual_effect :fade, item_container_id, :duration => 0.4 if source_view_is(:todo) && @remaining_in_context == 0
page[empty_container_msg_div_id].show if !empty_container_msg_div_id.nil? && @down_count == 0
else
page.notify :error, "There was an error deleting the item #{@todo.description}", 8.0

View file

@ -9,7 +9,7 @@ if @saved
page.show 'tickler-empty-nd' if source_view_is(:project) && @deferred_count == 0
page.hide 'empty-d' # If we've checked something as done, completed items can't be empty
end
if @remaining_undone_in_context == 0 && source_view_is(:todo)
if @remaining_in_context == 0 && source_view_is(:todo)
page.visual_effect :fade, item_container_id, :duration => 0.4
end
else

View file

@ -9,7 +9,7 @@ if @saved
if source_view_is_one_of [:todo, :context]
if @context_changed || @todo.deferred?
page[@todo].remove
if (@remaining_undone_in_context == 0)
if (@remaining_in_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" }
@ -21,7 +21,7 @@ if @saved
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
page.insert_html :bottom, "c#{@todo.context_id}items", :partial => 'todos/todo', :locals => { :parent_container_type => parent_container_type }
end
page.replace_html("badge_count", @remaining_undone_in_context) if source_view_is :context
page.replace_html("badge_count", @remaining_in_context) if source_view_is :context
page.replace_html("badge_count", @down_count) if source_view_is :todo
page.delay(0.5) do
page.call "todoItems.ensureContainerHeight", "c#{@original_item_context_id}items"
@ -56,14 +56,28 @@ if @saved
page.visual_effect :highlight, dom_id(@todo), :duration => 3
end
elsif source_view_is :deferred
if @todo.deferred?
page.replace dom_id(@todo), :partial => 'todos/todo', :locals => { :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(@todo), :duration => 3
else
if !@todo.deferred?
page[@todo].remove
page.show(empty_container_msg_div_id) if (@down_count == 0)
page.replace_html "badge_count", @down_count
end
elsif @context_changed
page[@todo].remove
page.call "console.log", "'@remaining_in_context = #{@remaining_in_context}'"
page.visual_effect(:fade, "c#{@original_item_context_id}", :duration => 0.4) if (@remaining_in_context == 0)
page.call "todoItems.ensureVisibleWithEffectAppear", "c#{@todo.context_id}"
page.call "todoItems.expandNextActionListingByContext", "c#{@todo.context_id}items", true
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
page.insert_html :bottom, "c#{@todo.context_id}items", :partial => 'todos/todo', :locals => { :parent_container_type => parent_container_type }
page.replace_html("badge_count", @down_count)
page.delay(0.5) do
page.call "todoItems.ensureContainerHeight", "c#{@original_item_context_id}items"
page.call "todoItems.ensureContainerHeight", "c#{@todo.context_id}items"
page.visual_effect :highlight, dom_id(@todo), :duration => 3
end
else
page.replace dom_id(@todo), :partial => 'todos/todo', :locals => { :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(@todo), :duration => 3
end
else
logger.error "unexpected source_view '#{params[:_source_view]}'"
end

View file

@ -25,6 +25,10 @@ module Tracks
base.send(:helper, Tracks::SourceViewSwitching::Helper)
base.send(:helper_method, :source_view)
end
def source_view_is( s )
s == (params[:_source_view] || @source_view).to_sym
end
def source_view
responder = Tracks::SourceViewSwitching::Responder.new(params[:_source_view] || @source_view)

View file

@ -0,0 +1,12 @@
setup :fixtures => :all
login :as => 'admin'
open "/tickler"
click "edit_icon_todo_15"
wait_for_visible "context_name_todo_15"
type "context_name_todo_15", "lab"
click "submit_todo_15"
wait_for_element_not_present "css=#c6 #todo_15"
wait_for_visible "c5"
wait_for_visible "css=#c5 #todo_15"
assert_not_visible "c5empty-nd"
wait_for_not_visible "c6"

View file

@ -0,0 +1,10 @@
setup :fixtures => :all
login :as => 'admin'
open "/tickler"
store_eval "this.browserbot.getCurrentWindow().$$('.context').length", 'initial_context_count'
type "todo_description", "a new action"
type "todo_context_name", "errands"
type "todo_show_from", "1/1/2030"
click "css=#todo-form-new-action .submit_box button"
store_eval "${initial_context_count} + 1", 'expected_context_count'
wait_for_eval "this.browserbot.getCurrentWindow().$$('.context').length", "${expected_context_count}"

View file

@ -0,0 +1,10 @@
setup :fixtures => :all
login :as => 'admin'
open "/tickler"
store_eval "this.browserbot.getCurrentWindow().$$('.context').length", 'initial_context_count'
type "todo_description", "a new action"
type "todo_context_name", "Brand new context"
type "todo_show_from", "1/1/2030"
click "css=#todo-form-new-action .submit_box button"
store_eval "${initial_context_count} + 1", 'expected_context_count'
wait_for_eval "this.browserbot.getCurrentWindow().$$('.context').length", "${expected_context_count}"