if @saved # show update message status_message = 'Action saved' status_message += ' to tickler' if @todo.deferred? status_message = 'Added new project / ' + status_message if @new_project_created status_message = 'Added new context / ' + status_message if @new_context_created page.notify :notice, status_message, 5.0 # update auto completer arrays for edit form in right column, only for pages # with that form unless source_view_is_one_of(:calendar) page << "contextAutoCompleter.options.array = #{context_names_for_autocomplete}; contextAutoCompleter.changed = true" if @new_context_created page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}; projectAutoCompleter.changed = true" if @new_project_created end if source_view_is_one_of(:todo, :context, :tag) if @context_changed || @todo.deferred? page[@todo].remove if (@remaining_in_context == 0) # remove context container from page if empty 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 if source_view_is_one_of(:todo, :tag) && @todo.active? 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? # show all todos in context page.insert_html :bottom, "c#{@todo.context_id}items", :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } end if source_view_is(:tag) && @todo.deferred? # show todo in deferred container page.insert_html :bottom, "tickleritems", :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? end # update badge count 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 # show todo in context page.delay(0.5) do page.call "todoItems.ensureContainerHeight", "c#{@original_item_context_id}items" if source_view_is_one_of(:todo, :tag) && @todo.active? page.call "todoItems.ensureContainerHeight", "c#{@todo.context_id}items" page.visual_effect :highlight, dom_id(@todo), :duration => 3 end end else if @original_item_was_deferred && source_view_is(:tag) # we go from the deferred container to a context container in tag view page[@todo].remove 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? # show all todos in context page.insert_html :bottom, "c#{@todo.context_id}items", :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } page['tickler-empty-nd'].show if @deferred_tag_count == 0 else page.replace dom_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } end page.visual_effect :highlight, dom_id(@todo), :duration => 3 end elsif source_view_is :project if @project_changed page[@todo].remove page.show("p#{@original_item_project_id}empty-nd") if (@remaining_undone_in_project == 0) page.replace_html "badge_count", @remaining_undone_in_project elsif @todo.deferred? page[@todo].remove page.show("p#{@original_item_project_id}empty-nd") if (@remaining_undone_in_project == 0) page.insert_html :bottom, "tickler", :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } page['tickler-empty-nd'].hide page.replace_html "badge_count", @down_count elsif @todo_was_activated_from_deferred_state page[@todo].remove page['tickler-empty-nd'].show if (@deferred_count == 0) page.insert_html :bottom, "p#{@todo.project_id}", :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } page["p#{@todo.project_id}empty-nd"].hide page.replace_html "badge_count", @down_count else page.replace dom_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } page.visual_effect :highlight, dom_id(@todo), :duration => 3 end elsif source_view_is :deferred if !@todo.deferred? page[@todo].remove page.show(empty_container_msg_div_id) if (@down_count == 0) page.replace_html "badge_count", @down_count elsif @context_changed page[@todo].remove 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 => { :todo => @todo, :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 => { :todo => @todo, :parent_container_type => parent_container_type } page.visual_effect :highlight, dom_id(@todo), :duration => 3 end elsif source_view_is :stats page.replace dom_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } page.visual_effect :highlight, dom_id(@todo), :duration => 3 elsif source_view_is :calendar if @due_date_changed page[@todo].remove page.show "empty_"+@original_item_due_id if @old_due_empty page.hide "empty_"+@new_due_id page.insert_html :bottom, @new_due_id, :partial => 'todos/todo', :locals => {:todo => @todo} page.visual_effect :highlight, dom_id(@todo), :duration => 3 else if @todo.due.nil? # due date removed page[@todo].remove page.show "empty_"+@original_item_due_id if @old_due_empty else page.replace dom_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type } page.visual_effect :highlight, dom_id(@todo), :duration => 3 end end else logger.error "unexpected source_view '#{params[:_source_view]}'" end # make sure the behavior of the new/updated todo is enabled page << "TodoBehavior.enableToggleNotes()" else page.show 'error_status' page.replace_html 'error_status', "#{error_messages_for('todo')}" end