Setting no_completed in the user preferences to zero now removes the completed items box completely from the home page and from the individual context and project pages.

Fixes #251.
 


git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@220 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2006-04-11 17:19:30 +00:00
parent 95e0fd3590
commit a2120f6ee1
10 changed files with 40 additions and 21 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 -%>
</div><!-- [end:display_box] -->

View file

@ -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'

View file

@ -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 -%>
<div class="container">
<div id="notes">

View file

@ -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'

View file

@ -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 -%>
</div><!-- End of display_box -->
<div id="input_box">

View file

@ -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'

View file

@ -4,7 +4,7 @@
<ul>
<li><strong>staleness_starts:</strong> the number of days before items with no due date get marked as stale (with a yellow highlight)</li>
<li><strong>date_format:</strong> the format in which you'd like dates to be shown. For example, for the date 31st January 2006, %d/%m/%Y will show 31/01/2006, %b-%e-%y will show Jan-31-06. See the <a href="http://uk2.php.net/strftime" title="PHP strftime manual">strftime manual</a> for more formatting options for the date.</li>
<li><strong>no_completed:</strong> number of completed actions to show on the home page</li>
<li><strong>no_completed:</strong> number of completed actions to show on the home page. If you set this to zero, the completed actions box will not be shown on the home page or on the individual context or project pages. You can still see all your completed items by clicking the 'Done' link in the navigation bar at the top of each page.</li>
<% if @user.is_admin? %>
<li><strong>admin_email:</strong> email address for the admin user of Tracks (displayed on the signup page for users to contact to obtain an account)</li>
<% end %>