diff --git a/tracks/app/helpers/application_helper.rb b/tracks/app/helpers/application_helper.rb index dece18b8..535e1fe6 100644 --- a/tracks/app/helpers/application_helper.rb +++ b/tracks/app/helpers/application_helper.rb @@ -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,9 +7,8 @@ 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 html_options = html_options.stringify_keys @@ -27,9 +27,9 @@ 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 return "" @@ -38,30 +38,31 @@ module ApplicationHelper days = days_from_today(due) case days - # overdue or due very soon! sound the alarm! - when -1000..-1 - "Overdue by #{pluralize(days * -1, 'day')} " - when 0 - "Due Today " - when 1 - "Due Tomorrow " + when 0 + "Due Today " + when 1 + "Due Tomorrow " # due 2-7 days away - when 2..7 + when 2..7 if prefs.due_style == Preference.due_styles[:due_on] "Due on #{due.strftime("%A")} " else "Due in #{pluralize(days, 'day')} " end - # more than a week away - relax + else + # overdue or due very soon! sound the alarm! + if days < 0 + "Overdue by #{pluralize(days * -1, 'day')} " else + # more than a week away - relax "Due in #{pluralize(days, 'day')} " + 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 return "" @@ -70,26 +71,28 @@ module ApplicationHelper days = days_from_today(due) case days - # overdue or due very soon! sound the alarm! - when -1000..-1 - "" + format_date(due) +"" - when 0 - ""+ format_date(due) + "" - when 1 - "" + format_date(due) + "" + when 0 + ""+ format_date(due) + "" + when 1 + "" + format_date(due) + "" # due 2-7 days away - when 2..7 - "" + format_date(due) + "" - # more than a week away - relax + when 2..7 + "" + format_date(due) + "" + else + # overdue or due very soon! sound the alarm! + if days < 0 + "" + format_date(due) +"" else + # more than a week away - relax "" + format_date(due) + "" + 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") @controller.count_undone_todos_phrase(todos_parent, string) end @@ -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', "