Sha256: 9d3df21307c8f20bbe50d1b0c20a7a655b6b2b6296db7a1040095d6c12e6846a

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Alchemy
  module Admin
    module IngredientsHelper
      include Alchemy::Admin::BaseHelper

      # 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.
      #
      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

      # Renders the label and hint for a ingredient.
      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("&nbsp;").html_safe
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
alchemy_cms-7.3.5 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.2.8 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.3.4 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.3.3 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.3.2 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.2.7 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.3.1 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.3.0 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.2.6 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.2.5 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.2.4 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.2.3 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.2.2 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.2.1 app/helpers/alchemy/admin/ingredients_helper.rb