Ticket #300: Improved ajax behavior

Conflicts:

	app/views/todos/create.js.rjs
	app/views/todos/update.js.rjs
This commit is contained in:
Eric Allen 2009-11-10 22:17:00 -05:00
parent a91547265d
commit d14d09559e
3 changed files with 20 additions and 2 deletions

View file

@ -246,6 +246,7 @@ module TodosHelper
return true if source_view_is(:project) && @todo.deferred? return true if source_view_is(:project) && @todo.deferred?
return true if !source_view_is(:deferred) && @todo.active? return true if !source_view_is(:deferred) && @todo.active?
return true if source_view_is(:project) && @todo.pending? return true if source_view_is(:project) && @todo.pending?
return true if source_view_is(:tag) && @todo.pending?
return false return false
end end

View file

@ -2,6 +2,7 @@ if @saved
page.hide 'status' page.hide 'status'
status_message = 'Added new next action' status_message = 'Added new next action'
status_message += ' to tickler' if @todo.deferred? status_message += ' to tickler' if @todo.deferred?
status_message += ' in pending state' if @todo.pending?
status_message = 'Added new project / ' + status_message if @new_project_created status_message = 'Added new project / ' + status_message if @new_project_created
status_message = 'Added new context / ' + status_message if @new_context_created status_message = 'Added new context / ' + status_message if @new_context_created
page.notify :notice, status_message, 5.0 page.notify :notice, status_message, 5.0
@ -21,11 +22,20 @@ if @saved
page.visual_effect :highlight, dom_id(@todo), :duration => 3 page.visual_effect :highlight, dom_id(@todo), :duration => 3
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
end end
# make sure the behavior of the new/updated todo is enabled
if (source_view_is :project and @todo.pending?) or (source_view_is :deferred) if (source_view_is :project and @todo.pending?) or (source_view_is :deferred)
page['tickler-empty-nd'].hide # For some reason this does not work: page['tickler-empty-nd'].hide if (@todo.pending? or (source_view_is :deferred)) page['tickler-empty-nd'].hide # For some reason this does not work: page['tickler-empty-nd'].hide if (@todo.pending? or (source_view_is :deferred))
end end
end end
# Update predecessors (if they exist and are visible)
@todo.uncompleted_predecessors.each do |p|
page << "if ($(\'#{item_container_id(p)}\')) {"
page[p].replace_html :partial => 'todos/todo',
:locals => { :todo => p, :parent_container_type => parent_container_type }
page << "}"
end
# make sure the behavior of the new/updated todo is enabled
page << "TodoBehavior.enableToggleNotes()"
page << "TodoBehavior.enableToggleSuccessors()"
else else
page.show 'status' page.show 'status'
page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}" page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}"

View file

@ -7,7 +7,7 @@ if @saved
page.notify :notice, status_message, 5.0 page.notify :notice, status_message, 5.0
if source_view_is_one_of(:todo, :context, :tag) if source_view_is_one_of(:todo, :context, :tag)
if @context_changed || @todo.deferred? if @context_changed || @todo.deferred? || @todo.pending?
page[@todo].remove page[@todo].remove
if (@remaining_in_context == 0) if (@remaining_in_context == 0)
@ -142,6 +142,13 @@ if @saved
else else
logger.error "unexpected source_view '#{params[:_source_view]}'" logger.error "unexpected source_view '#{params[:_source_view]}'"
end end
# Update predecessors (if they exist and are visible)
@todo.uncompleted_predecessors.each do |p|
page << "if ($(\'#{item_container_id(p)}\')) {"
page[p].replace_html :partial => 'todos/todo',
:locals => { :todo => p, :parent_container_type => parent_container_type }
page << "}"
end
else else
page.show 'error_status' page.show 'error_status'
page.replace_html 'error_status', "#{error_messages_for('todo')}" page.replace_html 'error_status', "#{error_messages_for('todo')}"