Sha256: 9e4e1e8be35a290f661baee273d0c8f42fcb1c6e6455f1246e2a15572ce3b61e

Contents?: true

Size: 1.25 KB

Versions: 29

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module Alchemy
  module Admin
    module ContentsHelper
      include Alchemy::Admin::BaseHelper

      # Renders the name of elements content.
      #
      # Displays a warning icon if content is missing its definition.
      #
      # Displays a mandatory field indicator, if the content has validations.
      #
      def render_content_name(content)
        if content.blank?
          warning("Content is nil")
          return
        end

        content_name = content.name_for_label

        if content.definition.blank?
          warning("Content #{content.name} is missing its definition")

          icon = hint_with_tooltip(
            Alchemy.t(:content_definition_missing),
          )

          content_name = "#{icon} #{content_name}".html_safe
        end

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

      # Renders the label and a remove link for a content.
      def content_label(content)
        content_tag :label, for: content.form_field_id do
          [render_hint_for(content), render_content_name(content)].compact.join("&nbsp;").html_safe
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
alchemy_cms-5.1.10 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.10 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.9 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.9 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.8 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.8 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.7 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.7 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.6 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.6 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.5 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.5 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.4 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.4 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.3 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.2 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.1 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.3 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.1.0 app/helpers/alchemy/admin/contents_helper.rb
alchemy_cms-5.0.2 app/helpers/alchemy/admin/contents_helper.rb