tracks/app/views/todos/toggle_check.js.erb

73 lines
4.2 KiB
Text
Raw Normal View History

if @saved
page[@todo].remove
page.show "empty_"+@original_item_due_id if @old_due_empty
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
unless @prefs.hide_completed_actions?
page.insert_html :top, "completed_containeritems", :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => "completed" }
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?
page.show 'tickler-empty-nd' if source_view_is(:project) && @deferred_count == 0 && @pending_count == 0
page.hide 'empty-d' # If we've checked something as done, completed items can't be empty
end
# 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"
page[t].remove if source_view_is(:project) or source_view_is(:tag)
page.insert_html :bottom, item_container_id(t), :partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(t, 'line'), {'startcolor' => "'#99ff99'"}
end
2008-07-19 20:27:45 +02:00
# remove container if empty
if @remaining_in_context == 0 && source_view_is_one_of(:todo, :tag)
page.visual_effect :fade, "c"+@todo.context.id.to_s, :duration => 0.4
end
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
if @todo.recurring_todo.todos.active.count == 0
page.notify :notice, t('todos.recurrence_completed'), 6.0 if @new_recurring_todo.nil?
end
2008-08-05 11:00:04 +02:00
end
2008-07-19 20:27:45 +02:00
end
else
2008-07-19 20:27:45 +02:00
# todo is activated from completed container
page.call "todoItems.ensureVisibleWithEffectAppear", item_container_id(@todo)
page.insert_html :bottom, item_container_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type }
page.visual_effect :highlight, dom_id(@todo, 'line'), {'startcolor' => "'#99ff99'"}
page.show "empty-d" if @completed_count == 0
page.show "c"+@todo.context.id.to_s
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
# 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
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"
page.insert_html :bottom, item_container_id(t), :partial => 'todos/todo', :locals => { :todo => t, :parent_container_type => parent_container_type }
end
end
end
2008-07-19 20:27:45 +02: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
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")
end