2007-03-30 04:36:52 +00:00
|
|
|
if @saved
|
|
|
|
|
page[@todo].remove
|
2008-10-04 15:56:22 +02:00
|
|
|
page.show "empty_"+@original_item_due_id if @old_due_empty
|
2007-03-30 04:36:52 +00:00
|
|
|
if @todo.completed?
|
2008-08-05 11:00:04 +02:00
|
|
|
|
2008-07-19 20:27:45 +02:00
|
|
|
# completed todos move from their context to the completed container
|
2007-03-30 04:36:52 +00:00
|
|
|
unless @prefs.hide_completed_actions?
|
2008-11-30 20:16:57 +01:00
|
|
|
page.insert_html :top, "completed_containeritems", :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => "completed" }
|
2007-03-30 04:36:52 +00:00
|
|
|
page.visual_effect :highlight, dom_id(@todo, 'line'), {'startcolor' => "'#99ff99'"}
|
|
|
|
|
page[empty_container_msg_div_id].show if @down_count == 0 && !empty_container_msg_div_id.nil?
|
2009-11-04 22:32:44 -05:00
|
|
|
page.show 'tickler-empty-nd' if source_view_is(:project) && @deferred_count == 0 && @pending_count == 0
|
2007-03-30 04:36:52 +00:00
|
|
|
page.hide 'empty-d' # If we've checked something as done, completed items can't be empty
|
|
|
|
|
end
|
2009-11-04 22:32:44 -05:00
|
|
|
# Activate pending todos that are successors of the completed
|
|
|
|
|
@pending_to_activate.each do |t|
|
|
|
|
|
logger.debug "#300: Removing #{t.description} from pending block and adding it to active"
|
2009-11-04 22:37:33 -05:00
|
|
|
page[t].remove if source_view_is(:project) or source_view_is(:tag)
|
2009-11-04 22:32:44 -05:00
|
|
|
page.insert_html :bottom, item_container_id(t), :partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type }
|
2009-08-16 00:34:08 +02:00
|
|
|
page.visual_effect :highlight, dom_id(t, 'line'), {'startcolor' => "'#99ff99'"}
|
2009-11-04 22:32:44 -05:00
|
|
|
end
|
2008-07-19 20:27:45 +02:00
|
|
|
|
|
|
|
|
# remove container if empty
|
2009-12-20 13:05:42 -05:00
|
|
|
if @remaining_in_context == 0 && source_view_is_one_of(:todo, :tag)
|
2009-10-07 11:54:42 -04:00
|
|
|
page.visual_effect :fade, "c"+@todo.context.id.to_s, :duration => 0.4
|
2007-03-30 04:36:52 +00:00
|
|
|
end
|
2009-04-14 21:36:57 +02:00
|
|
|
|
|
|
|
|
if @original_item_was_deferred && source_view_is(:tag)
|
|
|
|
|
# we go from the deferred container to the completed container in tag view
|
|
|
|
|
# check for empty message
|
|
|
|
|
page['tickler-empty-nd'].show if @deferred_tag_count == 0
|
|
|
|
|
end
|
|
|
|
|
|
2008-07-19 20:27:45 +02:00
|
|
|
# show new todo if the completed todo was recurring
|
2008-08-05 11:00:04 +02:00
|
|
|
if @todo.from_recurring_todo?
|
|
|
|
|
unless @new_recurring_todo.nil? || @new_recurring_todo.deferred?
|
|
|
|
|
page.call "todoItems.ensureVisibleWithEffectAppear", item_container_id(@new_recurring_todo)
|
|
|
|
|
page.insert_html :bottom, item_container_id(@new_recurring_todo), :partial => 'todos/todo', :locals => { :todo => @new_recurring_todo, :parent_container_type => parent_container_type }
|
|
|
|
|
page.visual_effect :highlight, dom_id(@new_recurring_todo, 'line'), {'startcolor' => "'#99ff99'"}
|
|
|
|
|
else
|
2008-11-28 16:39:50 +01:00
|
|
|
if @todo.recurring_todo.todos.active.count == 0
|
2010-10-31 21:27:13 +08:00
|
|
|
page.notify :notice, t('todos.recurrence_completed'), 6.0 if @new_recurring_todo.nil?
|
2008-11-28 16:39:50 +01:00
|
|
|
end
|
2008-08-05 11:00:04 +02:00
|
|
|
end
|
2008-07-19 20:27:45 +02:00
|
|
|
end
|
2008-10-04 15:56:22 +02:00
|
|
|
|
2007-03-30 04:36:52 +00:00
|
|
|
else
|
2008-07-19 20:27:45 +02:00
|
|
|
# todo is activated from completed container
|
|
|
|
|
page.call "todoItems.ensureVisibleWithEffectAppear", item_container_id(@todo)
|
2008-11-30 20:16:57 +01:00
|
|
|
page.insert_html :bottom, item_container_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type }
|
2007-03-30 04:36:52 +00:00
|
|
|
page.visual_effect :highlight, dom_id(@todo, 'line'), {'startcolor' => "'#99ff99'"}
|
|
|
|
|
page.show "empty-d" if @completed_count == 0
|
2009-10-07 11:54:42 -04:00
|
|
|
page.show "c"+@todo.context.id.to_s
|
2007-03-30 04:36:52 +00:00
|
|
|
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil? # If we've checked something as undone, incomplete items can't be empty
|
2009-11-04 22:32:44 -05:00
|
|
|
# If active todos are successors of the reactivated todo they will be blocked
|
|
|
|
|
@active_to_block.each do |t|
|
|
|
|
|
logger.debug "#300: Block #{t.description} that are a successor of #{@todo.description}"
|
|
|
|
|
page[t].remove # Remove it from active
|
2009-11-04 22:37:33 -05:00
|
|
|
if source_view_is(:project) or source_view_is(:tag) # Insert it in deferred/pending block if existing
|
|
|
|
|
logger.debug "Insert #{t.description} in #{item_container_id(t)} block"
|
2009-05-21 01:55:53 +02:00
|
|
|
page.insert_html :bottom, item_container_id(t), :partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type }
|
|
|
|
|
end
|
2009-11-04 22:32:44 -05:00
|
|
|
end
|
2007-03-30 04:36:52 +00:00
|
|
|
end
|
2008-07-19 20:27:45 +02:00
|
|
|
|
2007-03-30 04:36:52 +00:00
|
|
|
page.hide "status"
|
|
|
|
|
page.replace_html "badge_count", @down_count
|
|
|
|
|
if @todo.completed? && !@todo.project_id.nil? && @prefs.show_project_on_todo_done && !source_view_is(:project)
|
|
|
|
|
page.redirect_to project_path(@todo.project_id)
|
|
|
|
|
end
|
|
|
|
|
else
|
2010-10-31 21:27:13 +08:00
|
|
|
page.replace_html "status", content_tag("div", content_tag("h2", t(:todo_errors, :count => @todo.errors.count)) + content_tag("p", t('common.errors_with_fields')) + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")
|
2009-03-31 09:56:23 +02:00
|
|
|
end
|