Sha256: d3e1cf18b3f90a16eb1126e5f2e2216dde0baa64c1dbf0b356a60fd7f4c39339

Contents?: true

Size: 1.16 KB

Versions: 45

Compression:

Stored size: 1.16 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)
        label_tag ingredient.form_field_id(column) do
          [render_ingredient_role(ingredient), render_hint_for(ingredient)].compact.join("&nbsp;").html_safe
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
alchemy_cms-6.1.10 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.9 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.8 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.7 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.0.1 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.0.0 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.0.0.pre.rc1 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.6 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.0.0.pre.c app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.0.0.pre.b app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.5 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.0.14 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.4 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-7.0.0.pre.a app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.0.13 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.3 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.2 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.1 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.1.0 app/helpers/alchemy/admin/ingredients_helper.rb
alchemy_cms-6.0.12 app/helpers/alchemy/admin/ingredients_helper.rb