Tinkered a bit with the display of actions in hidden projects. It seems to me that hidden projects are ones that are in some sense 'on hold', so you probably don't want actions in those projects displayed on the home page, or on the context pages (though you still want to be able to view that project to evaluate whether it should be made active, and perhaps queue up more actions in it).

Now actions in hidden projects are hidden on the home page and context pages. Hidden projects are also listed separately in the sidebar (this should perhaps be included in the user preference for showing completed projects in the sidebar). The counts in the sidebar for projects and contexts *include* the hidden project actions, because I haven't fixed that yet. Also, excluding the hidden project actions is done in a really clunky way until I can get my head around the new acts_as_todo_container class.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@339 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2006-11-12 19:12:36 +00:00
parent e957f86cd1
commit a4963a9883
6 changed files with 39 additions and 18 deletions

View file

@ -92,6 +92,7 @@ class ApplicationController < ActionController::Base
init_not_done_counts
end
# TODO: Need to exclude hidden projects from this count
def init_not_done_counts(parents = ['project','context'])
parents.each do |parent|
eval("@#{parent}_not_done_counts = Todo.count(:all,

View file

@ -23,7 +23,7 @@ class ContextController < ApplicationController
end
# Filter the projects to show just the one passed in the URL
# e.g. <home>/project/show/<project_name> shows just <project_name>.
# e.g. <home>/context/<context_name> shows just <context_name>.
#
def show
init
@ -206,7 +206,10 @@ class ContextController < ApplicationController
def init
@source_view = params['_source_view'] || 'context'
@projects = @user.projects.reject { |x| x.completed? }
# If we exclude completed projects, then we can't display them in the sidebar
# if the user sets the preference for them to be shown
# @projects = @user.projects.reject { |x| x.completed? }
@projects = @user.projects
@contexts = @user.contexts
@todos = @user.todos
@done = Todo.find(:all, :conditions => ["todos.user_id = ? and todos.done = ?", @user.id, true], :include => [:project], :order => "completed DESC")
@ -216,7 +219,14 @@ class ContextController < ApplicationController
def init_todos
check_user_set_context
@done = @context.done_todos
@not_done_todos = @context.not_done_todos
# @not_done_todos = @context.not_done_todos
# TODO: Temporarily doing this 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 = Todo.find(:all,
:conditions => ["todos.context_id = ? and todos.done = ? and todos.type = ? and (projects.state != ? or todos.project_id is ?)", @context.id, false, "Immediate", "hidden", nil],
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
:include => [:project])
@count = @not_done_todos.size
end

View file

@ -8,7 +8,7 @@ class TodoController < ApplicationController
prepend_before_filter :login_required
append_before_filter :init, :except => [ :destroy, :completed, :completed_archive ]
layout "standard"
layout "standard", :except => :date_preview
# Main method for listing tasks
# Set page title, and fill variables with contexts and done and not-done tasks
@ -274,12 +274,14 @@ class TodoController < ApplicationController
end
def init_todos
# Exclude hidden projects from count on home page
@todos = Todo.find(:all,
:conditions => ['todos.user_id = ? and todos.type = ?', @user.id, "Immediate"],
:conditions => ['todos.user_id = ? and todos.type = ? and (projects.state != ? or todos.project_id is ?)', @user.id, "Immediate", "hidden", nil],
:include => [ :project, :context ])
# Exclude hidden projects from the home page
@not_done_todos = Todo.find(:all,
:conditions => ['todos.user_id = ? and todos.type = ? and todos.done = ?', @user.id, "Immediate", false],
:conditions => ['todos.user_id = ? and todos.type = ? and todos.done = ? and (projects.state != ? or todos.project_id is ?)', @user.id, "Immediate", false, "hidden", nil],
:order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC",
:include => [ :project, :context ])
end

View file

@ -70,11 +70,11 @@
<%= end_form_tag %><!--[eoform:todo]-->
<%= observe_field "todo_due",
:frequency => 1,
:frequency => 2,
:update => "date-preview",
:with => "todo_due",
:complete => "Element.show('date-preview')",
:url => { :action => "date_preview" } %>
:url => { :controller => "todo", :action => "date_preview" } %>
<%= calendar_setup( "todo_due" ) %>
<% if controller.controller_name == "deferred" -%>

View file

@ -6,6 +6,14 @@
<% end -%>
</ul>
<h3>Hidden Projects:</h3>
<ul>
<% for project in @projects.select{|p| p.hidden? } -%>
<li id="sidebar-project-<%= project.id %>" class="sidebar-project"><%= link_to( sanitize(project.name), { :controller => "project", :action => "show", :name => urlize(project.name) } ) + " (" + count_undone_todos(project,"actions") + ")" %></li>
<% end -%>
</ul>
<% if @user.preference.show_completed_projects_in_sidebar %>
<h3>Completed Projects:</h3>
<ul>

View file

@ -6,9 +6,9 @@ ActiveRecord::Schema.define(:version => 18) do
create_table "contexts", :force => true do |t|
t.column "name", :string, :default => "", :null => false
t.column "hide", :integer, :limit => 4, :default => 0, :null => false
t.column "position", :integer, :default => 0, :null => false
t.column "user_id", :integer, :default => 0, :null => false
t.column "hide", :boolean, :default => false
t.column "user_id", :integer, :default => 1
end
create_table "notes", :force => true do |t|
@ -55,7 +55,7 @@ ActiveRecord::Schema.define(:version => 18) do
create_table "projects", :force => true do |t|
t.column "name", :string, :default => "", :null => false
t.column "position", :integer, :default => 0, :null => false
t.column "user_id", :integer, :default => 0, :null => false
t.column "user_id", :integer, :default => 1
t.column "description", :text
t.column "state", :string, :limit => 20, :default => "active", :null => false
end
@ -70,23 +70,23 @@ ActiveRecord::Schema.define(:version => 18) do
create_table "todos", :force => true do |t|
t.column "context_id", :integer, :default => 0, :null => false
t.column "description", :string, :limit => 100, :default => "", :null => false
t.column "project_id", :integer
t.column "description", :string, :default => "", :null => false
t.column "notes", :text
t.column "done", :integer, :limit => 4, :default => 0, :null => false
t.column "done", :boolean, :default => false, :null => false
t.column "created_at", :datetime
t.column "due", :date
t.column "completed", :datetime
t.column "project_id", :integer
t.column "user_id", :integer, :default => 0, :null => false
t.column "user_id", :integer, :default => 1
t.column "type", :string, :default => "Immediate", :null => false
t.column "show_from", :date
end
create_table "users", :force => true do |t|
t.column "login", :string, :limit => 80
t.column "password", :string, :limit => 40
t.column "login", :string, :limit => 80, :default => "", :null => false
t.column "password", :string, :limit => 40, :default => "", :null => false
t.column "word", :string
t.column "is_admin", :integer, :limit => 4, :default => 0, :null => false
t.column "is_admin", :boolean, :default => false, :null => false
t.column "first_name", :string
t.column "last_name", :string
t.column "auth_type", :string, :default => "database", :null => false