Class: Matestack::Ui::Bootstrap::Form::Input
- Inherits:
-
VueJs::Components::Form::Input
- Object
- VueJs::Components::Form::Input
- Matestack::Ui::Bootstrap::Form::Input
show all
- Includes:
- Registry
- Defined in:
- lib/matestack/ui/bootstrap/form/input.rb
Instance Method Summary
collapse
Methods included from Registry
#bs_accordion, #bs_alert, #bs_avatar, #bs_badge, #bs_breadcrumb, #bs_btn, #bs_btn_group, #bs_card, #bs_carousel, #bs_close, #bs_col, #bs_collapse, #bs_container, #bs_dropdown, #bs_figure, #bs_form_checkbox, #bs_form_input, #bs_form_radio, #bs_form_select, #bs_form_submit, #bs_form_switch, #bs_icon, #bs_list_group, #bs_modal, #bs_navbar, #bs_page_heading, #bs_pagination, #bs_popover, #bs_progress, #bs_row, #bs_scrollspy, #bs_section_card, #bs_sidebar, #bs_smart_collection, #bs_spinner, #bs_tab_nav, #bs_tab_nav_content, #bs_toast, #bs_tooltip
Instance Method Details
56
57
58
59
60
61
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 56
def bootstrap_file_input_attributes
{
class: (options[:class] || "") << (" form-file-input"),
disabled: context.disabled
}
end
|
38
39
40
41
42
43
44
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 38
def bootstrap_input_attributes
{
id: (options[:id] || attribute_key),
class: (options[:class] || "") << (" form-control"),
disabled: context.disabled
}
end
|
#bootstrap_range_attributes ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 46
def bootstrap_range_attributes
{
class: (options[:class] || "") << (" form-range"),
disabled: context.disabled,
min: context.min,
max: context.max,
step: context.step
}
end
|
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 74
def file_input
div class: form_file_wrapper_class do
input options.merge(input_attributes).merge(bootstrap_file_input_attributes)
label class: "form-file-label", for: attribute_key do
span class: "form-file-text", "v-if": "data['#{attribute_key}']" do
if context.multiple
span "v-for": "file in data['#{attribute_key}']" do
plain "{{ file['name'] }}"
end
else
plain "{{ data['#{attribute_key}']['name'] }}"
end
end
span class: "form-file-text", "v-if": "!data['#{attribute_key}']" do
plain context.placeholder || "Choose file"
end
span class: "form-file-button" do
plain context.browse_button_text || "Browse"
end
end
render_errors
end
end
|
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 63
def form_file_wrapper_class
case context.variant
when :lg
(options[:class] || "") << (" form-file form-file-lg")
when :sm
(options[:class] || "") << (" form-file form-file-sm")
else
(options[:class] || "") << (" form-file")
end
end
|
106
107
108
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 106
def input_error_class
'is-invalid'
end
|
#render_errors ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 98
def render_errors
if display_errors?
div class: 'invalid-feedback', 'v-for': "error in #{error_key}" do
plain '{{ error }}'
end
end
end
|
#render_form_text ⇒ Object
110
111
112
113
114
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 110
def render_form_text
div id: "form_text_for_#{attribute_key}", class: "form-text" do
plain context.form_text
end
end
|
#response ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/matestack/ui/bootstrap/form/input.rb', line 17
def response
div class: "matestack-ui-bootstrap-input" do
label input_label, for: attribute_key, class: "form-label" if input_label
case context.type
when :range
input options.merge(input_attributes).merge(bootstrap_range_attributes)
if context.show_value
div id: attribute_key, class: "form-text" do
plain "{{ data['#{attribute_key}'] }}"
end
end
when :file
file_input
else
input options.merge(input_attributes).merge(bootstrap_input_attributes)
render_errors
end
render_form_text if context.form_text
end
end
|