Class: Matestack::Ui::Bootstrap::Form::Select

Inherits:
VueJs::Components::Form::Select
  • Object
show all
Defined in:
lib/matestack/ui/bootstrap/form/select.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_select_attributesObject



20
21
22
23
24
25
26
# File 'lib/matestack/ui/bootstrap/form/select.rb', line 20

def bootstrap_select_attributes
  {
    class: form_select_class,
    size: size_class,
    disabled: context.disabled
  }
end

#form_select_classObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/matestack/ui/bootstrap/form/select.rb', line 28

def form_select_class
  case context.variant
  when :lg
    (options[:class] || "") << (" form-select form-select-lg")
  when :sm
    (options[:class] || "") << (" form-select form-select-sm")
  else
    (options[:class] || "") << (" form-select")
  end
end

#input_error_classObject



51
52
53
# File 'lib/matestack/ui/bootstrap/form/select.rb', line 51

def input_error_class
  'is-invalid'
end

#render_errorsObject



43
44
45
46
47
48
49
# File 'lib/matestack/ui/bootstrap/form/select.rb', line 43

def render_errors
  if display_errors?
    div class: 'invalid-feedback', 'v-for': "error in #{error_key}" do
      plain '{{ error }}'
    end
  end
end

#render_form_textObject



55
56
57
58
59
# File 'lib/matestack/ui/bootstrap/form/select.rb', line 55

def render_form_text
  div class: "form-text form-text-for-#{attribute_key}" do
    plain context.form_text
  end
end

#responseObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/matestack/ui/bootstrap/form/select.rb', line 9

def response
  div class: "matestack-ui-bootstrap-form-select" do
    label input_label, ":for": id,  class: "form-label" if input_label
    select select_attributes.merge(bootstrap_select_attributes) do
      render_options
    end
    render_errors
    render_form_text
  end
end

#size_classObject



39
40
41
# File 'lib/matestack/ui/bootstrap/form/select.rb', line 39

def size_class
  context.size
end