mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00: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
|
module ApplicationHelper
|
||||||
|
|
||||||
def user_time
|
def user_time
|
||||||
|
|
@ -6,8 +7,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
# Replicates the link_to method but also checks request.request_uri to find
|
# Replicates the link_to method but also checks request.request_uri to find
|
||||||
# current page. If that matches the url, the link is marked
|
# current page. If that matches the url, the link is marked id = "current"
|
||||||
# id = "current"
|
|
||||||
#
|
#
|
||||||
def navigation_link(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
def navigation_link(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
||||||
if html_options
|
if html_options
|
||||||
|
|
@ -27,8 +27,8 @@ module ApplicationHelper
|
||||||
date.to_date - user_time.to_date
|
date.to_date - user_time.to_date
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check due date in comparison to today's date
|
# Check due date in comparison to today's date Flag up date appropriately with
|
||||||
# Flag up date appropriately with a 'traffic light' colour code
|
# a 'traffic light' colour code
|
||||||
#
|
#
|
||||||
def due_date(due)
|
def due_date(due)
|
||||||
if due == nil
|
if due == nil
|
||||||
|
|
@ -38,29 +38,30 @@ module ApplicationHelper
|
||||||
days = days_from_today(due)
|
days = days_from_today(due)
|
||||||
|
|
||||||
case days
|
case days
|
||||||
# overdue or due very soon! sound the alarm!
|
when 0
|
||||||
when -1000..-1
|
"<a title='#{format_date(due)}'><span class=\"amber\">Due Today</span></a> "
|
||||||
"<a title='#{format_date(due)}'><span class=\"red\">Overdue by #{pluralize(days * -1, 'day')}</span></a> "
|
when 1
|
||||||
when 0
|
"<a title='#{format_date(due)}'><span class=\"amber\">Due Tomorrow</span></a> "
|
||||||
"<a title='#{format_date(due)}'><span class=\"amber\">Due Today</span></a> "
|
|
||||||
when 1
|
|
||||||
"<a title='#{format_date(due)}'><span class=\"amber\">Due Tomorrow</span></a> "
|
|
||||||
# due 2-7 days away
|
# due 2-7 days away
|
||||||
when 2..7
|
when 2..7
|
||||||
if prefs.due_style == Preference.due_styles[:due_on]
|
if prefs.due_style == Preference.due_styles[:due_on]
|
||||||
"<a title='#{format_date(due)}'><span class=\"orange\">Due on #{due.strftime("%A")}</span></a> "
|
"<a title='#{format_date(due)}'><span class=\"orange\">Due on #{due.strftime("%A")}</span></a> "
|
||||||
else
|
else
|
||||||
"<a title='#{format_date(due)}'><span class=\"orange\">Due in #{pluralize(days, 'day')}</span></a> "
|
"<a title='#{format_date(due)}'><span class=\"orange\">Due in #{pluralize(days, 'day')}</span></a> "
|
||||||
end
|
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
|
else
|
||||||
|
# more than a week away - relax
|
||||||
"<a title='#{format_date(due)}'><span class=\"green\">Due in #{pluralize(days, 'day')}</span></a> "
|
"<a title='#{format_date(due)}'><span class=\"green\">Due in #{pluralize(days, 'day')}</span></a> "
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check due date in comparison to today's date
|
# Check due date in comparison to today's date Flag up date appropriately with
|
||||||
# Flag up date appropriately with a 'traffic light' colour code
|
# a 'traffic light' colour code Modified method for mobile screen
|
||||||
# Modified method for mobile screen
|
|
||||||
#
|
#
|
||||||
def due_date_mobile(due)
|
def due_date_mobile(due)
|
||||||
if due == nil
|
if due == nil
|
||||||
|
|
@ -70,24 +71,26 @@ module ApplicationHelper
|
||||||
days = days_from_today(due)
|
days = days_from_today(due)
|
||||||
|
|
||||||
case days
|
case days
|
||||||
# overdue or due very soon! sound the alarm!
|
when 0
|
||||||
when -1000..-1
|
"<span class=\"amber\">"+ format_date(due) + "</span>"
|
||||||
"<span class=\"red\">" + format_date(due) +"</span>"
|
when 1
|
||||||
when 0
|
"<span class=\"amber\">" + format_date(due) + "</span>"
|
||||||
"<span class=\"amber\">"+ format_date(due) + "</span>"
|
|
||||||
when 1
|
|
||||||
"<span class=\"amber\">" + format_date(due) + "</span>"
|
|
||||||
# due 2-7 days away
|
# due 2-7 days away
|
||||||
when 2..7
|
when 2..7
|
||||||
"<span class=\"orange\">" + format_date(due) + "</span>"
|
"<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
|
else
|
||||||
|
# more than a week away - relax
|
||||||
"<span class=\"green\">" + format_date(due) + "</span>"
|
"<span class=\"green\">" + format_date(due) + "</span>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a count of next actions in the given context or project
|
# Returns a count of next actions in the given context or project The result
|
||||||
# The result is count and a string descriptor, correctly pluralised if there are no
|
# is count and a string descriptor, correctly pluralised if there are no
|
||||||
# actions or multiple actions
|
# actions or multiple actions
|
||||||
#
|
#
|
||||||
def count_undone_todos_phrase(todos_parent, string="actions")
|
def count_undone_todos_phrase(todos_parent, string="actions")
|
||||||
|
|
@ -128,9 +131,9 @@ module ApplicationHelper
|
||||||
render :partial => 'shared/flash', :locals => { :flash => flash }
|
render :partial => 'shared/flash', :locals => { :flash => flash }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Display a flash message in RJS templates
|
# Display a flash message in RJS templates Usage: page.notify :warning, "This
|
||||||
# Usage: page.notify :warning, "This is the message", 5.0
|
# is the message", 5.0 Puts the message into a flash of type 'warning', fades
|
||||||
# Puts the message into a flash of type 'warning', fades over 5 secs
|
# over 5 secs
|
||||||
def notify(type, message, fade_duration)
|
def notify(type, message, fade_duration)
|
||||||
type = type.to_s # symbol to string
|
type = type.to_s # symbol to string
|
||||||
page.replace 'flash', "<h4 id='flash' class='alert #{type}'>#{message}</h4>"
|
page.replace 'flash', "<h4 id='flash' class='alert #{type}'>#{message}</h4>"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue