Skip to content

Commit 8b91677

Browse files
committed
fixed all bugs due to 2.0 migration
1 parent 7c56f8e commit 8b91677

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+452
-435
lines changed

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: https://github.com/matestack/matestack-ui-core
3-
revision: 0bbd207c34dea89cc0056e4de563141ceb8aa284
3+
revision: fc89a8a8dd61b88a764aac41d90b228951d28288
44
branch: matestack-ui-core-2.0
55
specs:
66
matestack-ui-core (2.0.0)
@@ -124,10 +124,10 @@ GEM
124124
mimemagic (0.3.5)
125125
mini_mime (1.0.2)
126126
mini_portile2 (2.5.0)
127-
minitest (5.14.3)
127+
minitest (5.14.4)
128128
msgpack (1.4.2)
129-
nio4r (2.5.5)
130-
nokogiri (1.11.1)
129+
nio4r (2.5.7)
130+
nokogiri (1.11.2)
131131
mini_portile2 (~> 2.5.0)
132132
racc (~> 1.4)
133133
orm_adapter (0.5.0)

app/concepts/matestack/ui/bootstrap/apps/admin_template.rb

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
11
class Matestack::Ui::Bootstrap::Apps::AdminTemplate < Matestack::Ui::App
22

3-
def response
4-
html do
5-
head do
6-
title "Matestack UI Addon Dummy App"
7-
8-
unescape csrf_meta_tags
9-
# unescape csp_meta_tag
10-
11-
meta charset: "utf-8"
12-
meta name: "viewport", content: "width=device-width, initial-scale=1"
13-
14-
# unescape stylesheet_pack_tag("application", media: "all")
15-
unescape javascript_pack_tag("application")
16-
# unescape Matestack::Ui::Core::Context.controller.view_context.stylesheet_pack_tag(:application)
17-
# unescape Matestack::Ui::Core::Context.controller.view_context.javascript_pack_tag(:application)
18-
end
19-
end
20-
body do
21-
matestack do
22-
body_response do
23-
yield
24-
end
25-
end
3+
def response(&block)
4+
matestack do
5+
body_response(&block)
266
end
277
end
288

29-
def body_response
9+
def body_response(&block)
3010
div class: "d-flex flex-row" do
3111
if should_show_sidebar?
3212
bs_sidebar sidebar_navigation_items: sidebar_navigation_items, slots: { sidebar_top: method(:sidebar_top_slot) }

app/concepts/matestack/ui/bootstrap/components/accordion.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ class Matestack::Ui::Bootstrap::Components::Accordion < Matestack::Ui::Bootstrap
44
optional :items # array with 2 Hashes: header and body
55
optional :open
66
optional :variant
7-
optional :attributes, :class, :id
7+
optional :attributes, class: { as: :bs_class }
8+
optional :id
89

910
def prepare
1011
@accordion_id = (context.id.present? ? context.id : "matestack-accordion-#{SecureRandom.hex(3)}")
@@ -49,7 +50,7 @@ def accordion_classes
4950
classes << 'accordion'
5051
classes << 'open' if context.open
5152
classes << 'accordion-flush' if context.variant == :flush
52-
classes << context.class
53+
classes << context.bs_class
5354
end.join(' ').strip
5455
end
5556
end

app/concepts/matestack/ui/bootstrap/components/alert.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class Matestack::Ui::Bootstrap::Components::Alert < Matestack::Ui::Bootstrap::BaseVueJsComponent
22
vue_name "matestack-ui-bootstrap-alert"
33

4-
optional :title, :text, :variant, :dismissible, :animate, :title_size, :class
4+
optional :title, :text, :variant, :dismissible, :animate, :title_size, class: { as: :bs_class }
55
optional :close_on, :dispose_on # event names on which occourences we close or dispose the modal
66

77
def response
88
div alert_attributes do
9-
heading context.title, size: (title_size || 4), class: 'alert-heading' if context.title
9+
heading context.title, size: (context.title_size || 4), class: 'alert-heading' if context.title
1010
plain context.text if context.text
1111
yield if block_given?
1212
bs_close dismiss: "alert" if context.dismissible
@@ -15,12 +15,19 @@ def response
1515

1616
protected
1717

18+
def config
19+
{}.tap do |props|
20+
props[:close_on] = context.close_on
21+
props[:dispose_on] = context.dispose_on
22+
end
23+
end
24+
1825
def alert_classes
1926
classes = ['alert']
2027
classes << "alert-#{context.variant || "primary"}"
2128
classes << "alert-dismissible" if context.dismissible
2229
classes << "fade show" if context.animate
23-
classes << context.class
30+
classes << context.bs_class
2431
classes.join(' ')
2532
end
2633

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
class Matestack::Ui::Bootstrap::Components::Avatar < Matestack::Ui::Bootstrap::BaseComponent
22

3-
optional :text, :bg_variant, :text_variant, :img_path, :size, :class
3+
optional :text, :bg_variant, :text_variant, :img_path, :size, class: { as: :bs_class }
44

55
def response
66
if context.text.present? && context.img_path.nil?
7-
div class: "rounded-circle bg-#{context.bg_variant || 'primary'} text-#{context.text_variant || 'white'} text-center p-2 #{context.class}",
7+
div class: "rounded-circle bg-#{context.bg_variant || 'primary'} text-#{context.text_variant || 'white'} text-center p-2 #{context.bs_class}",
88
style: "height: #{height}px; width: #{width}px; display: inline-block;" do
99
plain context.text
1010
end
1111
else
12-
div class: "rounded-circle text-#{context.text_variant || 'white'} text-center p-2 #{context.class}",
12+
div class: "rounded-circle text-#{context.text_variant || 'white'} text-center p-2 #{context.bs_class}",
1313
style: "height: #{height}px; width: #{width}px; display: inline-block; background-image: url(#{context.img_path}); background-size: contain;" do
1414
plain context.text
1515
end
1616
end
1717
end
1818

1919
def height
20-
size || 40
20+
context.size || 40
2121
end
2222

2323
def width
24-
size || 40
24+
context.size || 40
2525
end
2626

2727
end

app/concepts/matestack/ui/bootstrap/components/badge.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Matestack::Ui::Bootstrap::Components::Badge < Matestack::Ui::Bootstrap::BaseComponent
22

3-
optional :class
3+
optional class: { as: :bs_class }
44
optional :text, :variant, :rounded, :visually_hidden
55

66
def response
@@ -24,7 +24,7 @@ def badge_classes
2424
classes << 'badge'
2525
classes << (context.variant.present? ? "bg-#{context.variant}" : "bg-secondary")
2626
classes << "rounded-pill" if context.rounded
27-
classes << context.class
27+
classes << context.bs_class
2828
end.join(' ').strip
2929
end
3030
end

app/concepts/matestack/ui/bootstrap/components/breadcrumb.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Matestack::Ui::Bootstrap::Components::Breadcrumb < Matestack::Ui::Bootstrap::BaseComponent
22

33
optional :items # list of items with path and text
4-
optional :class # adding custom class to breadcrumb list
4+
optional class: { as: :bs_class } # adding custom class to breadcrumb list
55
optional :nav_class
66

77
def response
@@ -11,7 +11,7 @@ def response
1111
li link_attrs((context.items.size - 1) == index) do
1212
case item[:type]
1313
when :link
14-
link item
14+
a item
1515
when :transition
1616
transition item
1717
else
@@ -42,7 +42,7 @@ def breadcrumb_attributes
4242
def breadcrumb_classes
4343
[].tap do |classes|
4444
classes << "breadcrumb"
45-
classes << context.class
45+
classes << context.bs_class
4646
end.join(' ').strip
4747
end
4848
end

app/concepts/matestack/ui/bootstrap/components/button.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
class Matestack::Ui::Bootstrap::Components::Button < Matestack::Ui::Bootstrap::BaseComponent
22

33
optional :text, :type, :variant, :size, :outline
4-
optional :attributes, :class
4+
optional :attributes, class: { as: :bs_class }
55
optional :transition
66
optional :action
77
optional :onclick
88
optional :link
99

10-
def response
10+
def response(&block)
1111
if context.transition.present? && context.transition.is_a?(Hash)
1212
transition button_attributes.merge(context.transition.merge({role: "button"})) do
13-
inner_response
13+
inner_response(&block)
1414
end
1515
elsif context.action.present? && context.action.is_a?(Hash)
1616
action button_attributes.merge(context.action.merge({role: "button"})) do
17-
inner_response
17+
inner_response(&block)
1818
end
1919
elsif context.onclick.present? && context.onclick.is_a?(Hash)
2020
onclick button_attributes.merge(context.onclick.merge({role: "button"})) do
21-
inner_response
21+
inner_response(&block)
2222
end
2323
elsif context.link.present? && context.link.is_a?(Hash)
24-
link button_attributes.merge(context.link.merge({role: "button"})) do
25-
inner_response
24+
a button_attributes.merge(context.link.merge({role: "button"})) do
25+
inner_response(&block)
2626
end
2727
else
28-
button_response
28+
button_response(&block)
2929
end
3030
end
3131

32-
def button_response
32+
def button_response(&block)
3333
button button_attributes do
34-
inner_response
34+
inner_response(&block)
3535
end
3636
end
3737

38-
def inner_response
39-
plain text if text
38+
def inner_response(&block)
39+
plain context.text if context.text
4040
yield if block_given?
4141
end
4242

@@ -62,7 +62,7 @@ def button_classes
6262
# btn size
6363
classes << "btn-#{context.size}" if context.size
6464
# custom classes
65-
classes << context.class
65+
classes << context.bs_class
6666
end.join(' ').strip
6767
end
6868

app/concepts/matestack/ui/bootstrap/components/button_group.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Matestack::Ui::Bootstrap::Components::ButtonGroup < Matestack::Ui::Bootstrap::BaseComponent
22

3-
optional :class
3+
optional class: { as: :bs_class }
44
optional :label
55
optional :toolbar, :size, :vertical
66

@@ -16,7 +16,7 @@ def buttongroup_attributes
1616
attributes = {}.tap do |hash|
1717
hash[:class] = buttongroup_classes
1818
hash[:role] = "#{context.toolbar ? :toolbar : :group}"
19-
hash[:"aria-label"] = 'aria-label': context.label
19+
hash[:"aria-label"] = context.label
2020
end
2121
options.merge(
2222
attributes
@@ -27,7 +27,7 @@ def buttongroup_classes
2727
[].tap do |classes|
2828
classes << ("btn-#{context.toolbar ? :toolbar : :group}#{'-vertical' if context.vertical}")
2929
classes << "btn-group-#{context.size}" if context.size.present?
30-
classes << context.class
30+
classes << context.bs_class
3131
end.join(' ').strip
3232
end
3333

app/concepts/matestack/ui/bootstrap/components/card.rb

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Matestack::Ui::Bootstrap::Components::Card < Matestack::Ui::Bootstrap::BaseComponent
22

3-
optional :class
3+
optional class: { as: :bs_class }
44

55
# header attributes, expects a hash or string
66
# possible keys `:class, :text`
@@ -14,25 +14,23 @@ class Matestack::Ui::Bootstrap::Components::Card < Matestack::Ui::Bootstrap::Bas
1414

1515
optional :content_wrapper_class # class for content wrapper -> useful for content padding without affecting top image
1616

17-
optional :slots # passed in slots for card header or footer
18-
1917
def response
2018
div card_attributes do
21-
if context.header || context.slots && context.slots[:header]
19+
if context.header || slots && slots[:header]
2220
header_partial
2321
end
2422

2523
img_partial :top unless context.img_pos == :bottom
2624
div class: context.content_wrapper_class do
27-
body_partial if context.title || context.body || context.slots && context.slots[:body]
25+
body_partial if context.title || context.body || slots && slots[:body]
2826

2927
# custom body components
3028
# needed a div otherwise it will be displayed below footer
3129
div class: "p-3 pt-1" do yield if block_given? end
3230

3331
img_partial :bottom if context.img_pos == :bottom
3432

35-
footer_partial if context.footer || context.slots && context.slots[:footer]
33+
footer_partial if context.footer || slots && slots[:footer]
3634
end
3735
end
3836
end
@@ -41,9 +39,9 @@ def response
4139

4240
def header_partial
4341
header = self.context.header.is_a?(Hash) ? self.context.header : { text: self.context.header }
44-
div class: "card-header #{context.header[:class]}" do
45-
plain context.header[:text] if context.header[:text].present?
46-
slot context.slots[:header] if context.slots && context.slots[:header]
42+
div class: "card-header #{header[:class]}" do
43+
plain header[:text] if header[:text].present?
44+
slot :header if slots && slots[:header]
4745
end
4846
end
4947

@@ -60,18 +58,18 @@ def body_partial
6058
end
6159
elsif context.body
6260
paragraph class: "card-text" do
63-
plain body
61+
plain context.body
6462
end
6563
end
66-
slot context.slots[:body] if context.slots && context.slots[:body]
64+
slot :body if slots && slots[:body]
6765
end
6866
end
6967

7068
def footer_partial
7169
footer = self.context.footer.is_a?(Hash) ? self.context.footer : { text: self.context.footer }
72-
div class: "card-footer #{context.footer[:class]}" do
73-
plain context.footer[:text] if context.footer[:text].present?
74-
slot context.slots[:footer] if context.slots && context.slots[:footer]
70+
div class: "card-footer #{footer[:class]}" do
71+
plain footer[:text] if footer[:text].present?
72+
slot :footer if slots && slots[:footer]
7573
end
7674
end
7775

@@ -88,14 +86,13 @@ def card_attributes
8886
def card_classes
8987
[].tap do |classes|
9088
classes << 'card'
91-
classes << context.class
89+
classes << context.bs_class
9290
end.join(' ').strip
9391
end
9492

9593
def card_title(options, default_size = 5, title_class)
9694
if options.is_a? Hash
97-
heading size: (context.size || default_size), class: "#{context.class} #{title_class}",
98-
plain context.text
95+
heading context.text, size: (context.size || default_size), class: "#{context.bs_class} #{title_class}"
9996
elsif options
10097
heading size: default_size, class: title_class do
10198
plain options

0 commit comments

Comments
 (0)