mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
support for due dates for people who procrastinate :-) Fixes #689 where due date is more than 1000 days in the past. Thanks.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@795 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
80d46ac46f
commit
1cb7592d73
1 changed files with 39 additions and 36 deletions
|
|
@ -1,4 +1,5 @@
|
|||
# The methods added to this helper will be available to all templates in the application.
|
||||
# The methods added to this helper will be available to all templates in the
|
||||
# application.
|
||||
module ApplicationHelper
|
||||
|
||||
def user_time
|
||||
|
|
@ -6,8 +7,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
# Replicates the link_to method but also checks request.request_uri to find
|
||||
# current page. If that matches the url, the link is marked
|
||||
# id = "current"
|
||||
# current page. If that matches the url, the link is marked id = "current"
|
||||
#
|
||||
def navigation_link(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||
if html_options
|
||||
|
|
@ -27,8 +27,8 @@ module ApplicationHelper
|
|||
date.to_date - user_time.to_date
|
||||
end
|
||||
|
||||
# Check due date in comparison to today's date
|
||||
# Flag up date appropriately with a 'traffic light' colour code
|
||||
# Check due date in comparison to today's date Flag up date appropriately with
|
||||
# a 'traffic light' colour code
|
||||
#
|
||||
def due_date(due)
|
||||
if due == nil
|
||||
|
|
@ -38,9 +38,6 @@ module ApplicationHelper
|
|||
days = days_from_today(due)
|
||||
|
||||
case days
|
||||
# overdue or due very soon! sound the alarm!
|
||||
when -1000..-1
|
||||
"<a title='#{format_date(due)}'><span class=\"red\">Overdue by #{pluralize(days * -1, 'day')}</span></a> "
|
||||
when 0
|
||||
"<a title='#{format_date(due)}'><span class=\"amber\">Due Today</span></a> "
|
||||
when 1
|
||||
|
|
@ -52,15 +49,19 @@ module ApplicationHelper
|
|||
else
|
||||
"<a title='#{format_date(due)}'><span class=\"orange\">Due in #{pluralize(days, 'day')}</span></a> "
|
||||
end
|
||||
# more than a week away - relax
|
||||
else
|
||||
# overdue or due very soon! sound the alarm!
|
||||
if days < 0
|
||||
"<a title='#{format_date(due)}'><span class=\"red\">Overdue by #{pluralize(days * -1, 'day')}</span></a> "
|
||||
else
|
||||
# more than a week away - relax
|
||||
"<a title='#{format_date(due)}'><span class=\"green\">Due in #{pluralize(days, 'day')}</span></a> "
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Check due date in comparison to today's date
|
||||
# Flag up date appropriately with a 'traffic light' colour code
|
||||
# Modified method for mobile screen
|
||||
# Check due date in comparison to today's date Flag up date appropriately with
|
||||
# a 'traffic light' colour code Modified method for mobile screen
|
||||
#
|
||||
def due_date_mobile(due)
|
||||
if due == nil
|
||||
|
|
@ -70,9 +71,6 @@ module ApplicationHelper
|
|||
days = days_from_today(due)
|
||||
|
||||
case days
|
||||
# overdue or due very soon! sound the alarm!
|
||||
when -1000..-1
|
||||
"<span class=\"red\">" + format_date(due) +"</span>"
|
||||
when 0
|
||||
"<span class=\"amber\">"+ format_date(due) + "</span>"
|
||||
when 1
|
||||
|
|
@ -80,14 +78,19 @@ module ApplicationHelper
|
|||
# due 2-7 days away
|
||||
when 2..7
|
||||
"<span class=\"orange\">" + format_date(due) + "</span>"
|
||||
# more than a week away - relax
|
||||
else
|
||||
# overdue or due very soon! sound the alarm!
|
||||
if days < 0
|
||||
"<span class=\"red\">" + format_date(due) +"</span>"
|
||||
else
|
||||
# more than a week away - relax
|
||||
"<span class=\"green\">" + format_date(due) + "</span>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a count of next actions in the given context or project
|
||||
# The result is count and a string descriptor, correctly pluralised if there are no
|
||||
# Returns a count of next actions in the given context or project The result
|
||||
# is count and a string descriptor, correctly pluralised if there are no
|
||||
# actions or multiple actions
|
||||
#
|
||||
def count_undone_todos_phrase(todos_parent, string="actions")
|
||||
|
|
@ -128,9 +131,9 @@ module ApplicationHelper
|
|||
render :partial => 'shared/flash', :locals => { :flash => flash }
|
||||
end
|
||||
|
||||
# Display a flash message in RJS templates
|
||||
# Usage: page.notify :warning, "This is the message", 5.0
|
||||
# Puts the message into a flash of type 'warning', fades over 5 secs
|
||||
# Display a flash message in RJS templates Usage: page.notify :warning, "This
|
||||
# is the message", 5.0 Puts the message into a flash of type 'warning', fades
|
||||
# over 5 secs
|
||||
def notify(type, message, fade_duration)
|
||||
type = type.to_s # symbol to string
|
||||
page.replace 'flash', "<h4 id='flash' class='alert #{type}'>#{message}</h4>"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue