Show deferred actions on the project listing and sidebar

If a project does not have any active actions, then it will now display
that it has x number of deferred actions.

Fixes #1084
This commit is contained in:
Matt Rogers 2011-10-20 12:10:24 -05:00
parent 4d5a40c376
commit b387b27f4a
3 changed files with 70 additions and 6 deletions

View file

@ -91,8 +91,15 @@ class ApplicationController < ActionController::Base
#
def count_undone_todos_phrase(todos_parent, string="actions")
count = count_undone_todos(todos_parent)
word = count == 1 ? string.singularize : string.pluralize
return count.to_s + "&nbsp;" + word
deferred_count = count_deferred_todos(todos_parent)
if count == 0 && deferred_count > 0
word = deferred_count == 1 ? string.singularize : string.pluralize
word = "deferred&nbsp;" + word
deferred_count.to_s + "&nbsp;" + word
else
word = count == 1 ? string.singularize : string.pluralize
count.to_s + "&nbsp;" + word
end
end
def count_undone_todos(todos_parent)
@ -106,6 +113,14 @@ class ApplicationController < ActionController::Base
count || 0
end
def count_deferred_todos(todos_parent)
if todos_parent.nil?
count = 0
else
count = todos_parent.todos.deferred.count
end
end
# Convert a date object to the format specified in the user's preferences in
# config/settings.yml
#