Module: Spree::Admin::BaseHelper
- Defined in:
- app/helpers/spree/admin/base_helper.rb
Instance Method Summary collapse
- #admin_hint(title, text) ⇒ Object
- #admin_layout(layout = nil) ⇒ Object
- #datepicker_field_value(date, with_time: false) ⇒ Object
- #error_message_on(object, method, _options = {}) ⇒ Object
- #field_container(model, method, options = {}, &block) ⇒ Object
- #spree_dom_id(record) ⇒ Object
Instance Method Details
#admin_hint(title, text) ⇒ Object
27 28 29 30 31 |
# File 'app/helpers/spree/admin/base_helper.rb', line 27 def admin_hint(title, text) content_tag(:span, class: 'hint-tooltip', title:, data: { content: text }) do content_tag(:i, '', class: 'fa fa-info-circle') end end |
#admin_layout(layout = nil) ⇒ Object
49 50 51 52 |
# File 'app/helpers/spree/admin/base_helper.rb', line 49 def admin_layout(layout = nil) @admin_layout = layout if layout @admin_layout end |
#datepicker_field_value(date, with_time: false) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/spree/admin/base_helper.rb', line 33 def datepicker_field_value(date, with_time: false) return if date.blank? format = if with_time t('spree.date_picker.format_with_time', default: '%Y/%m/%d %H:%M') else t('spree.date_picker.format', default: '%Y/%m/%d') end l(date, format:) end |
#error_message_on(object, method, _options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/spree/admin/base_helper.rb', line 15 def (object, method, = {}) object = convert_to_model(object) obj = object.respond_to?(:errors) ? object : instance_variable_get("@#{object}") if obj && obj.errors[method].present? errors = safe_join(obj.errors[method], "<br>".html_safe) content_tag(:span, errors, class: 'formError') else '' end end |
#field_container(model, method, options = {}, &block) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/helpers/spree/admin/base_helper.rb', line 6 def field_container(model, method, = {}, &block) css_classes = [:class].to_a css_classes << 'field' if (model, method).present? css_classes << 'withError' end content_tag(:div, capture(&block), class: css_classes.join(' '), id: "#{model}_#{method}_field") end |
#spree_dom_id(record) ⇒ Object
45 46 47 |
# File 'app/helpers/spree/admin/base_helper.rb', line 45 def spree_dom_id(record) dom_id(record, 'spree') end |