diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 783ab045..29d26d9a 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -24,7 +24,10 @@ class TodoController < ApplicationController @on_page = "home" @page_title = "TRACKS::List tasks" - @done = @done[0..(@user.preferences["no_completed"].to_i-1)] + # If you've set no_completed to zero, the completed items box + # isn't shown on the home page + max_completed = @user.preferences["no_completed"].to_i-1 + @done = (max_completed > 0) ? @done[0..max_completed] : nil @contexts_to_show = @contexts.clone @contexts_to_show = @contexts_to_show.collect {|x| (!x.hide? and !x.find_not_done_todos.empty?) ? x:nil }.compact diff --git a/tracks/app/models/context.rb b/tracks/app/models/context.rb index a65ead83..85179573 100644 --- a/tracks/app/models/context.rb +++ b/tracks/app/models/context.rb @@ -26,7 +26,7 @@ class Context < ActiveRecord::Base todos = Todo.find :all, :conditions => ["todos.context_id = #{id} AND todos.done = ?", true], :include => [:context, :project], :order => "due IS NULL, due ASC, created_at ASC", - :limit => @user.preferences["no_completed"] + :limit => @user.preferences["no_completed"].to_i end # Returns a count of next actions in the given context diff --git a/tracks/app/models/project.rb b/tracks/app/models/project.rb index 210f21d9..a04b5b05 100644 --- a/tracks/app/models/project.rb +++ b/tracks/app/models/project.rb @@ -24,7 +24,8 @@ class Project < ActiveRecord::Base def find_done_todos todos = Todo.find :all, :conditions => ["project_id = #{id} AND done = ?", true], - :order => "due IS NULL, due ASC, created_at ASC" + :order => "due IS NULL, due ASC, created_at ASC", + :limit => @user.preferences["no_completed"].to_i end # Returns a count of next actions in the given project diff --git a/tracks/app/views/context/show.rhtml b/tracks/app/views/context/show.rhtml index 1c6c8774..4b45492f 100644 --- a/tracks/app/views/context/show.rhtml +++ b/tracks/app/views/context/show.rhtml @@ -7,7 +7,9 @@ <% end %> <%= render :partial => "context/context", :locals => { :context => @context, :collapsible => false } %> -<%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this context (last #{@user.preferences["no_completed"]})" } %> +<% unless @done.empty? -%> + <%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this context (last #{@user.preferences["no_completed"]})" } %> +<% end -%> diff --git a/tracks/app/views/context/toggle_check.rjs b/tracks/app/views/context/toggle_check.rjs index d4a9b169..dc18d508 100644 --- a/tracks/app/views/context/toggle_check.rjs +++ b/tracks/app/views/context/toggle_check.rjs @@ -1,12 +1,15 @@ if @saved - page.call "fadeAndRemoveItem", "item-#{@item.id}-container" + page.remove "item-#{@item.id}-container" if @item.done? - page.insert_html :top, "completed", :partial => 'todo/item' - page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"} - if @down_count == '0' - page.show "empty-nd" + # Don't try to insert contents into a non-existent container! + unless @user.preferences["no_completed"].to_i == 0 + page.insert_html :top, "completed", :partial => 'todo/item' + page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"} + if @down_count == '0' + page.show "empty-nd" + end + page.hide "empty-d" # If we've checked something as done, completed items can't be empty end - page.hide "empty-d" # If we've checked something as done, completed items can't be empty else page.call "ensureVisibleWithEffectAppear", "c#{@item.context_id}" page.insert_html :bottom, "c#{@item.context_id}", :partial => 'todo/item' diff --git a/tracks/app/views/project/show.rhtml b/tracks/app/views/project/show.rhtml index b72b4672..39ec875a 100644 --- a/tracks/app/views/project/show.rhtml +++ b/tracks/app/views/project/show.rhtml @@ -7,7 +7,9 @@ <% end %> <%= render :partial => "project/project", :locals => { :project => @project, :collapsible => false } %> -<%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this project" } %> +<% unless @done.empty? -%> + <%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this project" } %> +<% end -%>
diff --git a/tracks/app/views/project/toggle_check.rjs b/tracks/app/views/project/toggle_check.rjs index e0c4d037..15bfa97f 100644 --- a/tracks/app/views/project/toggle_check.rjs +++ b/tracks/app/views/project/toggle_check.rjs @@ -1,12 +1,15 @@ if @saved - page.call "fadeAndRemoveItem", "item-#{@item.id}-container" + page.remove "item-#{@item.id}-container" if @item.done? - page.insert_html :top, "completed", :partial => 'todo/item' - page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"} - if @down_count == '0' - page.show "empty-nd" + # Don't try to insert contents into a non-existent container! + unless @user.preferences["no_completed"].to_i == 0 + page.insert_html :top, "completed", :partial => 'todo/item' + page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"} + if @down_count == '0' + page.show "empty-nd" + end + page.hide "empty-d" # If we've checked something as done, completed items can't be empty end - page.hide "empty-d" # If we've checked something as done, completed items can't be empty else page.call "ensureVisibleWithEffectAppear", "p#{@item.project_id}" page.insert_html :bottom, "p#{@item.project_id}", :partial => 'todo/item' diff --git a/tracks/app/views/todo/list.rhtml b/tracks/app/views/todo/list.rhtml index aabd9c4e..b88b86d0 100644 --- a/tracks/app/views/todo/list.rhtml +++ b/tracks/app/views/todo/list.rhtml @@ -8,8 +8,10 @@ <%= render :partial => "context/context", :collection => @contexts_to_show, :locals => { :collapsible => true } %> - <%= render :partial => "todo/completed", + <% unless @done.nil? -%> + <%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => true, :append_descriptor => nil } %> + <% end -%>
diff --git a/tracks/app/views/todo/toggle_check.rjs b/tracks/app/views/todo/toggle_check.rjs index e91ef39b..5735bfc3 100644 --- a/tracks/app/views/todo/toggle_check.rjs +++ b/tracks/app/views/todo/toggle_check.rjs @@ -4,8 +4,11 @@ if @saved # not on the todo/list page when the item being deleted has just been added # page.call "fadeAndRemoveItem", "item-#{@item.id}-container" if @item.done? - page.insert_html :top, "completed", :partial => 'todo/item' - page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"} + # Don't try to insert contents into a non-existent container! + unless @user.preferences["no_completed"].to_i == 0 + page.insert_html :top, "completed", :partial => 'todo/item' + page.visual_effect :highlight, "item-#{@item.id}", {'startcolor' => "'#99ff99'"} + end else page.call "ensureVisibleWithEffectAppear", "c#{@item.context_id}" page.insert_html :bottom, "c#{@item.context_id}", :partial => 'todo/item' diff --git a/tracks/app/views/user/preference_edit_form.rhtml b/tracks/app/views/user/preference_edit_form.rhtml index 87ef509d..cfb5f5ee 100644 --- a/tracks/app/views/user/preference_edit_form.rhtml +++ b/tracks/app/views/user/preference_edit_form.rhtml @@ -4,7 +4,7 @@