lib/generators/somatics/install/templates/helper_admin.rb in somatics3-generators-0.0.9 vs lib/generators/somatics/install/templates/helper_admin.rb in somatics3-generators-0.0.10
- old
+ new
@@ -31,13 +31,13 @@
:title => I18n.t("sort_by",:field => text),
:remote=>true
}
link_to(text, params.merge({:"#{model_name}_sort" => key}), html_options) + sort_asc_desc_helper(model_name,param)
end
-
- def operators_for_select(filter_type)
- Query.operators_by_filter_type[filter_type].collect {|o| [(Query.operators[o].to_s.humanize), o]}
+
+ def paper_trail_for(object)
+ render 'admin/shared/versions', :obj => object
end
def excel_document(xml, &block)
xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
xml.Workbook({
@@ -58,6 +58,42 @@
end
end
yield block
end
end
+
+
+ def date_to_words(date)
+ if date == Date.today
+ "Today"
+ elsif date <= Date.today - 1
+ if date == Date.today - 1
+ "Yesterday"
+ elsif ((Date.today - 7)..(Date.today - 1)).include?(date)
+ "Last #{date.strftime("%A")}"
+ elsif ((Date.today - 14)..(Date.today - 8)).include?(date)
+ "Two #{date.strftime("%A")}s ago"
+ elsif ((Date.today - 21)..(Date.today - 15)).include?(date)
+ "Three #{date.strftime("%A")}s ago"
+ elsif ((Date.today - 29)..(Date.today - 22)).include?(date)
+ "Four #{date.strftime("%A")}s ago"
+ elsif Date.today - 30 < date
+ "More than a month ago"
+ end
+ else
+ if date == Date.today + 1
+ "Tomorrow"
+ elsif ((Date.today + 1)..(Date.today + 6)).include?(date)
+ "This coming #{date.strftime("%A")}"
+ elsif ((Date.today + 7)..(Date.today + 14)).include?(date)
+ "Next #{date.strftime("%A")}s away"
+ elsif ((Date.today + 15)..(Date.today + 21)).include?(date)
+ "Two #{date.strftime("%A")}s away"
+ elsif ((Date.today + 22)..(Date.today + 29)).include?(date)
+ "Three #{date.strftime("%A")}s away"
+ elsif Date.today + 30 > date
+ "More than a month in the future"
+ end
+ end
+ end
+
end