From ab2f0f8201e5107d274f56e03daa6866ba5d9321 Mon Sep 17 00:00:00 2001 From: lrbalt Date: Sun, 16 Mar 2008 22:48:29 +0000 Subject: [PATCH] fixes #660. New todos that belong to hidden or completed project are not added to home page or context page. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@744 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/contexts_controller.rb | 2 +- tracks/app/controllers/todos_controller.rb | 2 +- tracks/app/helpers/todos_helper.rb | 26 ++++++++++++------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tracks/app/controllers/contexts_controller.rb b/tracks/app/controllers/contexts_controller.rb index 86855c78..493859e4 100644 --- a/tracks/app/controllers/contexts_controller.rb +++ b/tracks/app/controllers/contexts_controller.rb @@ -166,7 +166,7 @@ class ContextsController < ApplicationController # search manually until I can work out a way to do the same thing using # not_done_todos acts_as_todo_container method Hides actions in hidden # projects from context. - @not_done_todos = @context.todos.find(:all, :conditions => ['todos.state = ?', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [:project, :tags]) + @not_done_todos = @context.todos.find(:all, :conditions => ['todos.state = ? AND projects.state = ?', 'active', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [:project, :tags]) @count = @not_done_todos.size @default_project_context_name_map = build_default_project_context_name_map(@projects).to_json end diff --git a/tracks/app/controllers/todos_controller.rb b/tracks/app/controllers/todos_controller.rb index b9606880..6553bd85 100644 --- a/tracks/app/controllers/todos_controller.rb +++ b/tracks/app/controllers/todos_controller.rb @@ -414,7 +414,7 @@ class TodosController < ApplicationController @todos = Todo.find(:all, :conditions => ['todos.user_id = ? and todos.state = ? or todos.state = ?', current_user.id, 'active', 'completed'], :include => [ :project, :context, :tags ]) # Exclude hidden projects from the home page - @not_done_todos = Todo.find(:all, :conditions => ['todos.user_id = ? and todos.state = ? and projects.state = ?', current_user.id, 'active', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [ :project, :context, :tags ]) + @not_done_todos = Todo.find(:all, :conditions => ['todos.user_id = ? and todos.state = ? AND (projects.state = ? OR todos.project_id IS NULL)', current_user.id, 'active', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [ :project, :context, :tags ]) end diff --git a/tracks/app/helpers/todos_helper.rb b/tracks/app/helpers/todos_helper.rb index 6284e91f..3185b725 100644 --- a/tracks/app/helpers/todos_helper.rb +++ b/tracks/app/helpers/todos_helper.rb @@ -1,7 +1,7 @@ module TodosHelper - #require 'users_controller' - # Counts the number of incomplete items in the specified context + # #require 'users_controller' Counts the number of incomplete items in the + # specified context # def count_items(context) count = Todo.find_all("done=0 AND context_id=#{context.id}").length @@ -14,12 +14,12 @@ module TodosHelper :id => dom_id(@todo, 'form'), :class => dom_id(@todo, 'form') + " inline-form edit_todo_form" }, &block ) - apply_behavior 'form.edit_todo_form', make_remote_form( - :method => :put, - :before => "this.down('button.positive').startWaiting()", - :loaded => "this.down('button.positive').stopWaiting()", - :condition => "!(this.down('button.positive').isWaiting())"), - :prevent_default => true + apply_behavior 'form.edit_todo_form', make_remote_form( + :method => :put, + :before => "this.down('button.positive').startWaiting()", + :loaded => "this.down('button.positive').stopWaiting()", + :condition => "!(this.down('button.positive').isWaiting())"), + :prevent_default => true end def remote_delete_icon @@ -79,7 +79,7 @@ module TodosHelper end apply_behavior '.item-container input.item-checkbox:click', remote_function(:url => javascript_variable('this.value'), :method => 'put', - :with => parameters) + :with => parameters) str end @@ -196,6 +196,14 @@ module TodosHelper end def should_show_new_item + + if @todo.project.nil? == false + # do not show new actions that were added to hidden or completed projects + # on home page and context page + return false if source_view_is(:todo) && (@todo.project.hidden? || @todo.project.completed?) + return false if source_view_is(:context) && (@todo.project.hidden? || @todo.project.completed?) + end + return true if source_view_is(:deferred) && @todo.deferred? return true if source_view_is(:project) && @todo.project.hidden? && @todo.project_hidden? return true if source_view_is(:project) && @todo.deferred?