AlchemyCMS/alchemy_cms

View on GitHub
app/views/alchemy/ingredients/_headline_editor.html.erb

Summary

Maintainability
Test Coverage
<% has_level_select = headline_editor.level_options.many? %>
<% has_size_select = headline_editor.size_options.many? %>

<%= content_tag :div,
  class: headline_editor.css_classes,
  data: headline_editor.data_attributes do %>
  <%= element_form.fields_for(:ingredients, headline_editor.ingredient) do |f| %>
    <%= ingredient_label(headline_editor) %>
    <%= f.text_field :value, id: headline_editor.form_field_id %>

    <% if headline_editor.settings[:anchor] %>
      <%= render "alchemy/ingredients/shared/anchor", ingredient_editor: headline_editor %>
    <% end %>

    <div class="input-addon right<%= " second" if has_size_select %>">
      <sl-tooltip content="<%= f.object.class.human_attribute_name(:level) %>">
        <%= f.select :level,
          options_for_select(headline_editor.level_options, headline_editor.level),
          {},
          {
            class: "custom-select",
            disabled: !has_level_select
          } %>
      </sl-tooltip>
    </div>

    <% if has_size_select %>
      <div class="input-addon right">
        <sl-tooltip content="<%= f.object.class.human_attribute_name(:size) %>">
          <%= f.select :size, options_for_select(headline_editor.size_options, headline_editor.size),
            {},
            { class: "custom-select" } %>
        </sl-tooltip>
      </div>
    <% end %>
  <% end %>
<% end %>