From a4963a9883df8e5d71056cd6d38ddce913c5b64a Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 12 Nov 2006 19:12:36 +0000 Subject: [PATCH] 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 --- tracks/app/controllers/application.rb | 1 + tracks/app/controllers/context_controller.rb | 16 ++++++++++++--- tracks/app/controllers/todo_controller.rb | 8 +++++--- .../app/views/shared/_add_new_item_form.rhtml | 4 ++-- tracks/app/views/shared/sidebar.rhtml | 8 ++++++++ tracks/db/schema.rb | 20 +++++++++---------- 6 files changed, 39 insertions(+), 18 deletions(-) diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index 72a00488..dfc70269 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -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, diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index ae4c6c83..2f59848e 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -23,7 +23,7 @@ class ContextController < ApplicationController end # Filter the projects to show just the one passed in the URL - # e.g. /project/show/ shows just . + # e.g. /context/ shows just . # 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 diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 97019683..f2565e50 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -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 diff --git a/tracks/app/views/shared/_add_new_item_form.rhtml b/tracks/app/views/shared/_add_new_item_form.rhtml index 038c3303..cd45356d 100644 --- a/tracks/app/views/shared/_add_new_item_form.rhtml +++ b/tracks/app/views/shared/_add_new_item_form.rhtml @@ -70,11 +70,11 @@ <%= end_form_tag %> <%= 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" -%> diff --git a/tracks/app/views/shared/sidebar.rhtml b/tracks/app/views/shared/sidebar.rhtml index 2f10c582..6f456e4e 100644 --- a/tracks/app/views/shared/sidebar.rhtml +++ b/tracks/app/views/shared/sidebar.rhtml @@ -6,6 +6,14 @@ <% end -%> +

Hidden Projects:

+
    + <% for project in @projects.select{|p| p.hidden? } -%> + + <% end -%> +
+ + <% if @user.preference.show_completed_projects_in_sidebar %>

Completed Projects:

    diff --git a/tracks/db/schema.rb b/tracks/db/schema.rb index 321056ee..e5e4c2be 100644 --- a/tracks/db/schema.rb +++ b/tracks/db/schema.rb @@ -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