From ab9fa1fc46564e477a6168d61957143ec3caf93b Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Tue, 4 Aug 2009 14:03:31 +0200 Subject: [PATCH] fixes #929. Manually applied revision:37a45313a0c0876272a871093e112c159c34b547 because it did not cleanly apply with cherry-pick --- app/controllers/todos_controller.rb | 14 ++++++++++---- app/views/shared/_add_new_item_form.rhtml | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 6b9d8f3a..0c8aee33 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -47,6 +47,7 @@ class TodosController < ApplicationController def create @source_view = params['_source_view'] || 'todo' + @tag_name = params['_tag_name'] p = TodoCreateParamsHelper.new(params, prefs) p.parse_dates() unless mobile? @@ -702,10 +703,15 @@ class TodosController < ApplicationController 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') + tags = Tag.find_by_name(tag) + if tags.nil? + # should normally not happen, but is a workaround for #929 + @deferred_tag_count = 0 + else + @deferred_tag_count = tags.todos.count(:all, + :conditions => ['todos.user_id = ? and state = ?', current_user.id, 'deferred'], + :order => 'show_from ASC, todos.created_at DESC') + end end def render_todos_html diff --git a/app/views/shared/_add_new_item_form.rhtml b/app/views/shared/_add_new_item_form.rhtml index 2cc96c5e..d3d64c7d 100644 --- a/app/views/shared/_add_new_item_form.rhtml +++ b/app/views/shared/_add_new_item_form.rhtml @@ -110,7 +110,8 @@ $('todo_context_name').projectDefaultContextsMap = eval('(' + <%= @default_proje <%= text_field("todo", "show_from", "size" => 12, "class" => "Date", "onfocus" => "Calendar.setup", "tabindex" => 7, "autocomplete" => "off") %> -<%= source_view_tag( @source_view ) %> +<%= source_view_tag( @source_view ) %> +<%= hidden_field_tag :_tag_name, @tag_name.underscore.gsub(/\s+/,'_') if source_view_is :tag %>