mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 07:40:12 +01:00
Modified display of undone next actions to return the correct case for "actions" depending on whether there are none, many or one. Fixes #69.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@108 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
dd255218b9
commit
f5053d60c2
7 changed files with 44 additions and 30 deletions
|
|
@ -13,8 +13,19 @@ class Context < ActiveRecord::Base
|
||||||
find(:all, :conditions => [ "hide = ?" , hidden ], :order => "position ASC")
|
find(:all, :conditions => [ "hide = ?" , hidden ], :order => "position ASC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_undone_todos
|
# Returns a count of next actions in the given context
|
||||||
Todo.count( "context_id=#{self.id} AND done=0" )
|
# The result is count and a string descriptor, correctly pluralised if there are no
|
||||||
|
# actions or multiple actions
|
||||||
|
#
|
||||||
|
def count_undone_todos(string="actions")
|
||||||
|
count = Todo.count( "context_id=#{self.id} AND done=0" )
|
||||||
|
|
||||||
|
if count == 1
|
||||||
|
word = string.singularize
|
||||||
|
else
|
||||||
|
word = string.pluralize
|
||||||
|
end
|
||||||
|
return count.to_s + " " + word
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,19 @@ class Project < ActiveRecord::Base
|
||||||
find(:all, :conditions => [ "done = ?" , isdone ], :order => "position ASC")
|
find(:all, :conditions => [ "done = ?" , isdone ], :order => "position ASC")
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_undone_todos
|
# Returns a count of next actions in the given project
|
||||||
Todo.count( "project_id=#{self.id} AND done=0" )
|
# The result is count and a string descriptor, correctly pluralised if there are no
|
||||||
|
# actions or multiple actions
|
||||||
|
#
|
||||||
|
def count_undone_todos(string="actions")
|
||||||
|
count = Todo.count( "project_id=#{self.id} AND done=0" )
|
||||||
|
|
||||||
|
if count == 1
|
||||||
|
word = string.singularize
|
||||||
|
else
|
||||||
|
word = string.pluralize
|
||||||
|
end
|
||||||
|
return count.to_s + " " + word
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@
|
||||||
{:action => "move_bottom", :id => context.id}, :title => "Move to bottom", :class=>"to_bottom") %>
|
{:action => "move_bottom", :id => context.id}, :title => "Move to bottom", :class=>"to_bottom") %>
|
||||||
</div>
|
</div>
|
||||||
<div class="data">
|
<div class="data">
|
||||||
<%= link_to( "#{context.name}", :action => "show", :name => urlize(context.name) ) %><%= " (" + Todo.count( "context_id=#{context.id} AND done=0" ).to_s + " actions)" %>
|
<%= link_to( "#{context.name}", :action => "show", :name => urlize(context.name) ) %>
|
||||||
|
<%= " (" + context.count_undone_todos("actions") + ")" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
|
|
|
||||||
|
|
@ -66,36 +66,32 @@
|
||||||
<h3>Active Projects:</h3>
|
<h3>Active Projects:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for project in Project.list_of -%>
|
<% for project in Project.list_of -%>
|
||||||
<% count = project.count_undone_todos -%>
|
|
||||||
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
||||||
:name => urlize(project.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(project.name) } ) + " (" + project.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Completed Projects:</h3>
|
<h3>Completed Projects:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for project in Project.list_of( isdone=1 ) -%>
|
<% for project in Project.list_of( isdone=1 ) -%>
|
||||||
<% count = project.count_undone_todos -%>
|
|
||||||
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
||||||
:name => urlize(project.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(project.name) } ) + " (" + project.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Active Contexts:</h3>
|
<h3>Active Contexts:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for context in Context.list_of -%>
|
<% for context in Context.list_of -%>
|
||||||
<% count = context.count_undone_todos -%>
|
|
||||||
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
||||||
:name => urlize(context.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(context.name) } ) + " (" + context.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Hidden Contexts:</h3>
|
<h3>Hidden Contexts:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for context in Context.list_of( hidden=1 ) -%>
|
<% for context in Context.list_of( hidden=1 ) -%>
|
||||||
<% count = context.count_undone_todos -%>
|
|
||||||
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
||||||
:name => urlize(context.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(context.name) } ) + " (" + context.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
{:action => "move_bottom", :id => project.id}, :title => "Move to bottom", :class=>"to_bottom") %>
|
{:action => "move_bottom", :id => project.id}, :title => "Move to bottom", :class=>"to_bottom") %>
|
||||||
</div>
|
</div>
|
||||||
<div class="data">
|
<div class="data">
|
||||||
<%= link_to( "#{project.name}", :action => "show", :name => urlize(project.name) ) %><%= " (" + Todo.count( "project_id=#{project.id} AND done=0" ).to_s + " actions)" %>
|
<%= link_to( "#{project.name}", :action => "show", :name => urlize(project.name) ) %><%= " (" + project.count_undone_todos("actions") + ")" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<% if project.done == 1 -%>
|
<% if project.done == 1 -%>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
<div id="next_actions">
|
<div id="next_actions">
|
||||||
<% if @project.done == 1 -%>
|
<% if @project.done == 1 -%>
|
||||||
<p class="info">This project has been completed</p>
|
<p class="info">This project has been completed</p>
|
||||||
|
<% for item in @not_done -%>
|
||||||
|
<%= render_partial "show_items", item %>
|
||||||
|
<% end -%>
|
||||||
<% elsif @not_done.empty? -%>
|
<% elsif @not_done.empty? -%>
|
||||||
<p>There are no next actions yet in this project</p>
|
<p>There are no next actions yet in this project</p>
|
||||||
<% else -%>
|
<% else -%>
|
||||||
|
|
@ -67,36 +70,32 @@
|
||||||
<h3>Active Projects:</h3>
|
<h3>Active Projects:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for project in Project.list_of -%>
|
<% for project in Project.list_of -%>
|
||||||
<% count = project.count_undone_todos -%>
|
|
||||||
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
||||||
:name => urlize(project.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(project.name) } ) + " (" + project.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Completed Projects:</h3>
|
<h3>Completed Projects:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for project in Project.list_of( isdone=1 ) -%>
|
<% for project in Project.list_of( isdone=1 ) -%>
|
||||||
<% count = project.count_undone_todos -%>
|
|
||||||
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
||||||
:name => urlize(project.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(project.name) } ) + " (" + project.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Active Contexts:</h3>
|
<h3>Active Contexts:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for context in Context.list_of -%>
|
<% for context in Context.list_of -%>
|
||||||
<% count = context.count_undone_todos -%>
|
|
||||||
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
||||||
:name => urlize(context.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(context.name) } ) + " (" + context.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Hidden Contexts:</h3>
|
<h3>Hidden Contexts:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for context in Context.list_of( hidden=1 ) -%>
|
<% for context in Context.list_of( hidden=1 ) -%>
|
||||||
<% count = context.count_undone_todos -%>
|
|
||||||
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
||||||
:name => urlize(context.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(context.name) } ) + " (" + context.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
</div><!-- End of input box -->
|
</div><!-- End of input box -->
|
||||||
|
|
|
||||||
|
|
@ -84,36 +84,32 @@
|
||||||
<h3>Active Projects:</h3>
|
<h3>Active Projects:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for project in Project.list_of -%>
|
<% for project in Project.list_of -%>
|
||||||
<% count = project.count_undone_todos -%>
|
|
||||||
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
||||||
:name => urlize(project.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(project.name) } ) + " (" + project.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Completed Projects:</h3>
|
<h3>Completed Projects:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for project in Project.list_of( isdone=1 ) -%>
|
<% for project in Project.list_of( isdone=1 ) -%>
|
||||||
<% count = project.count_undone_todos -%>
|
|
||||||
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
<li><%= link_to( project.name, { :controller => "project", :action => "show",
|
||||||
:name => urlize(project.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(project.name) } ) + " (" + project.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Active Contexts:</h3>
|
<h3>Active Contexts:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for context in Context.list_of -%>
|
<% for context in Context.list_of -%>
|
||||||
<% count = context.count_undone_todos -%>
|
|
||||||
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
||||||
:name => urlize(context.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(context.name) } ) + " (" + context.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Hidden Contexts:</h3>
|
<h3>Hidden Contexts:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<% for context in Context.list_of( hidden=1 ) -%>
|
<% for context in Context.list_of( hidden=1 ) -%>
|
||||||
<% count = context.count_undone_todos -%>
|
|
||||||
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
<li><%= link_to( context.name, { :controller => "context", :action => "show",
|
||||||
:name => urlize(context.name) } ) + " (" + count.to_s + " actions)" %></li>
|
:name => urlize(context.name) } ) + " (" + context.count_undone_todos("actions") + ")" %></li>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
</ul>
|
</ul>
|
||||||
</div><!-- End of input box -->
|
</div><!-- End of input box -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue