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

Inherits:
Core::Form::Select::Select
  • Object
show all
Defined in:
app/concepts/matestack/ui/bootstrap/form/select.rb

Instance Method Summary collapse

Instance Method Details

#determine_init_valueObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 36

def determine_init_value
  if init_value
    init_value
  else
    if multiple
      []
    else
      nil
    end
  end
end

#form_select_classObject



21
22
23
24
25
26
27
28
29
30
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 21

def form_select_class
  case 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



64
65
66
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 64

def input_error_class
  'is-invalid'
end

#placeholder_valueObject



48
49
50
51
52
53
54
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 48

def placeholder_value
  if multiple
    '[]'
  else
    'null'
  end
end

#render_errorsObject



56
57
58
59
60
61
62
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 56

def render_errors
  unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
    div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
      plain '{{ error }}'
    end
  end
end

#render_form_textObject



68
69
70
71
72
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 68

def render_form_text
  div id: "form_text_for_#{attr_key}", class: "form-text" do
    plain form_text
  end
end

#size_classObject



32
33
34
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 32

def size_class
  size
end

#vue_attributesObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/concepts/matestack/ui/bootstrap/form/select.rb', line 7

def vue_attributes
  (options[:attributes] || {}).merge({
    "@change": change_event,
    ref: vue_ref,
    'init-value': determine_init_value,
    'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
    'value-type': value_type,
    'class': form_select_class,
    'size': size_class,
    'id': attr_key,
    "#{v_model_type}": input_key,
  })
end