Module: Admin::ListViewHelper
- Defined in:
- app/helpers/admin/list_view_helper.rb
Instance Method Summary collapse
- #attribute_cell_class(att) ⇒ Object
- #attribute_header_class(att) ⇒ Object
- #attribute_header_id(att) ⇒ Object
- #link_or_span_unless_current(params, text, url, options) ⇒ Object
- #list_display_attributes ⇒ Object
- #nicify(key, value) ⇒ Object
- #shorten_display(value, max_length) ⇒ Object
Instance Method Details
#attribute_cell_class(att) ⇒ Object
58 59 60 61 62 |
# File 'app/helpers/admin/list_view_helper.rb', line 58 def attribute_cell_class(att) returning %w{page} do |classes| # classes << 'date-short' if att =~ /(updated|created)_(at|on)/ end.join(" ") end |
#attribute_header_class(att) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/admin/list_view_helper.rb', line 39 def attribute_header_class(att) @saved_order ||= if ['table_kit_order'] ActiveSupport::JSON.decode(CGI.unescape(['table_kit_order'])) else [] end returning %W{page-#{att}} do |classes| classes << 'date-us-civil' if att =~ /(updated|created)_(at|on)/ if @saved_order[0] && @list_display_attributes.index(att) == @saved_order[0] direction = @saved_order[1].to_i < 0 ? "desc" : "asc" classes << "sortfirst#{direction}" end end.join(" ") end |
#attribute_header_id(att) ⇒ Object
54 55 56 |
# File 'app/helpers/admin/list_view_helper.rb', line 54 def attribute_header_id(att) "#{att}-header" end |
#link_or_span_unless_current(params, text, url, options) ⇒ Object
3 4 5 6 7 8 9 |
# File 'app/helpers/admin/list_view_helper.rb', line 3 def link_or_span_unless_current(params, text, url, ) if [:id] == params[:view] content_tag(:span, text) else link_to text, url, end end |
#list_display_attributes ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/admin/list_view_helper.rb', line 11 def list_display_attributes display_atts = [] unless config['page_list_view.display_attributes'].nil? config['page_list_view.display_attributes'].split.each do |att| display_atts << att if Page.column_names.include?("#{att}") || Page.instance_methods.include?("#{att}") end end display_atts = %w{title parent_title slug class_name status_name updated_by_name updated_at} if display_atts.empty? @list_display_attributes ||= returning display_atts do |atts| end end |
#nicify(key, value) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/admin/list_view_helper.rb', line 27 def nicify(key,value) value = "" if value.nil? case value when String key=="title" ? shorten_display(value,24) : shorten_display(value,12) when ActiveSupport::TimeWithZone || Time value.strftime(fmt="%m/%d/%Y at %I:%M %p") else shorten_display(value.to_s,12) end end |
#shorten_display(value, max_length) ⇒ Object
23 24 25 |
# File 'app/helpers/admin/list_view_helper.rb', line 23 def shorten_display(value, max_length) value.length > max_length + 3 ? value.slice(0,max_length) + "..." : value end |