mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
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:
parent
4d5a40c376
commit
b387b27f4a
3 changed files with 70 additions and 6 deletions
|
|
@ -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 + " " + word
|
||||
deferred_count = count_deferred_todos(todos_parent)
|
||||
if count == 0 && deferred_count > 0
|
||||
word = deferred_count == 1 ? string.singularize : string.pluralize
|
||||
word = "deferred " + word
|
||||
deferred_count.to_s + " " + word
|
||||
else
|
||||
word = count == 1 ? string.singularize : string.pluralize
|
||||
count.to_s + " " + 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
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue