fix #867. deferring in tag view is now working

This commit is contained in:
Reinier Balt 2009-04-07 17:14:51 +02:00
parent 239b38cb15
commit 718685b4b5
3 changed files with 35 additions and 6 deletions

View file

@ -264,6 +264,8 @@ class TodosController < ApplicationController
@remaining_undone_in_project = current_user.projects.find(@original_item_project_id).not_done_todo_count
end
determine_down_count
determine_deferred_tag_count(params['_tag_name']) if @source_view == 'tag'
respond_to do |format|
format.js
format.xml { render :xml => @todo.to_xml( :except => :user_id ) }
@ -436,7 +438,7 @@ class TodosController < ApplicationController
@original_item_context_id = @todo.context_id
@todo.show_from = (@todo.show_from || @todo.user.date) + numdays.days
@saved = @todo.save
determine_down_count
determine_remaining_in_context_count(@todo.context_id)
respond_to do |format|
@ -694,6 +696,13 @@ class TodosController < ApplicationController
end
end
def determine_deferred_tag_count(tag)
tag_collection = Tag.find_by_name(tag).todos
@deferred_tag_count = tag_collection.count(:all,
:conditions => ['todos.user_id = ? and state = ?', current_user.id, 'deferred'],
:order => 'show_from ASC, todos.created_at DESC')
end
def render_todos_html
lambda do
@page_title = "TRACKS::List tasks"

View file

@ -239,7 +239,7 @@ module TodosHelper
end
def empty_container_msg_div_id
return "tickler-empty-nd" if source_view_is(:project) && @todo.deferred?
return "tickler-empty-nd" if source_view_is_one_of(:project, :tag) && @todo.deferred?
return "p#{@todo.project_id}empty-nd" if source_view_is :project
return "c#{@todo.context_id}empty-nd"
end
@ -276,7 +276,10 @@ module TodosHelper
end
def defer_link(days)
link_to_remote image_tag("defer_#{days}.png", :alt => "Defer #{pluralize(days, 'day')}"), :url => {:controller => 'todos', :action => 'defer', :id => @todo.id, :days => days, :_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")}
url = {:controller => 'todos', :action => 'defer', :id => @todo.id, :days => days,
:_source_view => (@source_view.underscore.gsub(/\s+/,'_') rescue "")}
url[:_tag_name] = @tag_name if @source_view == 'tag'
link_to_remote image_tag("defer_#{days}.png", :alt => "Defer #{pluralize(days, 'day')}"), :url => url
end
end

View file

@ -33,7 +33,7 @@ if @saved
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
@ -41,6 +41,12 @@ if @saved
# 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
@ -55,9 +61,20 @@ if @saved
end
end
else
page.replace dom_id(@todo), :partial => 'todos/todo', :locals => { :todo => @todo, :parent_container_type => parent_container_type }
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
end
elsif source_view_is :project
if @project_changed
page[@todo].remove