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") %>