Class: Matestack::Ui::Bootstrap::Form::Date

Inherits:
Core::Component::Dynamic
  • Object
show all
Includes:
Core::Form::HasErrors, Core::Form::HasInputHtmlAttributes, Core::Form::Utils
Defined in:
app/concepts/matestack/ui/bootstrap/form/date.rb

Instance Method Summary collapse

Instance Method Details

#attr_keyObject



59
60
61
# File 'app/concepts/matestack/ui/bootstrap/form/date.rb', line 59

def attr_key
  super
end

#change_eventObject



51
52
53
# File 'app/concepts/matestack/ui/bootstrap/form/date.rb', line 51

def change_event
  "$parent.inputChanged('#{attr_key}');".strip
end

#custom_options_validationObject



55
56
57
# File 'app/concepts/matestack/ui/bootstrap/form/date.rb', line 55

def custom_options_validation
  raise "included form config is missing, please add ':include' to parent form component" if @included_config.nil?
end

#error_keyObject



22
23
24
# File 'app/concepts/matestack/ui/bootstrap/form/date.rb', line 22

def error_key
  "$parent.errors[\"#{key}\"]"
end

#input_keyObject



18
19
20
# File 'app/concepts/matestack/ui/bootstrap/form/date.rb', line 18

def input_key
  "$parent.data[\"#{key}\"]"
end

#responseObject



31
32
33
34
35
36
37
38
# File 'app/concepts/matestack/ui/bootstrap/form/date.rb', line 31

def response
  div do
    label for: attr_key,  class: "form-label", text: input_label if input_label
    input html_attributes.merge(attributes: vue_attributes).merge(bootstrap_input_attributes)
    render_errors
    render_form_text if form_text
  end
end

#setupObject



26
27
28
29
# File 'app/concepts/matestack/ui/bootstrap/form/date.rb', line 26

def setup
  @component_config[:init_value] = init_value
  @component_config[:with_time] = with_time
end

#vue_attributesObject



40
41
42
43
44
45
46
47
48
49
# File 'app/concepts/matestack/ui/bootstrap/form/date.rb', line 40

def vue_attributes
  (options[:attributes] || {}).merge({
    id: attr_key,
    "@change": change_event,
    ref: "input.#{attr_key}",
    'init-value': init_value,
    'v-bind:class': "{ '#{input_error_class}': #{error_key} }",
    "aria-describedby": attr_key
  }).merge({ "v-model": input_key })
end