Module: Fae::ViewHelper
- Defined in:
- app/helpers/fae/view_helper.rb
Instance Method Summary collapse
- #attr_toggle(item, column) ⇒ Object (also: #fae_toggle)
- #fae_clone_button(item) ⇒ Object
- #fae_content_form(f, attribute, label: nil, hint: nil, helper_text: nil, markdown: nil, markdown_supported: nil) ⇒ Object
- #fae_date_format(datetime, timezone = @option.time_zone) ⇒ Object
- #fae_datetime_format(datetime, timezone = @option.time_zone) ⇒ Object
- #fae_file_form(f, file_name, label: nil, helper_text: nil, required: nil) ⇒ Object
- #fae_filter_form(options = {}, &block) ⇒ Object
-
#fae_filter_input(attribute, options = {}) ⇒ Object
this isn’t implemented yet, but saving the markup here.
- #fae_filter_select(attribute, options = {}) ⇒ Object
- #fae_image_form(f, image_name, label: nil, alt_label: nil, caption_label: nil, show_alt: nil, show_caption: nil, required: nil, helper_text: nil, alt_helper_text: nil, caption_helper_text: nil, attached_as: nil) ⇒ Object
- #fae_path ⇒ Object
Instance Method Details
#attr_toggle(item, column) ⇒ Object Also known as: fae_toggle
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/fae/view_helper.rb', line 28 def attr_toggle(item, column) active = item.send(column) link_class = active ? 'slider-yes-selected' : '' model_name = item.class.to_s.include?("Fae::") ? item.class.to_s.gsub('::','').underscore.pluralize : item.class.to_s.underscore.pluralize url = fae.toggle_path(model_name, item.id.to_s, column) link_to url, class: "slider-wrapper #{link_class}", method: :post, remote: true do '<div class="slider-options"> <div class="slider-option slider-option-yes">Yes</div> <div class="slider-option-selector"></div> <div class="slider-option slider-option-no">No</div> </div>'.html_safe end end |
#fae_clone_button(item) ⇒ Object
45 46 47 48 49 50 |
# File 'app/helpers/fae/view_helper.rb', line 45 def (item) return if item.blank? link_to "#{@index_path}?from_existing=#{item.id}", method: :post, title: 'Clone', class: 'main_table-action main_table-clone' do concat content_tag :span, nil, class: 'icon-copy' end end |
#fae_content_form(f, attribute, label: nil, hint: nil, helper_text: nil, markdown: nil, markdown_supported: nil) ⇒ Object
24 25 26 |
# File 'app/helpers/fae/view_helper.rb', line 24 def fae_content_form(f, attribute, label: nil, hint: nil, helper_text: nil, markdown: nil, markdown_supported: nil) render 'fae/application/content_form', f: f, attribute: attribute, label: label, hint: hint, helper_text: helper_text, markdown: markdown, markdown_supported: markdown_supported end |
#fae_date_format(datetime, timezone = @option.time_zone) ⇒ Object
4 5 6 |
# File 'app/helpers/fae/view_helper.rb', line 4 def fae_date_format(datetime, timezone = @option.time_zone) datetime.in_time_zone(timezone).strftime('%m/%d/%y') if is_date_or_time?(datetime) end |
#fae_datetime_format(datetime, timezone = @option.time_zone) ⇒ Object
8 9 10 |
# File 'app/helpers/fae/view_helper.rb', line 8 def fae_datetime_format(datetime, timezone = @option.time_zone) datetime.in_time_zone(timezone).strftime("%b %-d, %Y %l:%M%P %Z") if is_date_or_time?(datetime) end |
#fae_file_form(f, file_name, label: nil, helper_text: nil, required: nil) ⇒ Object
20 21 22 |
# File 'app/helpers/fae/view_helper.rb', line 20 def fae_file_form(f, file_name, label: nil, helper_text: nil, required: nil) render 'fae/application/file_uploader', f: f, file_name: file_name, label: label, required: required, helper_text: helper_text end |
#fae_filter_form(options = {}, &block) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/helpers/fae/view_helper.rb', line 52 def fae_filter_form( = {}, &block) [:action] ||= "#{@index_path}/filter" [:title] ||= "Search #{@klass_humanized.pluralize}" [:search] = true if [:search].nil? [:cookie_key] ||= false form_hash = { remote: true, class: 'js-filter-form table-filter-area' } form_hash['data-cookie-key'] = [:cookie_key] if [:cookie_key].present? form_tag([:action], form_hash) do concat content_tag :h2, [:title] concat filter_search_field if [:search] concat capture(&block) concat filter_submit_btns end end |
#fae_filter_input(attribute, options = {}) ⇒ Object
this isn’t implemented yet, but saving the markup here
95 96 97 98 99 100 |
# File 'app/helpers/fae/view_helper.rb', line 95 def fae_filter_input(attribute, = {}) '<div class="table-filter-group"> <label for="filter_city">Input</label> <input type="text" /> </div>'.html_safe end |
#fae_filter_select(attribute, options = {}) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/helpers/fae/view_helper.rb', line 69 def fae_filter_select(attribute, = {}) [:label] ||= attribute.to_s.titleize [:collection] ||= default_collection_from_attribute(attribute) [:label_method] ||= :fae_display_field [:placeholder] = "All #{[:label].pluralize}" if [:placeholder].nil? [:options] ||= [] [:grouped_by] ||= nil [:grouped_options] ||= [] # grouped_by takes priority over grouped_options if [:grouped_by].present? = filter_generate_select_group([:collection], [:grouped_by], [:label_method]) elsif [:grouped_options].present? = ([:grouped_options]) else = ([:collection], 'id', [:label_method]) = ([:options]) if [:options].present? end content_tag :div, class: 'table-filter-group' do concat label_tag "filter[#{attribute}]", [:label] concat select_tag "filter[#{attribute}]", , prompt: [:placeholder] end end |
#fae_image_form(f, image_name, label: nil, alt_label: nil, caption_label: nil, show_alt: nil, show_caption: nil, required: nil, helper_text: nil, alt_helper_text: nil, caption_helper_text: nil, attached_as: nil) ⇒ Object
16 17 18 |
# File 'app/helpers/fae/view_helper.rb', line 16 def fae_image_form(f, image_name, label: nil, alt_label: nil, caption_label: nil, show_alt: nil, show_caption: nil, required: nil, helper_text: nil, alt_helper_text: nil, caption_helper_text: nil, attached_as: nil) render 'fae/images/image_uploader', f: f, image_name: image_name, label: label, alt_label: alt_label, caption_label: , show_alt: show_alt, show_caption: , required: required, helper_text: helper_text, alt_helper_text: alt_helper_text, caption_helper_text: , attached_as: attached_as end |
#fae_path ⇒ Object
12 13 14 |
# File 'app/helpers/fae/view_helper.rb', line 12 def fae_path Rails.application.routes.url_helpers.fae_path[1..-1] end |