matestack-ui-bootstrap 1.5.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +17 -5
- data/lib/matestack/ui/bootstrap.rb +96 -17
- data/{app/concepts → lib}/matestack/ui/bootstrap/apps/admin_template.rb +14 -7
- data/lib/matestack/ui/bootstrap/base_component.rb +13 -0
- data/lib/matestack/ui/bootstrap/base_vue_js_component.rb +13 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/accordion.rb +18 -16
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/alert.js +12 -9
- data/lib/matestack/ui/bootstrap/components/alert.rb +43 -0
- data/lib/matestack/ui/bootstrap/components/avatar.rb +27 -0
- data/lib/matestack/ui/bootstrap/components/badge.rb +32 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/breadcrumb.rb +12 -10
- data/lib/matestack/ui/bootstrap/components/button.rb +71 -0
- data/lib/matestack/ui/bootstrap/components/button_group.rb +36 -0
- data/lib/matestack/ui/bootstrap/components/card.rb +105 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/carousel.js +21 -18
- data/lib/matestack/ui/bootstrap/components/carousel.rb +103 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/close.rb +10 -9
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/collapse.js +20 -17
- data/lib/matestack/ui/bootstrap/components/collapse.rb +54 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.js +5 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/dropdown.rb +29 -25
- data/lib/matestack/ui/bootstrap/components/icon.rb +21 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/list_group.rb +32 -29
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/modal.js +24 -21
- data/lib/matestack/ui/bootstrap/components/modal.rb +121 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/navbar.rb +37 -28
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/page_heading.rb +7 -5
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/pagination.rb +11 -9
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.js +4 -1
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/popover.rb +25 -21
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/progress.rb +19 -19
- data/lib/matestack/ui/bootstrap/components/scrollspy.rb +50 -0
- data/lib/matestack/ui/bootstrap/components/section_card.rb +33 -0
- data/lib/matestack/ui/bootstrap/components/spinner.rb +35 -0
- data/lib/matestack/ui/bootstrap/components/tab_nav.rb +79 -0
- data/lib/matestack/ui/bootstrap/components/tab_nav_content.rb +35 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/toast.js +22 -19
- data/lib/matestack/ui/bootstrap/components/toast.rb +113 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.js +4 -1
- data/{app/concepts → lib}/matestack/ui/bootstrap/components/tooltip.rb +20 -18
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/figure.rb +4 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/collection.rb +22 -16
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/collection.scss +0 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/content.rb +23 -19
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/filter.rb +6 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/content/smart_collection/paginate.rb +16 -11
- data/lib/matestack/ui/bootstrap/form/checkbox.rb +81 -0
- data/lib/matestack/ui/bootstrap/form/input.rb +116 -0
- data/lib/matestack/ui/bootstrap/form/radio.rb +55 -0
- data/lib/matestack/ui/bootstrap/form/select.rb +63 -0
- data/lib/matestack/ui/bootstrap/form/submit.rb +20 -0
- data/lib/matestack/ui/bootstrap/form/switch.rb +32 -0
- data/lib/matestack/ui/bootstrap/index.js +24 -0
- data/lib/matestack/ui/bootstrap/layout/column.rb +49 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/container.rb +12 -9
- data/lib/matestack/ui/bootstrap/layout/row.rb +25 -0
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.js +5 -2
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.rb +10 -10
- data/{app/concepts → lib}/matestack/ui/bootstrap/layout/sidebar.scss +0 -0
- data/lib/matestack/ui/bootstrap/registry.rb +169 -0
- data/{app/javascript/matestack-ui-bootstrap → lib/matestack/ui/bootstrap}/stylesheets/matestack-ui-bootstrap.scss +0 -0
- data/lib/matestack/ui/bootstrap/version.rb +1 -1
- metadata +67 -72
- data/app/assets/images/avatar-placeholder.png +0 -0
- data/app/assets/images/icons/bootstrap-icons.svg +0 -1
- data/app/concepts/matestack/ui/bootstrap/components/alert.rb +0 -34
- data/app/concepts/matestack/ui/bootstrap/components/avatar.rb +0 -27
- data/app/concepts/matestack/ui/bootstrap/components/badge.rb +0 -30
- data/app/concepts/matestack/ui/bootstrap/components/button.rb +0 -69
- data/app/concepts/matestack/ui/bootstrap/components/button_group.rb +0 -36
- data/app/concepts/matestack/ui/bootstrap/components/card.rb +0 -100
- data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +0 -86
- data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +0 -43
- data/app/concepts/matestack/ui/bootstrap/components/icon.rb +0 -19
- data/app/concepts/matestack/ui/bootstrap/components/modal.rb +0 -106
- data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +0 -48
- data/app/concepts/matestack/ui/bootstrap/components/section_card.rb +0 -31
- data/app/concepts/matestack/ui/bootstrap/components/spinner.rb +0 -31
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav.rb +0 -83
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav_content.rb +0 -32
- data/app/concepts/matestack/ui/bootstrap/components/toast.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/form/input.rb +0 -112
- data/app/concepts/matestack/ui/bootstrap/form/radio.rb +0 -57
- data/app/concepts/matestack/ui/bootstrap/form/select.rb +0 -53
- data/app/concepts/matestack/ui/bootstrap/form/submit.rb +0 -21
- data/app/concepts/matestack/ui/bootstrap/form/switch.rb +0 -99
- data/app/concepts/matestack/ui/bootstrap/layout/column.rb +0 -47
- data/app/concepts/matestack/ui/bootstrap/layout/row.rb +0 -15
- data/app/concepts/matestack/ui/bootstrap/pages/devise/sign_in.rb +0 -40
- data/app/concepts/matestack/ui/bootstrap/registry.rb +0 -61
- data/app/helpers/matestack/ui/bootstrap/application_helper.rb +0 -17
- data/app/javascript/matestack-ui-bootstrap/index.js +0 -24
- data/app/javascript/packs/matestack-ui-bootstrap.js +0 -2
- data/app/matestack/bootstrap/form/submit.rb +0 -20
- data/config/routes.rb +0 -2
- data/lib/matestack/ui/bootstrap/engine.rb +0 -26
@@ -1,48 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::Scrollspy < Matestack::Ui::Component
|
2
|
-
|
3
|
-
requires :height
|
4
|
-
|
5
|
-
optional :offset # pixel to offset from top, by default 10
|
6
|
-
optional method: { as: :bs_method} # find which section, by default auto
|
7
|
-
optional :target # scroll target id
|
8
|
-
optional class: { as: :bs_class} # adding custom class to scrollspy
|
9
|
-
|
10
|
-
def response
|
11
|
-
div scrollspy_attributes do
|
12
|
-
yield_components
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def scrollspy_attributes
|
19
|
-
attributes = {}.tap do |hash|
|
20
|
-
hash[:class] = scrollspy_classes
|
21
|
-
hash[:data] = { "bs-spy": "scroll", "bs-target": "#{target}" }
|
22
|
-
hash[:data].merge!("bs-offset": offset) if offset.present?
|
23
|
-
hash[:data].merge!("bs-method": :"#{bs_method}") if bs_method.present?
|
24
|
-
hash[:style] = "overflow-y: scroll; position: relative;"
|
25
|
-
hash[:style] << "height: #{parsed_height};"
|
26
|
-
hash[:tabindex] = 0
|
27
|
-
end
|
28
|
-
html_attributes.merge(
|
29
|
-
attributes
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
def parsed_height
|
34
|
-
if height.present?
|
35
|
-
if height.to_s.include?("px") || height.to_s.include?("em") || height.to_s.include?("rem")
|
36
|
-
height
|
37
|
-
else
|
38
|
-
"#{height}px"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def scrollspy_classes
|
44
|
-
[].tap do |classes|
|
45
|
-
classes << bs_class
|
46
|
-
end.join(' ').strip
|
47
|
-
end
|
48
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::SectionCard < Matestack::Ui::Component
|
2
|
-
|
3
|
-
optional :id, :title, :subtitle, :icon, :slots, :content_padding
|
4
|
-
|
5
|
-
def response
|
6
|
-
section id: :id, class: "section-card rounded shadow-sm mb-4 bg-white" do
|
7
|
-
div class: "d-flex flex-row justify-content-between" do
|
8
|
-
if title.present? || subtitle.present?
|
9
|
-
div class: "section-card-heading p-4" do
|
10
|
-
heading size: 5, class: "mb-0" do
|
11
|
-
bs_icon name: icon, size: "35" if icon.present?
|
12
|
-
plain title
|
13
|
-
end
|
14
|
-
small class: "text-muted" do
|
15
|
-
plain subtitle
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
if slots.present? && slots[:actions].present?
|
20
|
-
div class: "section-card-actions p-4" do
|
21
|
-
slot slots[:actions]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
div class: "section-card-content #{'p-4' unless content_padding == false} #{'pt-1' if title || subtitle}" do
|
26
|
-
yield_components
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::Spinner < Matestack::Ui::Component
|
2
|
-
|
3
|
-
optional class: { as: :bs_class }
|
4
|
-
optional :kind, :variant, :size, :sr_only
|
5
|
-
|
6
|
-
def response
|
7
|
-
div spinner_attributes do
|
8
|
-
span class: "visually-hidden", text: sr_only
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
protected
|
13
|
-
|
14
|
-
def spinner_attributes
|
15
|
-
html_attributes.merge(
|
16
|
-
class: spinner_class,
|
17
|
-
attributes: { 'role': "status" }
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
def spinner_class
|
22
|
-
[].tap do |classes|
|
23
|
-
spinner_kind = kind || :border
|
24
|
-
classes << "spinner-#{spinner_kind}"
|
25
|
-
classes << "text-#{variant || 'primary'}"
|
26
|
-
classes << "spinner-#{spinner_kind}-sm" if size
|
27
|
-
#optional classes
|
28
|
-
classes << bs_class
|
29
|
-
end.join(' ').strip
|
30
|
-
end
|
31
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::TabNav < Matestack::Ui::Component
|
2
|
-
|
3
|
-
requires :id
|
4
|
-
|
5
|
-
optional :items, :variant, :fill, :justified, :vertical, :vertical_up_to_sm,
|
6
|
-
:vertical_up_to_md, :vertical_up_to_xl, :horizontal,
|
7
|
-
class: { as: :bs_class }, attributes: { as: :bs_attrs}
|
8
|
-
|
9
|
-
def response
|
10
|
-
if items.present?
|
11
|
-
ul nav_attributes do
|
12
|
-
nav_items_partial
|
13
|
-
end
|
14
|
-
end
|
15
|
-
div class: "tab-content", id: "#{id}Content" do
|
16
|
-
yield_components
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
def nav_items_partial
|
23
|
-
items.each do |item|
|
24
|
-
li class: "nav-item", attributes: { role: "presentation" } do
|
25
|
-
# '<a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="true">Home</a>'
|
26
|
-
link class: "nav-link #{'active' if item[:active]}",
|
27
|
-
id: "tab-#{item[:id]}",
|
28
|
-
path: "#tab-#{item[:id]}-content",
|
29
|
-
attributes: {
|
30
|
-
role: "tab",
|
31
|
-
"aria-controls": "tab-#{item[:id]}",
|
32
|
-
"aria-selected": "#{'true' if item[:active]}",
|
33
|
-
"data-bs-toggle": "tab"
|
34
|
-
} do
|
35
|
-
bs_icon name: item[:icon], size: 20 if item[:icon]
|
36
|
-
span class: "#{'ps-3' if item[:icon]}", text: item[:text] if item[:text]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def link_attrs path, active, disabled, delay=nil
|
43
|
-
{}.tap do |hash|
|
44
|
-
hash[:class] = "nav-link #{'active' if path == request.fullpath } #{'disabled' if disabled}"
|
45
|
-
|
46
|
-
hash[:attributes] = {}.tap do |hash|
|
47
|
-
hash[:'aria-selected'] = path == request.fullpath ? 'true' : 'false'
|
48
|
-
hash[:'aria-current'] = 'page' if active == true
|
49
|
-
hash[:'aria-disabled'] = 'true' if disabled
|
50
|
-
hash[:role] = "tab" if toggle.present?
|
51
|
-
hash[:'aria-controls'] = "#{path.gsub('#','')}" if toggle.present?
|
52
|
-
end
|
53
|
-
|
54
|
-
hash[:data] = { "bs-toggle": "pill" } if pills
|
55
|
-
hash[:data] = { "bs-toggle": "tab" } if tabs
|
56
|
-
hash[:path] = path
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def nav_attributes
|
61
|
-
html_attributes.merge(
|
62
|
-
id: id,
|
63
|
-
class: nav_classes,
|
64
|
-
attributes: { role: "tablist"}
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
|
-
def nav_classes
|
69
|
-
[].tap do |classes|
|
70
|
-
classes << 'nav'
|
71
|
-
classes << 'nav-tabs' if variant == :tabs || variant.nil?
|
72
|
-
classes << 'nav-pills' if variant == :pills
|
73
|
-
classes << 'nav-fill' if fill
|
74
|
-
classes << 'nav-justified' if justified
|
75
|
-
classes << 'flex-column' if vertical
|
76
|
-
classes << 'flex-column flex-sm-column flex-md-row' if vertical_up_to_sm
|
77
|
-
classes << 'flex-column flex-sm-column flex-md-column flex-lg-row' if vertical_up_to_md
|
78
|
-
classes << 'flex-column flex-sm-column flex-md-column flex-lg-column flex-xl-row' if vertical_up_to_xl
|
79
|
-
classes << "justify-content-#{horizontal}" if horizontal.present?
|
80
|
-
classes << bs_class
|
81
|
-
end.join(' ').strip
|
82
|
-
end
|
83
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::TabNavContent < Matestack::Ui::Component
|
2
|
-
|
3
|
-
requires :id
|
4
|
-
|
5
|
-
optional :tabs, :pills, :active, class: { as: :bs_class }, attributes: { as: :bs_attrs}
|
6
|
-
|
7
|
-
def response
|
8
|
-
div tab_content_attributes do
|
9
|
-
yield_components
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
|
15
|
-
def tab_content_attributes
|
16
|
-
html_attributes.merge(
|
17
|
-
id: "tab-#{id}-content",
|
18
|
-
class: tab_content_classes,
|
19
|
-
attributes: { role: "tabpanel", "aria-labelledby": "tab-#{id}" }
|
20
|
-
)
|
21
|
-
end
|
22
|
-
|
23
|
-
def tab_content_classes
|
24
|
-
[].tap do |classes|
|
25
|
-
classes << 'tab-pane'
|
26
|
-
classes << 'fade'
|
27
|
-
classes << 'show ' if active
|
28
|
-
classes << 'active' if active
|
29
|
-
classes << bs_class
|
30
|
-
end.join(' ').strip
|
31
|
-
end
|
32
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Components::Toast < Matestack::Ui::VueJsComponent
|
2
|
-
vue_js_component_name "matestack-ui-bootstrap-toast"
|
3
|
-
|
4
|
-
# header attributes, expects a hash or string
|
5
|
-
# possible keys `:icon_class, :icon, :title, :subtitle`
|
6
|
-
optional :header
|
7
|
-
# body expects a string as message inside toast
|
8
|
-
optional :body
|
9
|
-
# placement attributes, expects a hash wiht possible keys: position, min-height
|
10
|
-
optional :placement # for adding custom css style
|
11
|
-
optional :important, :delay, :autohide, :animation
|
12
|
-
optional class: { as: :bs_class }, attributes: { as: :bs_attrs }, data: { as: :bs_data }
|
13
|
-
optional :slots
|
14
|
-
|
15
|
-
def response
|
16
|
-
standard_placement_partial
|
17
|
-
# standard_placement_partial unless placement.present?
|
18
|
-
# custom_placement_partial if placement.present?
|
19
|
-
end
|
20
|
-
|
21
|
-
protected
|
22
|
-
|
23
|
-
def custom_placement_partial
|
24
|
-
div attributes: placement_attrs do
|
25
|
-
standard_placement_partial
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def standard_placement_partial
|
30
|
-
div toast_attributes do
|
31
|
-
header_partial if header || slots && slots[:header]
|
32
|
-
body_partial
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def header_partial
|
37
|
-
header = self.header.is_a?(Hash) ? self.header : { title: self.header }
|
38
|
-
div class: "toast-header" do
|
39
|
-
img class: "#{'rounded me-2' || header[:icon_class]}", path: header[:icon] if header[:icon].present?
|
40
|
-
strong class: "me-auto", text: header[:title] if header[:title].present?
|
41
|
-
small text: header[:subtitle] if header[:subtitle].present?
|
42
|
-
|
43
|
-
slot slots[:header] if slots && slots[:header]
|
44
|
-
bs_close dismiss: 'toast', class: "ms-2 mb-1", attributes: { "@click": "hide()"}
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def body_partial
|
50
|
-
div class: "toast-body" do
|
51
|
-
plain body if body
|
52
|
-
end
|
53
|
-
unless header || slots && slots[:header]
|
54
|
-
bs_close dismiss: 'toast', class: "ms-auto me-2 btn-close-white", attributes: { "@click": "hide()"}
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def toast_attributes
|
59
|
-
html_attributes.merge(
|
60
|
-
class: toast_classes,
|
61
|
-
attributes: toast_attrs,
|
62
|
-
data: toast_data
|
63
|
-
)
|
64
|
-
end
|
65
|
-
|
66
|
-
def toast_data
|
67
|
-
(bs_data || {}).tap do |hash|
|
68
|
-
hash["bs-delay"] = delay.nil? ? 5000 : delay
|
69
|
-
hash["bs-autohide"] = autohide.nil? ? "true" : "#{autohide}"
|
70
|
-
hash["bs-animation"] = animation.nil? ? "true" : "#{animation}"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def toast_attrs
|
75
|
-
(bs_attrs || {}).tap do |hash|
|
76
|
-
hash[:role] = (important == false ? 'status' : 'alert')
|
77
|
-
hash[:'aria-live'] = (important ? 'assertive' : 'polite') if important.present? && !placement.present?
|
78
|
-
hash[:'aria-live'] = 'assertive' unless important.present?
|
79
|
-
hash[:'aria-atomic'] = 'true' unless placement.present?
|
80
|
-
hash[:style] = "z-index: 10000; position: fixed; #{placement[:position] || 'top: 0; right: 0;' }" if placement.present?
|
81
|
-
hash["v-bind:class"] = "{'show' : showing }"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def toast_classes
|
86
|
-
[].tap do |classes|
|
87
|
-
classes << 'toast p-0 fade d-flex align-items-center border-0'
|
88
|
-
classes << bs_class
|
89
|
-
end.join(' ').strip
|
90
|
-
end
|
91
|
-
|
92
|
-
def placement_attrs
|
93
|
-
{}.tap do |hash|
|
94
|
-
hash[:'aria-live'] = (important ? 'assertive' : 'polite') if important.present?
|
95
|
-
hash[:'aria-atomic'] = 'true'
|
96
|
-
hash[:style] = "position: relative; min-height: #{placement[:height]};"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Form::Checkbox < Matestack::Ui::Core::Form::Checkbox::Base
|
2
|
-
|
3
|
-
vue_js_component_name "matestack-ui-core-form-checkbox"
|
4
|
-
|
5
|
-
optional :form_text
|
6
|
-
optional :disabled
|
7
|
-
optional :variant
|
8
|
-
|
9
|
-
def response
|
10
|
-
div class: "matestack-ui-bootstrap-form-checkbox" do
|
11
|
-
label class: "form-label", text: input_label, for: attr_key if input_label && multiple?
|
12
|
-
render_options
|
13
|
-
render_errors
|
14
|
-
render_form_text unless form_text.nil? # otherwise renders empty div
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def multiple?
|
21
|
-
options[:options].present?
|
22
|
-
end
|
23
|
-
|
24
|
-
def render_options
|
25
|
-
# multiple
|
26
|
-
if multiple?
|
27
|
-
options[:options].to_a.each do |item|
|
28
|
-
checkbox_wrapper do
|
29
|
-
input html_attributes.merge(
|
30
|
-
attributes: vue_attributes,
|
31
|
-
type: :checkbox,
|
32
|
-
id: "#{id_for_item(item_value(item))}",
|
33
|
-
name: item_name(item),
|
34
|
-
value: item_value(item),
|
35
|
-
class: 'form-check-input'
|
36
|
-
)
|
37
|
-
bootstrap_label text: item_name(item), for_input: id_for_item(item_value(item))
|
38
|
-
end
|
39
|
-
end
|
40
|
-
# checked/unchecked checkbox (true/false checkbox)
|
41
|
-
else
|
42
|
-
checkbox_wrapper do
|
43
|
-
input html_attributes.merge(
|
44
|
-
attributes: vue_attributes_for_single_input,
|
45
|
-
type: :hidden,
|
46
|
-
value: (false_value || 0),
|
47
|
-
class: 'form-check-input'
|
48
|
-
)
|
49
|
-
|
50
|
-
input html_attributes.merge(
|
51
|
-
attributes: vue_attributes_for_single_input,
|
52
|
-
type: :checkbox,
|
53
|
-
id: id_for_item(value),
|
54
|
-
value: checked_value,
|
55
|
-
class: 'form-check-input'
|
56
|
-
)
|
57
|
-
|
58
|
-
bootstrap_label text: input_label, for_input: id_for_item(value)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def checkbox_wrapper(options = {}, &block)
|
64
|
-
div class: "form-check #{'form-check-inline' if variant == :inline}", attributes: options[:attributes] do
|
65
|
-
yield
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def bootstrap_label(text:, for_input:)
|
70
|
-
label text: text, for: for_input, class: 'form-check-label'
|
71
|
-
end
|
72
|
-
|
73
|
-
def render_errors
|
74
|
-
unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
|
75
|
-
div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}", style: "display: block;" } do
|
76
|
-
plain '{{ error }}'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def input_error_class
|
82
|
-
'is-invalid'
|
83
|
-
end
|
84
|
-
|
85
|
-
def checkbox_options
|
86
|
-
super || {}
|
87
|
-
end
|
88
|
-
|
89
|
-
def render_form_text
|
90
|
-
div id: "form_text_for_#{attr_key}", class: "form-text" do
|
91
|
-
plain form_text
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def id_for_item(value)
|
96
|
-
"#{html_attributes[:id]}_#{value}_#{attr_key}"
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
class Matestack::Ui::Bootstrap::Form::Input < Matestack::Ui::Core::Form::Input::Base
|
2
|
-
|
3
|
-
vue_js_component_name "matestack-ui-core-form-input"
|
4
|
-
|
5
|
-
optional :form_text
|
6
|
-
optional :disabled
|
7
|
-
optional :browse_button_text
|
8
|
-
optional :placeholder
|
9
|
-
optional :variant
|
10
|
-
optional :min
|
11
|
-
optional :max
|
12
|
-
optional :step
|
13
|
-
optional :show_value
|
14
|
-
|
15
|
-
def response
|
16
|
-
div class: "matestack-ui-bootstrap-input" do
|
17
|
-
label for: attr_key, class: "form-label", text: input_label if input_label
|
18
|
-
case type
|
19
|
-
when :range
|
20
|
-
input html_attributes.merge(attributes: vue_attributes).merge(bootstrap_range_attributes)
|
21
|
-
if show_value
|
22
|
-
div id: attr_key, class: "form-text" do
|
23
|
-
plain "{{ data['#{attr_key}'] }}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
when :file
|
27
|
-
file_input
|
28
|
-
else
|
29
|
-
input html_attributes.merge(attributes: vue_attributes).merge(bootstrap_input_attributes)
|
30
|
-
render_errors
|
31
|
-
end
|
32
|
-
render_form_text if form_text
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def bootstrap_input_attributes
|
37
|
-
{
|
38
|
-
id: (options[:id] || attr_key),
|
39
|
-
class: (options[:class] || "") << (" form-control"),
|
40
|
-
disabled: disabled
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
def bootstrap_range_attributes
|
45
|
-
{
|
46
|
-
class: (options[:class] || "") << (" form-range"),
|
47
|
-
disabled: disabled,
|
48
|
-
min: min,
|
49
|
-
max: max,
|
50
|
-
steps: step
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def bootstrap_file_input_attributes
|
55
|
-
{
|
56
|
-
class: (options[:class] || "") << (" form-file-input"),
|
57
|
-
disabled: disabled
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
def form_file_wrapper_class
|
62
|
-
case variant
|
63
|
-
when :lg
|
64
|
-
(options[:class] || "") << (" form-file form-file-lg")
|
65
|
-
when :sm
|
66
|
-
(options[:class] || "") << (" form-file form-file-sm")
|
67
|
-
else
|
68
|
-
(options[:class] || "") << (" form-file")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def file_input
|
73
|
-
div class: form_file_wrapper_class do
|
74
|
-
input html_attributes.merge(attributes: vue_attributes).merge(bootstrap_file_input_attributes)
|
75
|
-
label class: "form-file-label", for: attr_key do
|
76
|
-
span class: "form-file-text", attributes: { "v-if": "data['#{attr_key}']" } do
|
77
|
-
if multiple
|
78
|
-
span attributes: { "v-for": "file in data['#{attr_key}']" } do
|
79
|
-
plain "{{ file['name'] }}"
|
80
|
-
end
|
81
|
-
else
|
82
|
-
plain "{{ data['#{attr_key}']['name'] }}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
span class: "form-file-text", attributes: { "v-if": "!data['#{attr_key}']" } do
|
86
|
-
plain placeholder || "Choose file"
|
87
|
-
end
|
88
|
-
span class: "form-file-button", text: browse_button_text || "Browse"
|
89
|
-
end
|
90
|
-
render_errors
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def render_errors
|
95
|
-
unless @included_config[:errors] == false && (errors == false || errors.nil?) || errors == false
|
96
|
-
div class: 'invalid-feedback', attributes: { 'v-for': "error in #{error_key}" } do
|
97
|
-
plain '{{ error }}'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def input_error_class
|
103
|
-
'is-invalid'
|
104
|
-
end
|
105
|
-
|
106
|
-
def render_form_text
|
107
|
-
div id: "form_text_for_#{attr_key}", class: "form-text" do
|
108
|
-
plain form_text
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|