ui_bibz 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/app/assets/javascripts/form.coffee +1 -5
  4. data/app/assets/javascripts/interface.coffee +8 -0
  5. data/app/assets/javascripts/ui_bibz.coffee.erb +1 -1
  6. data/app/assets/stylesheets/forms.sass +5 -0
  7. data/app/assets/stylesheets/notifications.sass +8 -1
  8. data/config/initializers/will_paginate.rb +1 -1
  9. data/lib/ui_bibz/helpers/ui/core/boxes_helper.rb +9 -0
  10. data/lib/ui_bibz/helpers/ui/core/notifications_helper.rb +17 -0
  11. data/lib/ui_bibz/infos.rb +2 -2
  12. data/lib/ui_bibz/ui/base.rb +1 -1
  13. data/lib/ui_bibz/ui/core/boxes/card.rb +2 -0
  14. data/lib/ui_bibz/ui/core/boxes/card_accordion.rb +65 -0
  15. data/lib/ui_bibz/ui/core/boxes/components/card_body.rb +12 -1
  16. data/lib/ui_bibz/ui/core/component.rb +12 -4
  17. data/lib/ui_bibz/ui/core/forms/buttons/button.rb +14 -4
  18. data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +0 -1
  19. data/lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb +4 -2
  20. data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +9 -12
  21. data/lib/ui_bibz/ui/core/forms/selects/select_field.rb +7 -14
  22. data/lib/ui_bibz/ui/core/navigations/link.rb +12 -0
  23. data/lib/ui_bibz/ui/core/notifications/components/toast_body.rb +50 -0
  24. data/lib/ui_bibz/ui/core/notifications/components/toast_header.rb +62 -0
  25. data/lib/ui_bibz/ui/core/notifications/spinner.rb +89 -0
  26. data/lib/ui_bibz/ui/core/notifications/toast.rb +97 -0
  27. data/lib/ui_bibz/ui/extensions/core/component/popover_extension.rb +16 -5
  28. data/lib/ui_bibz.rb +3 -0
  29. data/test/simple_form_test.rb +7 -7
  30. data/test/ui/core/component_test.rb +1 -0
  31. data/test/ui/core/forms/buttons/button_group_test.rb +3 -3
  32. data/test/ui/core/forms/buttons/button_test.rb +44 -9
  33. data/test/ui/core/forms/choices/checkbox_field_test.rb +1 -1
  34. data/test/ui/core/forms/selects/dropdown_select_field_test.rb +10 -10
  35. data/test/ui/core/forms/selects/select_field_test.rb +2 -2
  36. data/test/ui/core/forms/surrounds/surround_field_test.rb +2 -2
  37. data/test/ui/core/navigations/link_test.rb +26 -0
  38. data/test/ui/core/navigations/navbar_test.rb +1 -1
  39. data/test/ui/core/navigations/toolbar_test.rb +2 -2
  40. data/test/ui/core/notifications/spinner_test.rb +33 -0
  41. data/test/ui/core/notifications/toast_test.rb +15 -0
  42. data/test/ui/ux/containers/panel_test.rb +4 -4
  43. data/ui_bibz.gemspec +1 -1
  44. data/vendor/assets/javascripts/bootstrap-select.js.map +1 -1
  45. data/vendor/assets/javascripts/bootstrap-select.min.js +3 -3
  46. data/vendor/assets/stylesheets/bootstrap-select.css.map +1 -1
  47. data/vendor/assets/stylesheets/bootstrap-select.min.css +3 -3
  48. metadata +19 -8
@@ -0,0 +1,89 @@
1
+ module UiBibz::Ui::Core::Notifications
2
+
3
+ # Create a spinner
4
+ #
5
+ # This element is an extend of UiBibz::Ui::Core::Component.
6
+ #
7
+ # ==== Attributes
8
+ #
9
+ # * +content+ - Content of element
10
+ # * +options+ - Options of element
11
+ # * +html_options+ - Html Options of element
12
+ #
13
+ # ==== Options
14
+ #
15
+ # You can add HTML attributes using the +html_options+.
16
+ # You can pass arguments in options attribute:
17
+ # * +status+ - status of élement with symbol value:
18
+ # (+:primary+, +:secondary+, +:success+, +:danger+, +:warning+, +:info+, +:light+, +:dark+)
19
+ # * +size+
20
+ # (+:xs+, +:sm+, +:lg+)
21
+ # * +type+
22
+ # (+:border+, +:grow+)
23
+ #
24
+ # ==== Signatures
25
+ #
26
+ # UiBibz::Ui::Core::Notifications::Spinner.new(content, options = nil, html_options = nil)
27
+ #
28
+ # UiBibz::Ui::Core::Notifications::Spinner.new(options = nil, html_options = nil) do
29
+ # content
30
+ # end
31
+ #
32
+ # ==== Examples
33
+ #
34
+ # UiBibz::Ui::Core::Notifications::Spinner.new(content, status: :success, type: :pill).render
35
+ #
36
+ # UiBibz::Ui::Core::Notifications::Spinner.new() do
37
+ # #content
38
+ # end.render
39
+ #
40
+ # ==== Helper
41
+ #
42
+ # ui_spinner(content, options = {}, html_options = {})
43
+ #
44
+ # ui_spinner(options = {}, html_options = {}) do
45
+ # content
46
+ # end
47
+ #
48
+ class Spinner < UiBibz::Ui::Core::Component
49
+
50
+ # See UiBibz::Ui::Core::Component.initialize
51
+ def initialize content = nil, options = nil, html_options = nil, &block
52
+ super
53
+ end
54
+
55
+ # Render html tag
56
+ def pre_render
57
+ content_tag tag_html, html_options do
58
+ content_tag :span, @content || "Loading...", class: "sr-only"
59
+ end
60
+ end
61
+
62
+ private
63
+
64
+ def component_html_options
65
+ super.merge({ role: "status" })
66
+ end
67
+
68
+ def component_html_classes
69
+ ["spinner-#{ type }", status, size]
70
+ end
71
+
72
+ def status
73
+ "text-#{ @options[:status] || :secondary }" if options[:status]
74
+ end
75
+
76
+ def type
77
+ @options[:type] || "border"
78
+ end
79
+
80
+ def size
81
+ "spinner-#{ type }-#{ options[:size] }" if options[:size]
82
+ end
83
+
84
+ def tag_html
85
+ options[:tag] || :div
86
+ end
87
+
88
+ end
89
+ end
@@ -0,0 +1,97 @@
1
+ require 'ui_bibz/ui/core/notifications/components/toast_header'
2
+ require 'ui_bibz/ui/core/notifications/components/toast_body'
3
+ module UiBibz::Ui::Core::Notifications
4
+
5
+ # Create an alert
6
+ #
7
+ # This element is an extend of UiBibz::Ui::Core::Component.
8
+ #
9
+ # ==== Attributes
10
+ #
11
+ # * +content+ - Content of element
12
+ # * +options+ - Options of element
13
+ # * +html_options+ - Html Options of element
14
+ #
15
+ # ==== Options
16
+ #
17
+ # You can add HTML attributes using the +html_options+.
18
+ # You can pass arguments in options attribute:
19
+ # * +status+ - status of élement with symbol value:
20
+ # (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
21
+ # * +glyph+ - [String | Hash] Add glyph with name or hash options
22
+ # * +name+ - [String]
23
+ # *+timeout+ - [Integer]
24
+ #
25
+ # ==== Signatures
26
+ #
27
+ # UiBibz::Ui::Core::Toast.new(content, options = nil, html_options = nil)
28
+ #
29
+ # UiBibz::Ui::Core::Toast.new(options = nil, html_options = nil) do
30
+ # content
31
+ # end
32
+ #
33
+ # ==== Examples
34
+ #
35
+ # UiBibz::Ui::Core::Toast.new(class: 'my-toast').tap |t|
36
+ # t.header "My header toast", glyph: 'eye', time: 'now'
37
+ # t.body "My body toast"
38
+ # end
39
+ #
40
+ # UiBibz::Ui::Core::Toast.new(class: 'my-toast').tap |t|
41
+ # t.header glyph: 'eye', time: 'now' do
42
+ # My header toast
43
+ # end
44
+ # t.body class: 'my-body-toast' do
45
+ # My body toast
46
+ # end
47
+ # end.render
48
+ #
49
+ # ==== Helper
50
+ #
51
+ # ui_toast(options = { tap: true }, html_options = {}) do |t|
52
+ # t.header "My header toast", glyph: 'eye', time: 'now'
53
+ # t.body "My body toast"
54
+ # end
55
+ #
56
+ class Toast < UiBibz::Ui::Core::Component
57
+
58
+ # See UiBibz::Ui::Core::Component.initialize
59
+ def initialize content = nil, options = nil, html_options = nil, &block
60
+ super
61
+ end
62
+
63
+ # Render html tag
64
+ def pre_render
65
+ content_tag :div, html_options do
66
+ concat @header
67
+ concat @body
68
+ end
69
+ end
70
+
71
+ # Add Header which is a component
72
+ def header content = nil, options = nil, html_options = nil, &block
73
+ @header = UiBibz::Ui::Core::Notifications::Components::ToastHeader.new(content, options, html_options, &block).render
74
+ end
75
+
76
+ # Add Body which is a component
77
+ def body content = nil, options = nil, html_options = nil, &block
78
+ @body = UiBibz::Ui::Core::Notifications::Components::ToastBody.new(content, options, html_options, &block).render
79
+ end
80
+
81
+ private
82
+
83
+ def component_html_classes
84
+ super << 'toast'
85
+ end
86
+
87
+ def component_html_options
88
+ { role: 'alert', "aria-live": "assertive", "aria-atomic": true }
89
+ end
90
+
91
+ def component_html_data
92
+ super
93
+ add_html_data "autohide", options[:auto_hide] if options[:auto_hide]
94
+ end
95
+
96
+ end
97
+ end
@@ -1,17 +1,28 @@
1
1
  module PopoverExtension
2
2
 
3
+ TOOLTIP_METHODS = %i(animation container delay html placement selector template title trigger
4
+ offset fallback_placement boundary sanitize white_list santitize_fn)
5
+
6
+ POPOVER_METHODS = %i(animation container content delay html placement selector template title
7
+ trigger offset fallback_placement boundary sanitize white_list sanitize_fn)
8
+
3
9
  def popover_data_html
4
10
  unless options[:popover].blank?
5
11
  add_html_data :toggle, "popover"
6
12
  add_html_data :content, (options[:popover].kind_of?(String) ? options[:popover] : options[:popover][:content])
7
13
  end
8
14
  if options[:popover].kind_of?(Hash)
9
- add_html_data :title, options[:popover].try(:[], :title) unless options[:popover].try(:[], :title).nil?
15
+ POPOVER_METHODS.each{ |mth| add_html_data(mth, options[:popover].try(:[], mth)) unless options[:popover].try(:[], mth).nil? }
10
16
  add_html_data :placement, options[:popover].try(:[], :position) unless options[:popover].try(:[], :position).nil?
11
- add_html_data :trigger, options[:popover].try(:[], :trigger) unless options[:popover].try(:[], :trigger).nil?
12
- add_html_data :template, options[:popover].try(:[], :template) unless options[:popover].try(:[], :template).nil?
13
- add_html_data :animation, options[:popover].try(:[], :animation) unless options[:popover].try(:[], :animation).nil?
14
- add_html_data :html, options[:popover].try(:[], :html) unless options[:popover].try(:[], :html).nil?
17
+ end
18
+ end
19
+
20
+ def tooltip_data_html
21
+ add_html_data :toggle, "tooltip" unless options[:tooltip].nil?
22
+
23
+ if options[:tooltip].kind_of?(Hash)
24
+ TOOLTIP_METHODS.each{ |mth| add_html_data(mth, options[:tooltip].try(:[], mth)) unless options[:tooltip].try(:[], mth).nil? }
25
+ add_html_data :placement, options[:tooltip].try(:[], :position) unless options[:tooltip].try(:[], :position).nil?
15
26
  end
16
27
  end
17
28
 
data/lib/ui_bibz.rb CHANGED
@@ -76,6 +76,7 @@ module UiBibz
76
76
 
77
77
  module Boxes
78
78
  autoload :Card, "ui_bibz/ui/core/boxes/card"
79
+ autoload :CardAccordion, "ui_bibz/ui/core/boxes/card_accordion"
79
80
  autoload :CardColumn, "ui_bibz/ui/core/boxes/card_column"
80
81
  autoload :CardDeck, "ui_bibz/ui/core/boxes/card_deck"
81
82
  autoload :CardGroup, "ui_bibz/ui/core/boxes/card_group"
@@ -172,6 +173,8 @@ module UiBibz
172
173
  autoload :Alert, "ui_bibz/ui/core/notifications/alert"
173
174
  autoload :Badge, "ui_bibz/ui/core/notifications/badge"
174
175
  autoload :ProgressBar, "ui_bibz/ui/core/notifications/progress_bar"
176
+ autoload :Spinner, "ui_bibz/ui/core/notifications/spinner"
177
+ autoload :Toast, "ui_bibz/ui/core/notifications/toast"
175
178
  end
176
179
 
177
180
  module Windows
@@ -47,7 +47,7 @@ class SimpleFormTest < ActionView::TestCase
47
47
  f.input :name_fr, as: :ui_dropdown_select_field, collection: @users, label_method: :name_fr
48
48
  end
49
49
 
50
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"dropdown-select-field\"><option value=\"1\">test1</option>
50
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"dropdown-select-field\" data-style=\"btn-secondary\" title=\"false\"><option value=\"1\">test1</option>
51
51
  <option value=\"2\">test2</option></select></div></form>"
52
52
 
53
53
  assert_equal expected, actual
@@ -59,7 +59,7 @@ class SimpleFormTest < ActionView::TestCase
59
59
  f.input :name_fr, as: :ui_dropdown_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
60
60
  end
61
61
 
62
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"dropdown-select-field\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
62
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"dropdown-select-field\" data-style=\"btn-secondary\" title=\"false\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
63
63
  <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
64
64
 
65
65
  assert_equal expected, actual
@@ -159,7 +159,7 @@ test1</textarea></div></form>"
159
159
  f.input :name_fr, as: :ui_select_field, collection: @users, label_method: :name_fr
160
160
  end
161
161
 
162
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control\"><option value=\"1\">test1</option>
162
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control custom-select\"><option value=\"1\">test1</option>
163
163
  <option value=\"2\">test2</option></select></div></form>"
164
164
 
165
165
  assert_equal expected, actual
@@ -170,7 +170,7 @@ test1</textarea></div></form>"
170
170
  f.input :name_fr, as: :ui_select_field, refresh: { target: { data: [] }}, collection: @users, label_method: :name_fr
171
171
  end
172
172
 
173
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><div class=\"field-refresh input-group ui_surround_field\"><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control\"><option value=\"1\">test1</option>
173
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><div class=\"field-refresh input-group ui_surround_field\"><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control custom-select\"><option value=\"1\">test1</option>
174
174
  <option value=\"2\">test2</option></select><div class=\"input-group-btn\"><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#user_name_fr&quot;,&quot;url&quot;:&quot;&quot;,&quot;data&quot;:[]}}\" class=\"btn-secondary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fas fa-sync-alt\"></i> </span></div></div></div></form>"
175
175
 
176
176
  assert_equal expected, actual
@@ -182,7 +182,7 @@ test1</textarea></div></form>"
182
182
  f.input :name_fr, as: :ui_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
183
183
  end
184
184
 
185
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
185
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control custom-select\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
186
186
  <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
187
187
 
188
188
  assert_equal expected, actual
@@ -195,7 +195,7 @@ test1</textarea></div></form>"
195
195
  f.input :name_fr, as: :ui_select_field, collection: @countries
196
196
  end
197
197
 
198
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control\"><option selected=\"selected\" value=\"1\">France</option>
198
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control custom-select\"><option selected=\"selected\" value=\"1\">France</option>
199
199
  <option value=\"2\">Deutchland</option></select></div></form>"
200
200
 
201
201
  assert_equal expected, actual
@@ -208,7 +208,7 @@ test1</textarea></div></form>"
208
208
  f.input :name_fr, as: :ui_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
209
209
  end
210
210
 
211
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control\"><optgroup label=\"Europe\"><option selected=\"selected\" value=\"1\">France</option>
211
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"select-field form-control custom-select\"><optgroup label=\"Europe\"><option selected=\"selected\" value=\"1\">France</option>
212
212
  <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
213
213
 
214
214
  assert_equal expected, actual
@@ -24,4 +24,5 @@ class ComponentTest < ActionView::TestCase
24
24
 
25
25
  assert_equal expected, actual
26
26
  end
27
+
27
28
  end
@@ -7,7 +7,7 @@ class ButtonGroupTest < ActionView::TestCase
7
7
  actual = ui_button_group do |bg|
8
8
  bg.button 'state'
9
9
  end
10
- expected = "<div class=\"btn-group\" role=\"group\"><button class=\"btn\">state</button></div>"
10
+ expected = "<div class=\"btn-group\" role=\"group\"><button class=\"btn-secondary btn\">state</button></div>"
11
11
 
12
12
  assert_equal expected, actual
13
13
  end
@@ -16,7 +16,7 @@ class ButtonGroupTest < ActionView::TestCase
16
16
  actual = ui_button_group(position: :vertical) do |bg|
17
17
  bg.button 'state'
18
18
  end
19
- expected = "<div class=\"btn-group-vertical\" role=\"group\"><button class=\"btn\">state</button></div>"
19
+ expected = "<div class=\"btn-group-vertical\" role=\"group\"><button class=\"btn-secondary btn\">state</button></div>"
20
20
 
21
21
  assert_equal expected, actual
22
22
  end
@@ -34,7 +34,7 @@ class ButtonGroupTest < ActionView::TestCase
34
34
  actual = ui_button_group(size: :sm) do |bg|
35
35
  bg.button 'state'
36
36
  end
37
- expected = "<div class=\"btn-group btn-group-sm\" role=\"group\"><button class=\"btn btn-sm\">state</button></div>"
37
+ expected = "<div class=\"btn-group btn-group-sm\" role=\"group\"><button class=\"btn-secondary btn btn-sm\">state</button></div>"
38
38
 
39
39
  assert_equal expected, actual
40
40
  end
@@ -5,7 +5,7 @@ class ButtonTest < ActionView::TestCase
5
5
 
6
6
  test "button" do
7
7
  actual = ui_button('state')
8
- expected = "<button class=\"btn\">state</button>"
8
+ expected = "<button class=\"btn-secondary btn\">state</button>"
9
9
 
10
10
  assert_equal expected, actual
11
11
  end
@@ -26,56 +26,91 @@ class ButtonTest < ActionView::TestCase
26
26
 
27
27
  test 'button disabled' do
28
28
  actual = ui_button('state', state: :disabled)
29
- expected = "<button class=\"disabled btn\" disabled=\"disabled\">state</button>"
29
+ expected = "<button class=\"disabled btn-secondary btn\" disabled=\"disabled\">state</button>"
30
30
 
31
31
  assert_equal expected, actual
32
32
  end
33
33
 
34
34
  test 'button active' do
35
35
  actual = ui_button('state', state: :active)
36
- expected = "<button class=\"active btn\" aria-pressed=\"true\">state</button>"
36
+ expected = "<button class=\"active btn-secondary btn\" aria-pressed=\"true\">state</button>"
37
37
 
38
38
  assert_equal expected, actual
39
39
  end
40
40
 
41
41
  test 'button badge' do
42
42
  actual = ui_button('state', badge: 2)
43
- expected = "<button class=\"btn\">state<span class=\"badge-secondary badge\">2</span></button>"
43
+ expected = "<button class=\"btn-secondary btn\">state<span class=\"badge-secondary badge\">2</span></button>"
44
44
 
45
45
  assert_equal expected, actual
46
46
  end
47
47
 
48
48
  test 'button block' do
49
49
  actual = ui_button('state', type: :block)
50
- expected = "<button class=\"btn btn-block\">state</button>"
50
+ expected = "<button class=\"btn-secondary btn btn-block\">state</button>"
51
51
 
52
52
  assert_equal expected, actual
53
53
  end
54
54
 
55
55
  test 'button size' do
56
56
  actual = ui_button('state', size: :sm)
57
- expected = "<button class=\"btn btn-sm\">state</button>"
57
+ expected = "<button class=\"btn-secondary btn btn-sm\">state</button>"
58
58
 
59
59
  assert_equal expected, actual
60
60
  end
61
61
 
62
62
  test 'button toggle' do
63
63
  actual = ui_button('state', toggle: true)
64
- expected = "<button class=\"btn\" data-toggle=\"button\" aria-pressed=\"false\" autocomplete=\"off\">state</button>"
64
+ expected = "<button class=\"btn-secondary btn\" data-toggle=\"button\" aria-pressed=\"false\" autocomplete=\"off\">state</button>"
65
65
 
66
66
  assert_equal expected, actual
67
67
  end
68
68
 
69
69
  test 'button glyph' do
70
70
  actual = ui_button('state', glyph: 'diamond')
71
- expected = "<button class=\"btn\"><i class=\"glyph fas fa-diamond\"></i> state</button>"
71
+ expected = "<button class=\"btn-secondary btn\"><i class=\"glyph fas fa-diamond\"></i> state</button>"
72
72
 
73
73
  assert_equal expected, actual
74
74
  end
75
75
 
76
76
  test 'button glyph without text' do
77
77
  actual = ui_button('state', glyph: 'diamond', text: false)
78
- expected = "<button class=\"btn without-text\"><i title=\"state\" class=\"glyph fas fa-diamond\"></i></button>"
78
+ expected = "<button class=\"btn-secondary btn without-text\"><i title=\"state\" class=\"glyph fas fa-diamond\"></i></button>"
79
+
80
+ assert_equal expected, actual
81
+ end
82
+
83
+ test 'button with collapse' do
84
+ actual = ui_button('state', collapse: 'collapse-id')
85
+ expected = "<button class=\"btn-secondary btn\" data-toggle=\"collapse\" data-target=\"#collapse-id\">state</button>"
86
+
87
+ assert_equal expected, actual
88
+ end
89
+
90
+ test "button with simple popover" do
91
+ actual = ui_button('My Button', popover: 'My popover')
92
+ expected = "<button data-toggle=\"popover\" data-content=\"My popover\" class=\"btn-secondary btn\">My Button</button>"
93
+
94
+ assert_equal expected, actual
95
+ end
96
+
97
+ test "button with complex popover" do
98
+ actual = ui_button('My Button', popover: { content: 'My popover', position: :left })
99
+ expected = "<button data-toggle=\"popover\" data-content=\"My popover\" data-placement=\"left\" class=\"btn-secondary btn\">My Button</button>"
100
+
101
+ assert_equal expected, actual
102
+ end
103
+
104
+ test "button with simple tooltip" do
105
+ actual = ui_button('My Button', { tooltip: true }, { title: 'My tooltip' })
106
+ expected = "<button title=\"My tooltip\" data-toggle=\"tooltip\" class=\"btn-secondary btn\">My Button</button>"
107
+
108
+ assert_equal expected, actual
109
+ end
110
+
111
+ test "button with complex tooltip" do
112
+ actual = ui_button('My Button', tooltip: { title: 'My tooltip', position: :left })
113
+ expected = "<button data-toggle=\"tooltip\" data-title=\"My tooltip\" data-placement=\"left\" class=\"btn-secondary btn\">My Button</button>"
79
114
 
80
115
  assert_equal expected, actual
81
116
  end
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class CheckboxFieldTest < ActionView::TestCase
4
4
 
5
5
  test 'checkbox_field' do
6
- actual = UiBibz::Ui::Core::Forms::Choices::CheckboxField.new('John', { value: 1, status: :primary, type: :circle }).render
6
+ actual = UiBibz::Ui::Core::Forms::Choices::CheckboxField.new('John', { value: 1 }).render
7
7
  expected = "<div class=\"custom-control custom-checkbox\"><input type=\"hidden\" name=\"John\" id=\"John-hidden\" value=\"0\" /><input type=\"checkbox\" name=\"John\" id=\"John\" value=\"1\" class=\"custom-control-input\" /><label class=\"custom-control-label\" for=\"John\">John</label></div>"
8
8
 
9
9
  assert_equal expected, actual
@@ -5,7 +5,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
5
5
  test 'dropdown_select_field' do
6
6
  options = options_for_select(2.times.map{ |i| "option #{i}" })
7
7
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', options_tags: options).render
8
- expected = "<select name=\"test\" id=\"test\" class=\"dropdown-select-field\"></select>"
8
+ expected = "<select name=\"test\" id=\"test\" data-style=\"btn-secondary\" class=\"dropdown-select-field\"></select>"
9
9
 
10
10
  assert_equal expected, actual
11
11
  end
@@ -13,7 +13,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
13
13
  test 'dropdown_select_field searchable' do
14
14
  options = options_for_select(2.times.map{ |i| "option #{i}" })
15
15
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, searchable: true }).render
16
- expected = "<select name=\"test\" id=\"test\" data-live-search=\"true\" class=\"dropdown-select-field\"></select>"
16
+ expected = "<select name=\"test\" id=\"test\" data-live-search=\"true\" data-style=\"btn-secondary\" class=\"dropdown-select-field\"></select>"
17
17
 
18
18
  assert_equal expected, actual
19
19
  end
@@ -21,7 +21,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
21
21
  test 'dropdown_select_field max_options' do
22
22
  options = options_for_select(2.times.map{ |i| "option #{i}" })
23
23
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, max_options: 2 }).render
24
- expected = "<select name=\"test\" id=\"test\" data-max-options=\"2\" class=\"dropdown-select-field\"></select>"
24
+ expected = "<select name=\"test\" id=\"test\" data-max-options=\"2\" data-style=\"btn-secondary\" class=\"dropdown-select-field\"></select>"
25
25
 
26
26
  assert_equal expected, actual
27
27
  end
@@ -29,7 +29,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
29
29
  test 'dropdown_select_field selected_text_format' do
30
30
  options = options_for_select(2.times.map{ |i| "option #{i}" })
31
31
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, selected_text_format: "count > x" }).render
32
- expected = "<select name=\"test\" id=\"test\" data-selected-text-format=\"count &gt; x\" class=\"dropdown-select-field\"></select>"
32
+ expected = "<select name=\"test\" id=\"test\" data-selected-text-format=\"count &gt; x\" data-style=\"btn-secondary\" class=\"dropdown-select-field\"></select>"
33
33
 
34
34
  assert_equal expected, actual
35
35
  end
@@ -37,7 +37,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
37
37
  test 'dropdown_select_field menu_size' do
38
38
  options = options_for_select(2.times.map{ |i| "option #{i}" })
39
39
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, menu_size: 2 }).render
40
- expected = "<select name=\"test\" id=\"test\" data-size=\"2\" class=\"dropdown-select-field\"></select>"
40
+ expected = "<select name=\"test\" id=\"test\" data-size=\"2\" data-style=\"btn-secondary\" class=\"dropdown-select-field\"></select>"
41
41
 
42
42
  assert_equal expected, actual
43
43
  end
@@ -45,7 +45,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
45
45
  test 'dropdown_select_field actions_box' do
46
46
  options = options_for_select(2.times.map{ |i| "option #{i}" })
47
47
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, actions_box: true }).render
48
- expected = "<select name=\"test\" id=\"test\" data-actions-box=\"true\" class=\"dropdown-select-field\"></select>"
48
+ expected = "<select name=\"test\" id=\"test\" data-style=\"btn-secondary\" data-actions-box=\"true\" class=\"dropdown-select-field\"></select>"
49
49
 
50
50
  assert_equal expected, actual
51
51
  end
@@ -53,7 +53,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
53
53
  test 'dropdown_select_field show_tick' do
54
54
  options = options_for_select(2.times.map{ |i| "option #{i}" })
55
55
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, show_tick: true }).render
56
- expected = "<select name=\"test\" id=\"test\" class=\"dropdown-select-field show-tick\"></select>"
56
+ expected = "<select name=\"test\" id=\"test\" data-style=\"btn-secondary\" class=\"dropdown-select-field show-tick\"></select>"
57
57
 
58
58
  assert_equal expected, actual
59
59
  end
@@ -61,7 +61,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
61
61
  test 'dropdown_select_field show_menu_arrow' do
62
62
  options = options_for_select(2.times.map{ |i| "option #{i}" })
63
63
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, show_menu_arrow: true }).render
64
- expected = "<select name=\"test\" id=\"test\" class=\"dropdown-select-field show-menu-arrow\"></select>"
64
+ expected = "<select name=\"test\" id=\"test\" data-style=\"btn-secondary\" class=\"dropdown-select-field\"></select>"
65
65
 
66
66
  assert_equal expected, actual
67
67
  end
@@ -69,14 +69,14 @@ class DropdownSelectFieldTest < ActionView::TestCase
69
69
  test 'dropdown_select_field dropup' do
70
70
  options = options_for_select(2.times.map{ |i| "option #{i}" })
71
71
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, dropup: true }).render
72
- expected = "<select name=\"test\" id=\"test\" class=\"dropdown-select-field dropup\"></select>"
72
+ expected = "<select name=\"test\" id=\"test\" data-style=\"btn-secondary\" class=\"dropdown-select-field dropup\"></select>"
73
73
 
74
74
  assert_equal expected, actual
75
75
  end
76
76
 
77
77
  test 'dropdown_select_field refresh' do
78
78
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { refresh: { mode: 'local', target: { data: [] }}}).render
79
- expected = "<div class=\"field-refresh input-group ui_surround_field\"><select name=\"test\" id=\"test\" class=\"dropdown-select-field\"></select><div class=\"input-group-btn\"><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;local&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#test&quot;,&quot;url&quot;:&quot;&quot;,&quot;data&quot;:[]}}\" class=\"btn-secondary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fas fa-sync-alt\"></i> </span></div></div>"
79
+ expected = "<div class=\"field-refresh input-group ui_surround_field\"><select name=\"test\" id=\"test\" data-style=\"btn-secondary\" class=\"dropdown-select-field\"></select><div class=\"input-group-btn\"><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;local&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#test&quot;,&quot;url&quot;:&quot;&quot;,&quot;data&quot;:[]}}\" class=\"btn-secondary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fas fa-sync-alt\"></i> </span></div></div>"
80
80
 
81
81
  assert_equal expected, actual
82
82
  end
@@ -5,7 +5,7 @@ class SelectFieldTest < ActionView::TestCase
5
5
  test "Select Field" do
6
6
  options = options_for_select(2.times.map{ |i| "option #{i}" })
7
7
  actual = UiBibz::Ui::Core::Forms::Selects::SelectField.new('example', option_tags: options).render
8
- expected = "<select name=\"example\" id=\"example\" class=\"select-field form-control\"><option value=\"option 0\">option 0</option>
8
+ expected = "<select name=\"example\" id=\"example\" class=\"select-field form-control custom-select\"><option value=\"option 0\">option 0</option>
9
9
  <option value=\"option 1\">option 1</option></select>"
10
10
 
11
11
  assert_equal expected, actual
@@ -13,7 +13,7 @@ class SelectFieldTest < ActionView::TestCase
13
13
 
14
14
  test "Select Field refresh" do
15
15
  actual = UiBibz::Ui::Core::Forms::Selects::SelectField.new('example', refresh: { target: { url: '/' }}).render
16
- expected = "<div class=\"field-refresh input-group ui_surround_field\"><select name=\"example\" id=\"example\" class=\"select-field form-control\"></select><div class=\"input-group-btn\"><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#example&quot;,&quot;url&quot;:&quot;/&quot;,&quot;data&quot;:[]}}\" class=\"btn-secondary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fas fa-sync-alt\"></i> </span></div></div>"
16
+ expected = "<div class=\"field-refresh input-group ui_surround_field\"><select name=\"example\" id=\"example\" class=\"select-field form-control custom-select\"></select><div class=\"input-group-btn\"><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#example&quot;,&quot;url&quot;:&quot;/&quot;,&quot;data&quot;:[]}}\" class=\"btn-secondary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fas fa-sync-alt\"></i> </span></div></div>"
17
17
 
18
18
  assert_equal expected, actual
19
19
  end
@@ -39,7 +39,7 @@ class SurroundFieldTest < ActionView::TestCase
39
39
  actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf|
40
40
  sf.button 'Submit'
41
41
  end.render
42
- expected = "<div class=\"input-group ui_surround_field\"><div class=\"input-group-btn\"><button class=\"btn\">Submit</button></div></div>"
42
+ expected = "<div class=\"input-group ui_surround_field\"><div class=\"input-group-btn\"><button class=\"btn-secondary btn\">Submit</button></div></div>"
43
43
 
44
44
  assert_equal expected, actual
45
45
  end
@@ -50,7 +50,7 @@ class SurroundFieldTest < ActionView::TestCase
50
50
  sf.addon '€'
51
51
  sf.glyph 'pencil'
52
52
  end.render
53
- expected = "<div class=\"input-group ui_surround_field\"><div class=\"input-group-btn\"><button class=\"btn\">Submit</button></div><span class=\"input-group-addon\">€</span><span class=\"input-group-addon\"><i class=\"glyph fas fa-pencil\"></i></span></div>"
53
+ expected = "<div class=\"input-group ui_surround_field\"><div class=\"input-group-btn\"><button class=\"btn-secondary btn\">Submit</button></div><span class=\"input-group-addon\">€</span><span class=\"input-group-addon\"><i class=\"glyph fas fa-pencil\"></i></span></div>"
54
54
 
55
55
  assert_equal expected, actual
56
56
  end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+ class LinkTest < ActionView::TestCase
3
+ include UiBibz::Helpers::Ui::CoreHelper
4
+
5
+ test 'Link' do
6
+ actual = ui_link 'My link', url: "#link"
7
+ expected = "<a href=\"#link\">My link</a>"
8
+
9
+ assert_equal expected, actual
10
+ end
11
+
12
+ test 'Link without text' do
13
+ actual = ui_link 'My link', glyph: "gem", text: false, url: "#link"
14
+ expected = "<a href=\"#link\"><i title=\"My link\" class=\"glyph fas fa-gem\"></i></a>"
15
+
16
+ assert_equal expected, actual
17
+ end
18
+
19
+ test "Link with collapse option" do
20
+ actual = ui_link 'My link', url: "#link", collapse: 'collapse-id'
21
+ expected = "<a role=\"button\" data-toggle=\"collapse\" data-target=\"#collapse-id\" href=\"#link\">My link</a>"
22
+
23
+ assert_equal expected, actual
24
+ end
25
+
26
+ end