Class: Alchemy::Ingredients::HeadlineEditor

Inherits:
BaseEditor
  • Object
show all
Defined in:
app/components/alchemy/ingredients/headline_editor.rb

Instance Attribute Summary

Attributes inherited from BaseEditor

#html_options, #ingredient

Instance Method Summary collapse

Methods inherited from BaseEditor

#call, #form_field_id, #form_field_name, #initialize

Constructor Details

This class inherits a constructor from Alchemy::Ingredients::BaseEditor

Instance Method Details

#input_fieldObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/components/alchemy/ingredients/headline_editor.rb', line 8

def input_field
  tag.div(class: "input-field") do
    concat text_field_tag(form_field_name,
      value,
      minlength: length_validation&.fetch(:minimum, nil),
      maxlength: length_validation&.fetch(:maximum, nil),
      readonly: !editable?,
      required: presence_validation?,
      pattern: format_validation,
      id: form_field_id)

    if settings[:anchor]
      concat render(
        "alchemy/ingredients/shared/anchor",
        ingredient:
      )
    end

    concat(
      tag.div(class: ["input-addon", "right", has_size_select? ? "second" : nil].compact) do
        ("sl-tooltip",
          content: ingredient.class.human_attribute_name(:level),
          disabled: !editable?) do
          select_tag(
            form_field_name(:level),
            options_for_select(level_options, level),
            class: "custom-select",
            disabled: !has_level_select? || !editable?
          )
        end
      end
    )

    if has_size_select?
      concat(
        tag.div(class: "input-addon right") do
          ("sl-tooltip",
            content: ingredient.class.human_attribute_name(:size),
            disabled: !editable?) do
            select_tag(
              form_field_name(:size),
              options_for_select(size_options, size),
              class: "custom-select",
              disabled: !editable?
            )
          end
        end
      )
    end
  end
end