Added some rudimentary sorting of completed items. They are now sorted in to done today, done in the last 7 days and done in the last 31 days. At the bottom of completed.rhtml, there's a link to completed_archive.rhtml, which shows archived items older than 31 days.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@23 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
bsag 2005-02-13 17:45:45 +00:00
parent 660c77b842
commit 60934fb8c8
5 changed files with 52 additions and 3 deletions

View file

@ -25,9 +25,27 @@ class TodoController < ApplicationController
# #
def completed def completed
@page_title = "Completed tasks" @page_title = "Completed tasks"
@done = Todo.find_all( "done=1", "completed DESC" ) today_query = "DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= completed"
week_query = "DATE_SUB(CURDATE(),INTERVAL 2 DAY) >= completed
AND DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= completed"
month_query = "DATE_SUB(CURDATE(),INTERVAL 8 DAY) >= completed
AND DATE_SUB(CURDATE(),INTERVAL 31 DAY) <= completed"
@done_today = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{today_query}
ORDER BY completed DESC;" )
@done_this_week = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{week_query}
ORDER BY completed DESC;" )
@done_this_month = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{month_query}
ORDER BY completed DESC;" )
end end
# Archived completed items, older than 31 days
#
def completed_archive
@page_title = "Archived completed tasks"
archive_query = "DATE_SUB(CURDATE(),INTERVAL 32 DAY) >= completed"
@done_archive = Todo.find_by_sql( "SELECT * FROM todos WHERE done = 1 AND #{archive_query}
ORDER BY completed DESC;" )
end
# Called by a form button # Called by a form button
# Parameters from form fields should be passed to create new item # Parameters from form fields should be passed to create new item

View file

@ -12,4 +12,5 @@ module TodoHelper
return count return count
end end
end end

View file

@ -1,10 +1,26 @@
<div id="display_box_projects"> <div id="display_box_projects">
<p>You have completed <%= @done_today.length %> actions so far today.</p>
<div class="contexts"> <div class="contexts">
<h2>Completed items</h2> <h2>Completed today</h2>
<table class="next_actions" cellspacing="5" cellpadding="0" border="0"> <table class="next_actions" cellspacing="5" cellpadding="0" border="0">
<%= render_collection_of_partials "done", @done %> <%= render_collection_of_partials "done", @done_today %>
</table> </table>
</div> </div>
<div class="contexts">
<h2>Completed in last 7 days</h2>
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
<%= render_collection_of_partials "done", @done_this_week %>
</table>
</div>
<div class="contexts"
<h2>Completed in the last 31 days</h2>
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
<%= render_collection_of_partials "done", @done_this_month %>
</table>
</div>
<p>Older completed items: <%= link_to( "Older than 31 days", :controller => "todo", :action => "completed_archive" ) %></p>
</div><!- End of display_box --> </div><!- End of display_box -->

View file

@ -0,0 +1,11 @@
<div id="display_box_projects">
<p>There are <%= @done_archive.length %> completed actions in the archive.</p>
<div class="contexts">
<h2>Completed more than 31 days ago</h2>
<table class="next_actions" cellspacing="5" cellpadding="0" border="0">
<%= render_collection_of_partials "done", @done_archive %>
</table>
</div>
</div><!- End of display_box -->

View file

@ -16,6 +16,9 @@ Project wiki: <http://www.rousette.org.uk/projects/wiki/>
7. Changed the method of adding due dates to drop-down option lists. It's more obvious and less error prone than typing in the date. Your preferences for date formatting are still honoured when displaying due dates. 7. Changed the method of adding due dates to drop-down option lists. It's more obvious and less error prone than typing in the date. Your preferences for date formatting are still honoured when displaying due dates.
8. Added a favicon, kindly produced by Jim Ray. 8. Added a favicon, kindly produced by Jim Ray.
9. Added border="0" to the button images to stop Firefox putting a red border around them. 9. Added border="0" to the button images to stop Firefox putting a red border around them.
10. Added a new path:, base: setting in settings.yml. This is used in constructing URLs in standard.rhtml and other places for the javascripts and stylesheets. You need to specify it in the format,
http://my.domain.tld/subdir/tracks
or whatever the full URL is. This should help people who put Tracks in a subdirectory.
## Version 1.01 ## Version 1.01