Module: Alchemy::Admin::IngredientsHelper

Includes:
BaseHelper
Included in:
ElementsHelper
Defined in:
app/helpers/alchemy/admin/ingredients_helper.rb

Instance Method Summary collapse

Methods included from BaseHelper

#alchemy_body_class, #alchemy_datepicker, #button_with_confirm, #clipboard_select_tag_options, #current_alchemy_user_name, #delete_button, #hint_with_tooltip, #js_filter_field, #link_to_confirm_dialog, #link_to_dialog, #link_url_regexp, #page_layout_missing_warning, #render_alchemy_title, #render_hint_for, #sites_for_select, #toolbar_button, #translations_for_select

Methods included from NavigationHelper

#alchemy_main_navigation_entry, #entry_active?, #main_navigation_css_classes, #navigate_module, #sorted_alchemy_modules, #url_for_module, #url_for_module_sub_navigation

Methods included from BaseHelper

#page_or_find, #render_icon, #render_message, #shorten, #warning

Instance Method Details

#ingredient_label(ingredient, column = :value, html_options = {}) ⇒ Object

Renders the label and hint for a ingredient.



35
36
37
38
39
40
41
42
# File 'app/helpers/alchemy/admin/ingredients_helper.rb', line 35

def ingredient_label(ingredient, column = :value, html_options = {})
  label_tag ingredient.form_field_id(column), html_options do
    [
      render_ingredient_role(ingredient),
      render_hint_for(ingredient, size: "1x", fixed_width: false)
    ].compact.join(" ").html_safe
  end
end

#render_ingredient_role(ingredient) ⇒ Object

Renders the translated role of ingredient.

Displays a warning icon if ingredient is missing its definition.

Displays a mandatory field indicator, if the ingredient has validations.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/alchemy/admin/ingredients_helper.rb', line 14

def render_ingredient_role(ingredient)
  if ingredient.blank?
    warning("Ingredient is nil")
    return
  end

  content = ingredient.translated_role

  if ingredient.has_warnings?
    icon = hint_with_tooltip(ingredient.warnings)
    content = "#{icon} #{content}".html_safe
  end

  if ingredient.has_validations?
    "#{content}<span class='validation_indicator'>*</span>".html_safe
  else
    content
  end
end