diff --git a/tracks/app/models/context.rb b/tracks/app/models/context.rb index 8cc0f684..3fab268e 100644 --- a/tracks/app/models/context.rb +++ b/tracks/app/models/context.rb @@ -13,8 +13,19 @@ class Context < ActiveRecord::Base find(:all, :conditions => [ "hide = ?" , hidden ], :order => "position ASC") end - def count_undone_todos - Todo.count( "context_id=#{self.id} AND done=0" ) + # Returns a count of next actions in the given context + # 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 diff --git a/tracks/app/models/project.rb b/tracks/app/models/project.rb index 13cce765..5b68d4ff 100644 --- a/tracks/app/models/project.rb +++ b/tracks/app/models/project.rb @@ -13,8 +13,19 @@ class Project < ActiveRecord::Base find(:all, :conditions => [ "done = ?" , isdone ], :order => "position ASC") end - def count_undone_todos - Todo.count( "project_id=#{self.id} AND done=0" ) + # Returns a count of next actions in the given project + # 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 diff --git a/tracks/app/views/context/_context_listing.rhtml b/tracks/app/views/context/_context_listing.rhtml index 5ae72b75..623a6821 100644 --- a/tracks/app/views/context/_context_listing.rhtml +++ b/tracks/app/views/context/_context_listing.rhtml @@ -18,7 +18,8 @@ {:action => "move_bottom", :id => context.id}, :title => "Move to bottom", :class=>"to_bottom") %>
- <%= 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") + ")" %>
diff --git a/tracks/app/views/context/show.rhtml b/tracks/app/views/context/show.rhtml index 5f611c65..21a166e6 100644 --- a/tracks/app/views/context/show.rhtml +++ b/tracks/app/views/context/show.rhtml @@ -66,36 +66,32 @@

Active Projects:

Completed Projects:

Active Contexts:

Hidden Contexts:

diff --git a/tracks/app/views/project/_project_listing.rhtml b/tracks/app/views/project/_project_listing.rhtml index fe8f748e..6f2d0ef7 100644 --- a/tracks/app/views/project/_project_listing.rhtml +++ b/tracks/app/views/project/_project_listing.rhtml @@ -18,7 +18,7 @@ {:action => "move_bottom", :id => project.id}, :title => "Move to bottom", :class=>"to_bottom") %>
- <%= 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") + ")" %>
<% if project.done == 1 -%> diff --git a/tracks/app/views/project/show.rhtml b/tracks/app/views/project/show.rhtml index 0ec712c1..dbfbc0df 100644 --- a/tracks/app/views/project/show.rhtml +++ b/tracks/app/views/project/show.rhtml @@ -6,6 +6,9 @@
<% if @project.done == 1 -%>

This project has been completed

+ <% for item in @not_done -%> + <%= render_partial "show_items", item %> + <% end -%> <% elsif @not_done.empty? -%>

There are no next actions yet in this project

<% else -%> @@ -67,36 +70,32 @@

Active Projects:

Completed Projects:

Active Contexts:

Hidden Contexts:

diff --git a/tracks/app/views/todo/list.rhtml b/tracks/app/views/todo/list.rhtml index 35a4ad1e..610e82ac 100644 --- a/tracks/app/views/todo/list.rhtml +++ b/tracks/app/views/todo/list.rhtml @@ -84,36 +84,32 @@

Active Projects:

Completed Projects:

Active Contexts:

Hidden Contexts: