Module: Metajp::Shared::SuperCrud::Helper
- Defined in:
- lib/metajp/shared/super_crud/helper.rb
Instance Method Summary collapse
-
#filter_results ⇒ Object
—————————————————————- framework stuff —————————————————————-.
- #ordering(attribute) ⇒ Object
-
#set_admin_url(object, path) ⇒ Object
—————————————————————- general helpers —————————————————————-.
- #super_button(name, link, options = {}) ⇒ Object
-
#super_column_heading(display_name, attribute, controller = controller_name) ⇒ Object
—————————————————————- table sorting and filtering helpers —————————————————————-.
- #super_custom_remote_paginate(collection, options = {}) ⇒ Object
- #super_header(name, &block) ⇒ Object
- #super_icon(type, options = {}) ⇒ Object
- #super_menu_item(name, link, selected = nil, options = {}) ⇒ Object
- #super_paginate(collection) ⇒ Object
- #super_row(name, object, iterator = nil, &block) ⇒ Object
-
#super_show_item(name, value) ⇒ Object
—————————————————————- show helpers —————————————————————-.
- #super_table(&block) ⇒ Object
- #super_triangle(attribute) ⇒ Object
-
#table_header(width, name, column, options = {}) ⇒ Object
table header.
Instance Method Details
#filter_results ⇒ Object
framework stuff
10 11 12 13 14 15 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 10 def filter_results out = "" out += "<div id=\"filter-results-count\" class=\"float-right\">#{@filter_count} found #{link_to(super_icon('cross'), {:controller => controller_name})}</div>" if @filter_count out += "<div id=\"filter-results\">#{@filter_text}</div>#{}" if @filter_text out end |
#ordering(attribute) ⇒ Object
109 110 111 112 113 114 115 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 109 def ordering(attribute) if @ordering == "ascend_by_#{attribute}" then "descend_by_#{attribute}" else "ascend_by_#{attribute}" end end |
#set_admin_url(object, path) ⇒ Object
general helpers
57 58 59 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 57 def set_admin_url(object, path) object.new_record? ? "/admin/#{path}/" : "/admin/#{path}/#{object.id}" end |
#super_button(name, link, options = {}) ⇒ Object
43 44 45 46 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 43 def (name, link, = {}) div_style = .delete(:div_style) "<div class='button' style='#{div_style}'>#{link_to(name, link, )}</div>" end |
#super_column_heading(display_name, attribute, controller = controller_name) ⇒ Object
table sorting and filtering helpers
84 85 86 87 88 89 90 91 92 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 84 def super_column_heading(display_name, attribute, controller = controller_name) = { :controller => controller, :action => 'display_list', :ordering => ordering(attribute), :attribute => attribute.to_s }.merge!(@extra_params) link_to("#{display_name} #{super_triangle(attribute)}", , :class => 'column-header') end |
#super_custom_remote_paginate(collection, options = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 94 def super_custom_remote_paginate(collection, = {}) [:ordering] ||= @ordering [:attribute] ||= @attribute [:controller] ||= controller_name [:action] ||= 'display_list' [:method] ||= 'post' .merge!(@extra_params) "<div class='pagination'>#{will_paginate(collection, :params => , :remote => {})}</div>#{float_clear}" end |
#super_header(name, &block) ⇒ Object
17 18 19 20 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 17 def super_header(name, &block) heading = "<h1>#{name}</h1>" concat("<div id='sub-header'>#{capture(&block)}#{heading}#{float_clear}</div>") end |
#super_icon(type, options = {}) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 61 def super_icon(type, = {}) width = 16 alt = nil file_name = "#{type}.png" "<img src=\"/images/icons/#{file_name}\" alt=\"#{alt ? alt : type}\" #{"title=\"#{alt}\"" if !alt.blank?} style=\"width: #{width}px;\" />" end |
#super_menu_item(name, link, selected = nil, options = {}) ⇒ Object
48 49 50 51 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 48 def (name, link, selected = nil, = {}) [:class] = 'selected' if selected == @render_options[:selected_tab] && !@render_options[:selected_tab].blank? "<li>#{link_to(name, link, )}</li>" end |
#super_paginate(collection) ⇒ Object
33 34 35 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 33 def super_paginate(collection) "<div id='table-footer'>#{super_custom_remote_paginate(collection)}</div>" end |
#super_row(name, object, iterator = nil, &block) ⇒ Object
28 29 30 31 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 28 def super_row(name, object, iterator = nil, &block) line = (iterator ? iterator % 2 : 0) concat("<tr id='#{name}-#{object.id}' class='line-#{line} padded-td'>#{capture(&block)}</tr>") end |
#super_show_item(name, value) ⇒ Object
show helpers
72 73 74 75 76 77 78 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 72 def super_show_item(name, value) value = value.blank? ? '<i>null</i>' : value "<p> <label class='strong'>#{name}</label> #{value} </p>" end |
#super_table(&block) ⇒ Object
22 23 24 25 26 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 22 def super_table(&block) table_start = '<div id="filter" class="rounded" style="display: none;"></div> <table class="stripped-list list" cellspacing="0" width="750px">' concat("#{table_start}#{capture(&block)}</table>") end |
#super_triangle(attribute) ⇒ Object
104 105 106 107 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 104 def super_triangle(attribute) return "▲" if @ordering == "ascend_by_#{attribute}" return "▼" if @ordering == "descend_by_#{attribute}" end |
#table_header(width, name, column, options = {}) ⇒ Object
table header
38 39 40 41 |
# File 'lib/metajp/shared/super_crud/helper.rb', line 38 def table_header(width, name, column, = {}) filler = [:plain_text].blank? ? super_column_heading(name, column) : name "<th width='#{width}' class='#{[:class]}'>#{filler}</th>" end |