Module: ArticlesHelper
Instance Method Summary collapse
- #field_with_preset_value_and_errors(options) ⇒ Object
- #format_billing_unit(article) ⇒ Object
- #format_billing_unit_with_ratios(article) ⇒ Object
- #format_group_order_unit(article) ⇒ Object
- #format_group_order_unit_with_ratios(article) ⇒ Object
- #format_price_unit(article) ⇒ Object
- #format_supplier_order_unit(article) ⇒ Object
- #format_supplier_order_unit_with_ratios(article) ⇒ Object
-
#highlight_new(unequal_attributes, attributes) ⇒ Object
useful for highlighting attributes, when synchronizing articles.
- #row_classes(article) ⇒ Object
Instance Method Details
#field_with_preset_value_and_errors(options) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/articles_helper.rb', line 46 def field_with_preset_value_and_errors() form, field, value, field_errors, input_html = .values_at(:form, :field, :value, :errors, :input_html) form.input field, label: false, wrapper_html: { class: field_errors.blank? ? '' : 'error' }, input_html: input_html, wrapper: :inline_form do output = [form.input_field(field, { value: value }.merge(input_html))] if field_errors.present? errors = tag.span(class: 'help-inline') do field_errors.join(', ') end output << errors end safe_join(output) end end |
#format_billing_unit(article) ⇒ Object
26 27 28 |
# File 'app/helpers/articles_helper.rb', line 26 def format_billing_unit(article) format_unit(:billing_unit, article) end |
#format_billing_unit_with_ratios(article) ⇒ Object
42 43 44 |
# File 'app/helpers/articles_helper.rb', line 42 def format_billing_unit_with_ratios(article) format_unit_with_ratios(:billing_unit, article) end |
#format_group_order_unit(article) ⇒ Object
22 23 24 |
# File 'app/helpers/articles_helper.rb', line 22 def format_group_order_unit(article) format_unit(:group_order_unit, article) end |
#format_group_order_unit_with_ratios(article) ⇒ Object
38 39 40 |
# File 'app/helpers/articles_helper.rb', line 38 def format_group_order_unit_with_ratios(article) format_unit_with_ratios(:group_order_unit, article) end |
#format_price_unit(article) ⇒ Object
30 31 32 |
# File 'app/helpers/articles_helper.rb', line 30 def format_price_unit(article) format_unit(:price_unit, article) end |
#format_supplier_order_unit(article) ⇒ Object
18 19 20 |
# File 'app/helpers/articles_helper.rb', line 18 def format_supplier_order_unit(article) format_unit(:supplier_order_unit, article) end |
#format_supplier_order_unit_with_ratios(article) ⇒ Object
34 35 36 |
# File 'app/helpers/articles_helper.rb', line 34 def format_supplier_order_unit_with_ratios(article) format_unit_with_ratios(:supplier_order_unit, article) end |
#highlight_new(unequal_attributes, attributes) ⇒ Object
useful for highlighting attributes, when synchronizing articles
3 4 5 6 7 8 9 |
# File 'app/helpers/articles_helper.rb', line 3 def highlight_new(unequal_attributes, attributes) attributes = [attributes] unless attributes.is_a?(Array) return unless unequal_attributes intersection = (unequal_attributes.keys & attributes) intersection.empty? ? '' : 'background-color: yellow' end |
#row_classes(article) ⇒ Object
11 12 13 14 15 16 |
# File 'app/helpers/articles_helper.rb', line 11 def row_classes(article) classes = [] classes << 'unavailable' unless article.availability classes << 'just-updated' if article.recently_updated && article.availability classes.join(' ') end |