mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Modified the 'count' badge on todo/list: now shows the number of uncompleted items in contexts that *aren't* hidden (i.e. the actions actually listed on todo/list). Number of items in hidden contexts are shown in parentheses after the link to that context. So you don't forget about that stuff ;-)
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@29 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
de31b57852
commit
14334563ee
7 changed files with 30 additions and 21 deletions
|
|
@ -14,10 +14,17 @@ class TodoController < ApplicationController
|
||||||
@page_title = "List tasks"
|
@page_title = "List tasks"
|
||||||
@projects = Project.find_all
|
@projects = Project.find_all
|
||||||
@places = Context.find_all
|
@places = Context.find_all
|
||||||
@shown_places = Context.find_all( "hide=0", "id ASC")
|
@shown_places = Context.find_all_by_hide( 0, "id ASC" )
|
||||||
@hidden_places = Context.find_all( "hide=1")
|
@hidden_places = Context.find_all_by_hide( 1 )
|
||||||
@done = Todo.find_all( "done=1", "completed DESC", 5 )
|
@done = Todo.find_all_by_done( 1, "completed DESC", 5 )
|
||||||
@count = Todo.count( "done=0" )
|
|
||||||
|
# Set count badge to number of not-done, not hidden context items
|
||||||
|
count = 0
|
||||||
|
sub = 0
|
||||||
|
@hidden_places.each do |h|
|
||||||
|
sub = Todo.find_all("done=0 AND context_id=#{h.id}").length + sub
|
||||||
|
end
|
||||||
|
@count = Todo.find_all("done=0").length - sub
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,5 +48,4 @@ module ApplicationHelper
|
||||||
"<span class=\"green\">" + format_date(due) + "</span> "
|
"<span class=\"green\">" + format_date(due) + "</span> "
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,9 @@
|
||||||
module TodoHelper
|
module TodoHelper
|
||||||
|
|
||||||
def count_items(items, context)
|
# Counts the number of uncompleted items in the selected context
|
||||||
# Count the number of items in the selected context
|
#
|
||||||
#
|
def count_items(context)
|
||||||
count = 0
|
count = Todo.find_all("done=0 AND context_id=#{context.id}").length
|
||||||
for item in items
|
|
||||||
if item.context['name'] == context
|
|
||||||
count += 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return count
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
<p>Hidden contexts:
|
<p>Hidden contexts:
|
||||||
<% for @hidden_place in @hidden_places %>
|
<% for @hidden_place in @hidden_places %>
|
||||||
<a href="<%= url_for( :controller => "context", :action => "show", :id => "#{@hidden_place.id}" ) %>"><%= @hidden_place.name.capitalize %></a> |
|
<% num = count_items(@hidden_place) %>
|
||||||
|
<a href="<%= url_for( :controller => "context", :action => "show", :id => "#{@hidden_place.id}" ) %>"><%= @hidden_place.name.capitalize %> (<%= num %>)</a> |
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,10 @@ require_gem 'rails'
|
||||||
|
|
||||||
# Try loading gem Redcloth first, but if that fails
|
# Try loading gem Redcloth first, but if that fails
|
||||||
# fall back on lib version
|
# fall back on lib version
|
||||||
# FIXME
|
|
||||||
begin
|
begin
|
||||||
require_gem 'redcloth', '>= 3.0.3'
|
require_gem 'redcloth', '>= 3.0.3'
|
||||||
rescue StandardError
|
rescue LoadError
|
||||||
require_dependency "redcloth"
|
require_or_load( "redcloth" )
|
||||||
end
|
end
|
||||||
|
|
||||||
# Environment-specific configuration.
|
# Environment-specific configuration.
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
|
|
||||||
map.connect '', :controller => 'todo', :action => 'list'
|
map.connect '', :controller => 'todo', :action => 'list'
|
||||||
|
|
||||||
|
map.connect 'add_item', :controller => 'todo', :action => 'add_item'
|
||||||
|
|
||||||
# Install the default route as the lowest priority.
|
# Install the default route as the lowest priority.
|
||||||
map.connect ':controller/:action/:id'
|
map.connect ':controller/:action/:id'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,14 @@ Project wiki: <http://www.rousette.org.uk/projects/wiki/>
|
||||||
or whatever the full URL is. This should help people who put Tracks in a subdirectory.
|
or whatever the full URL is. This should help people who put Tracks in a subdirectory.
|
||||||
11. 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.
|
11. 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.
|
||||||
12. Changed the method of generating links to stylesheet and javascripts. Together with the new Routes, this should sort out any problems with putting Tracks in a sub-directory.
|
12. Changed the method of generating links to stylesheet and javascripts. Together with the new Routes, this should sort out any problems with putting Tracks in a sub-directory.
|
||||||
|
13. config/environment.rb now checks to see if a gem version of Redcloth is installed that is greater than version 3.0.3. If that fails, it falls back on the packaged lib version. Note that there's an odd bug I can't seem to pin down that means that if you are using the packaged lib version, you'll get some errors like:
|
||||||
|
|
||||||
|
`./script/../config/..//lib/redcloth.rb:169: warning: already initialized constant VERSION`
|
||||||
|
|
||||||
|
`./script/../config/..//lib/redcloth.rb:170: warning: already initialized constant DEFAULT_RULES`
|
||||||
|
|
||||||
|
but ONLY if you're using the development environment; with production it's fine, and with the gem version of Redcloth it's fine in both environments.
|
||||||
|
13. Modified the 'count' badge on todo/list: now shows the number of uncompleted items in contexts that *aren't* hidden (i.e. the actions actually listed on todo/list). Number of items in hidden contexts are shown in parentheses after the link to that context. So you don't forget about that stuff ;-)
|
||||||
|
|
||||||
## Version 1.01
|
## Version 1.01
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue