ui_bibz 3.0.0.beta11 → 3.0.0.beta16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +1 -1
  3. data/Gemfile.lock +60 -58
  4. data/lib/ui_bibz.rb +2 -0
  5. data/lib/ui_bibz/concerns/models/searchable.rb +3 -3
  6. data/lib/ui_bibz/infos.rb +2 -2
  7. data/lib/ui_bibz/inputs/ui_bibz_form/ui_bibz_form_builder.rb +9 -12
  8. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_radio_field_input.rb +2 -13
  9. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_switch_field_input.rb +1 -13
  10. data/lib/ui_bibz/rails/engine.rb +2 -2
  11. data/lib/ui_bibz/ui/concerns/navigation_concern.rb +12 -0
  12. data/lib/ui_bibz/ui/concerns/notification_concern.rb +13 -0
  13. data/lib/ui_bibz/ui/core/boxes/card.rb +1 -1
  14. data/lib/ui_bibz/ui/core/component.rb +5 -1
  15. data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +28 -18
  16. data/lib/ui_bibz/ui/core/forms/choices/components/choice.rb +8 -4
  17. data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +5 -34
  18. data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +2 -2
  19. data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +11 -0
  20. data/lib/ui_bibz/ui/core/navigations/nav.rb +1 -5
  21. data/lib/ui_bibz/ui/core/navigations/navbar.rb +1 -5
  22. data/lib/ui_bibz/ui/core/notifications/popover.rb +2 -6
  23. data/lib/ui_bibz/ui/core/notifications/tooltip.rb +2 -6
  24. data/lib/ui_bibz/ui/ux/tables/components/store.rb +3 -0
  25. data/lib/ui_bibz/ui/ux/tables/extensions/paginable.rb +0 -3
  26. data/lib/ui_bibz/ui/ux/tables/table_pagination.rb +0 -3
  27. data/lib/ui_bibz/ui/ux/tables/table_pagination_per_page.rb +0 -3
  28. data/test/simple_form_test.rb +38 -29
  29. data/test/ui/core/forms/choices/checkbox_field_test.rb +14 -0
  30. data/test/ui/core/forms/choices/radio_field_test.rb +7 -0
  31. data/test/ui/core/forms/selects/{multi_select_field_test.rb → dropdown_select_field_test.rb} +5 -5
  32. data/test/ui/core/forms/surrounds/surround_field_test.rb +1 -1
  33. data/ui_bibz.gemspec +1 -0
  34. metadata +22 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5109c403d8f9d306f2f973b619ef117bd7e3df4bb036358e47744058fc553718
4
- data.tar.gz: 3e1af30e67ffb1c68ae033110241da17a457aa7e1b0ebc797ca521f8d3d54991
3
+ metadata.gz: ffa18823b220fe50b0aab6b3b25e06d184bc514266edaf8a24e47345e8816001
4
+ data.tar.gz: c189f21d3f6ad9943f8fc9ce303eb9578d1159366a7fc3340d9a5fed8205d9ad
5
5
  SHA512:
6
- metadata.gz: e0bf93e9f8098b12c510c9aa3280506b893d54c6a05dad6338c4e5198ac23b9d27725403497db8171fbc7eb7e0b40358cdacc4238d1311ad2d0e02b19f6afc2b
7
- data.tar.gz: dcb82ceeed6c63c19ecf35b95014ccf78f12a702507598a6b29e1ea5665d7767e8d0224630cc2eadf46f1699e7d6917533e391d02cd82b3452bdffabfb417557
6
+ metadata.gz: 53ef82ec6ccc0bd9f4036887402fef838f6e206d2ce59282fd3b9571eaa1b960767607e99286bb515e95d801c8c8a4c4f7750c219096bed99b49ccd55cabc37c
7
+ data.tar.gz: 7e4f7f43e3fb0e1830eafc73b35c6901184586973db3d5964b06de5e27503edbee78d945f8203104effc617c3a4b0263a8903fd5d7cc0193a83a4e6c626b22ea
@@ -23,6 +23,6 @@ jobs:
23
23
  - name: Test with Rake
24
24
  uses: paambaati/codeclimate-action@v2.7.5
25
25
  env:
26
- CC_TEST_REPORTER_ID: 7e50558afc7a861280e3194a765a159e9ea5bdd22d2ebe6c13e5e23fe914c66b
26
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
27
27
  with:
28
28
  coverageCommand: bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (3.0.0.beta11)
4
+ ui_bibz (3.0.0.beta16)
5
5
  will-paginate-i18n
6
6
  will_paginate (~> 3.3.0)
7
7
  will_paginate-bootstrap4
@@ -9,63 +9,63 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actioncable (6.0.3.4)
13
- actionpack (= 6.0.3.4)
12
+ actioncable (6.0.3.5)
13
+ actionpack (= 6.0.3.5)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (6.0.3.4)
17
- actionpack (= 6.0.3.4)
18
- activejob (= 6.0.3.4)
19
- activerecord (= 6.0.3.4)
20
- activestorage (= 6.0.3.4)
21
- activesupport (= 6.0.3.4)
16
+ actionmailbox (6.0.3.5)
17
+ actionpack (= 6.0.3.5)
18
+ activejob (= 6.0.3.5)
19
+ activerecord (= 6.0.3.5)
20
+ activestorage (= 6.0.3.5)
21
+ activesupport (= 6.0.3.5)
22
22
  mail (>= 2.7.1)
23
- actionmailer (6.0.3.4)
24
- actionpack (= 6.0.3.4)
25
- actionview (= 6.0.3.4)
26
- activejob (= 6.0.3.4)
23
+ actionmailer (6.0.3.5)
24
+ actionpack (= 6.0.3.5)
25
+ actionview (= 6.0.3.5)
26
+ activejob (= 6.0.3.5)
27
27
  mail (~> 2.5, >= 2.5.4)
28
28
  rails-dom-testing (~> 2.0)
29
- actionpack (6.0.3.4)
30
- actionview (= 6.0.3.4)
31
- activesupport (= 6.0.3.4)
29
+ actionpack (6.0.3.5)
30
+ actionview (= 6.0.3.5)
31
+ activesupport (= 6.0.3.5)
32
32
  rack (~> 2.0, >= 2.0.8)
33
33
  rack-test (>= 0.6.3)
34
34
  rails-dom-testing (~> 2.0)
35
35
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
- actiontext (6.0.3.4)
37
- actionpack (= 6.0.3.4)
38
- activerecord (= 6.0.3.4)
39
- activestorage (= 6.0.3.4)
40
- activesupport (= 6.0.3.4)
36
+ actiontext (6.0.3.5)
37
+ actionpack (= 6.0.3.5)
38
+ activerecord (= 6.0.3.5)
39
+ activestorage (= 6.0.3.5)
40
+ activesupport (= 6.0.3.5)
41
41
  nokogiri (>= 1.8.5)
42
- actionview (6.0.3.4)
43
- activesupport (= 6.0.3.4)
42
+ actionview (6.0.3.5)
43
+ activesupport (= 6.0.3.5)
44
44
  builder (~> 3.1)
45
45
  erubi (~> 1.4)
46
46
  rails-dom-testing (~> 2.0)
47
47
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
- activejob (6.0.3.4)
49
- activesupport (= 6.0.3.4)
48
+ activejob (6.0.3.5)
49
+ activesupport (= 6.0.3.5)
50
50
  globalid (>= 0.3.6)
51
- activemodel (6.0.3.4)
52
- activesupport (= 6.0.3.4)
53
- activerecord (6.0.3.4)
54
- activemodel (= 6.0.3.4)
55
- activesupport (= 6.0.3.4)
56
- activestorage (6.0.3.4)
57
- actionpack (= 6.0.3.4)
58
- activejob (= 6.0.3.4)
59
- activerecord (= 6.0.3.4)
51
+ activemodel (6.0.3.5)
52
+ activesupport (= 6.0.3.5)
53
+ activerecord (6.0.3.5)
54
+ activemodel (= 6.0.3.5)
55
+ activesupport (= 6.0.3.5)
56
+ activestorage (6.0.3.5)
57
+ actionpack (= 6.0.3.5)
58
+ activejob (= 6.0.3.5)
59
+ activerecord (= 6.0.3.5)
60
60
  marcel (~> 0.3.1)
61
- activesupport (6.0.3.4)
61
+ activesupport (6.0.3.5)
62
62
  concurrent-ruby (~> 1.0, >= 1.0.2)
63
63
  i18n (>= 0.7, < 2)
64
64
  minitest (~> 5.1)
65
65
  tzinfo (~> 1.1)
66
66
  zeitwerk (~> 2.2, >= 2.2.2)
67
67
  ast (2.4.2)
68
- awesome_print (1.8.0)
68
+ awesome_print (1.9.2)
69
69
  builder (3.2.4)
70
70
  byebug (11.1.3)
71
71
  childprocess (4.0.0)
@@ -95,7 +95,7 @@ GEM
95
95
  haml (>= 4.0, < 6)
96
96
  nokogiri (>= 1.6.0)
97
97
  ruby_parser (~> 3.5)
98
- i18n (1.8.8)
98
+ i18n (1.8.9)
99
99
  concurrent-ruby (~> 1.0)
100
100
  iniparse (1.5.0)
101
101
  jquery-rails (4.4.0)
@@ -113,8 +113,8 @@ GEM
113
113
  mimemagic (0.3.5)
114
114
  mini_mime (1.0.2)
115
115
  mini_portile2 (2.5.0)
116
- minitest (5.14.3)
117
- nio4r (2.5.5)
116
+ minitest (5.14.4)
117
+ nio4r (2.5.7)
118
118
  nokogiri (1.11.1)
119
119
  mini_portile2 (~> 2.5.0)
120
120
  racc (~> 1.4)
@@ -128,37 +128,37 @@ GEM
128
128
  rack (2.2.3)
129
129
  rack-test (1.1.0)
130
130
  rack (>= 1.0, < 3)
131
- rails (6.0.3.4)
132
- actioncable (= 6.0.3.4)
133
- actionmailbox (= 6.0.3.4)
134
- actionmailer (= 6.0.3.4)
135
- actionpack (= 6.0.3.4)
136
- actiontext (= 6.0.3.4)
137
- actionview (= 6.0.3.4)
138
- activejob (= 6.0.3.4)
139
- activemodel (= 6.0.3.4)
140
- activerecord (= 6.0.3.4)
141
- activestorage (= 6.0.3.4)
142
- activesupport (= 6.0.3.4)
131
+ rails (6.0.3.5)
132
+ actioncable (= 6.0.3.5)
133
+ actionmailbox (= 6.0.3.5)
134
+ actionmailer (= 6.0.3.5)
135
+ actionpack (= 6.0.3.5)
136
+ actiontext (= 6.0.3.5)
137
+ actionview (= 6.0.3.5)
138
+ activejob (= 6.0.3.5)
139
+ activemodel (= 6.0.3.5)
140
+ activerecord (= 6.0.3.5)
141
+ activestorage (= 6.0.3.5)
142
+ activesupport (= 6.0.3.5)
143
143
  bundler (>= 1.3.0)
144
- railties (= 6.0.3.4)
144
+ railties (= 6.0.3.5)
145
145
  sprockets-rails (>= 2.0.0)
146
146
  rails-dom-testing (2.0.3)
147
147
  activesupport (>= 4.2.0)
148
148
  nokogiri (>= 1.6)
149
149
  rails-html-sanitizer (1.3.0)
150
150
  loofah (~> 2.3)
151
- railties (6.0.3.4)
152
- actionpack (= 6.0.3.4)
153
- activesupport (= 6.0.3.4)
151
+ railties (6.0.3.5)
152
+ actionpack (= 6.0.3.5)
153
+ activesupport (= 6.0.3.5)
154
154
  method_source
155
155
  rake (>= 0.8.7)
156
156
  thor (>= 0.20.3, < 2.0)
157
157
  rainbow (3.0.0)
158
158
  rake (13.0.3)
159
- regexp_parser (2.0.3)
159
+ regexp_parser (2.1.1)
160
160
  rexml (3.2.4)
161
- rubocop (1.9.1)
161
+ rubocop (1.11.0)
162
162
  parallel (~> 1.10)
163
163
  parser (>= 3.0.0.0)
164
164
  rainbow (>= 2.2.2, < 4.0)
@@ -171,7 +171,7 @@ GEM
171
171
  parser (>= 2.7.1.5)
172
172
  rubocop-minitest (0.10.3)
173
173
  rubocop (>= 0.87, < 2.0)
174
- rubocop-performance (1.9.2)
174
+ rubocop-performance (1.10.1)
175
175
  rubocop (>= 0.90.0, < 2.0)
176
176
  rubocop-ast (>= 0.4.0)
177
177
  rubocop-rails (2.9.1)
@@ -213,6 +213,7 @@ GEM
213
213
  will_paginate (3.3.0)
214
214
  will_paginate-bootstrap4 (0.2.2)
215
215
  will_paginate (~> 3.0, >= 3.0.0)
216
+ yard (0.9.26)
216
217
  zeitwerk (2.4.2)
217
218
 
218
219
  PLATFORMS
@@ -236,6 +237,7 @@ DEPENDENCIES
236
237
  simplecov
237
238
  sqlite3
238
239
  ui_bibz!
240
+ yard
239
241
 
240
242
  BUNDLED WITH
241
243
  2.1.4
data/lib/ui_bibz.rb CHANGED
@@ -78,6 +78,8 @@ module UiBibz
78
78
  module Concerns
79
79
  autoload :HtmlConcern, 'ui_bibz/ui/concerns/html_concern'
80
80
  autoload :CardItemableConcern, 'ui_bibz/ui/concerns/card_itemable_concern'
81
+ autoload :NavigationConcern, 'ui_bibz/ui/concerns/navigation_concern'
82
+ autoload :NotificationConcern, 'ui_bibz/ui/concerns/notification_concern'
81
83
  end
82
84
 
83
85
  # Core
@@ -120,18 +120,18 @@ module UiBibz::Concerns::Models::Searchable
120
120
  if attribute == :as
121
121
  attribute.each_value do |value|
122
122
  sql_subquery << "lower(#{value}) LIKE :#{value}_#{i}"
123
- sql_attributes = sql_attributes.merge(Hash["#{value}_#{i}".to_sym, "%#{pattern}%"])
123
+ sql_attributes = sql_attributes.merge({ "#{value}_#{i}".to_sym => "%#{pattern}%" })
124
124
  end
125
125
  else
126
126
  key_name = attribute.keys.first.to_s.pluralize
127
127
  attribute.each_value do |value|
128
128
  sql_subquery << "lower(#{key_name}.#{value}) LIKE :#{key_name}_#{value}_#{i}"
129
- sql_attributes = sql_attributes.merge(Hash["#{key_name}_#{value}_#{i}".to_sym, "%#{pattern}%"])
129
+ sql_attributes = sql_attributes.merge({ "#{key_name}_#{value}_#{i}".to_sym => "%#{pattern}%" })
130
130
  end
131
131
  end
132
132
  else
133
133
  sql_subquery << "lower(#{to_s.underscore.pluralize.split('/').last}.#{attribute}) LIKE :#{attribute}_#{i}"
134
- sql_attributes = sql_attributes.merge(Hash["#{attribute}_#{i}".to_sym, "%#{pattern}%"])
134
+ sql_attributes = sql_attributes.merge({ "#{attribute}_#{i}".to_sym => "%#{pattern}%" })
135
135
  end
136
136
  end
137
137
  sql_query << "(#{sql_subquery.join(' OR ')})"
data/lib/ui_bibz/infos.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module UiBibz
4
4
  NAME = 'Ui Bibz'
5
5
  SLUG = 'ui_bibz'
6
- BOOTSTRAP_VERSION = '5.0.0.beta1'
6
+ BOOTSTRAP_VERSION = '5.0.0.beta2'
7
7
  DESCRIPTION = "A Rails Interface Framework using Bootstrap #{BOOTSTRAP_VERSION}."
8
8
  SUMMARY = "Ui Bibz is an Ui Framework that allows you to build an interface very quickly and simply using Bootstrap #{BOOTSTRAP_VERSION}."
9
9
  LICENSE = 'MIT'
@@ -12,6 +12,6 @@ module UiBibz
12
12
  REPO = 'git+https://github.com/thooams/ui_bibz.git'
13
13
  EMAIL = 'thomas@hummel.link'
14
14
  AUTHOR = 'Thooams [Thomas HUMMEL]'
15
- VERSION = '3.0.0.beta11'
15
+ VERSION = '3.0.0.beta16'
16
16
  AUTHORS = ['Thooams'].freeze
17
17
  end
@@ -17,7 +17,7 @@ module UiBibzForm
17
17
  wrapper_html = (options[:input_html] || {}).merge({ class: input_classes })
18
18
  surround_field = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new(content, opts, html_options).tap(&block)
19
19
  errors_text = surround_field.errors.flatten.to_sentence
20
- required = surround_field.required_fields.any? { |u| u == true }
20
+ required = surround_field.required_fields.any?(true)
21
21
  wrapper_classes = UiBibz::Utils::Screwdriver.join_classes(('has-error' if errors_text.present?), wrapper_html.try(:[], :class))
22
22
  label_classes = UiBibz::Utils::Screwdriver.join_classes(('required' if required), 'control-label')
23
23
  abbr_html = content_tag('abbr', I18n.t(:"simple_form.required.mark", default: '*'), title: I18n.t(:"simple_form.required.text", default: 'required')) if required
@@ -32,19 +32,16 @@ module UiBibzForm
32
32
  end
33
33
 
34
34
  def ui_button_group(content = nil, opts = nil, html_options = nil, &block)
35
- content = (options || {}).merge(content || {})
36
- content = content.merge(template: @template, form: self)
37
-
38
- input_classes = UiBibz::Utils::Screwdriver.join_classes('button_group', options[:input_html].try(:[], :class))
39
- wrapper_html = (options[:input_html] || {}).merge({ class: input_classes })
40
-
41
- content_tag :div, wrapper_html do
42
- concat content_tag(:label, content[:label]) unless content[:label].nil?
43
- concat UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new(content, opts, html_options).tap(&block).render
44
- end
35
+ ui_component_group_by(UiBibz::Ui::Core::Forms::Buttons::ButtonGroup, content, opts, html_options, &block)
45
36
  end
46
37
 
47
38
  def ui_choice_group(content = nil, opts = nil, html_options = nil, &block)
39
+ ui_component_group_by(UiBibz::Ui::Core::Forms::Choices::ChoiceGroup, content, opts, html_options, &block)
40
+ end
41
+
42
+ private
43
+
44
+ def ui_component_group_by(component_class, content = nil, opts = nil, html_options = nil, &block)
48
45
  content = (options || {}).merge(content || {})
49
46
  content = content.merge(template: @template, form: self)
50
47
 
@@ -53,7 +50,7 @@ module UiBibzForm
53
50
 
54
51
  content_tag :div, wrapper_html do
55
52
  concat content_tag(:label, content[:label]) unless content[:label].nil?
56
- concat UiBibz::Ui::Core::Forms::Choices::ChoiceGroup.new(content, opts, html_options).tap(&block).render
53
+ concat component_class.new(content, opts, html_options).tap(&block).render
57
54
  end
58
55
  end
59
56
  end
@@ -1,20 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UiBibzInputs
4
- class UiRadioFieldInput < SimpleForm::Inputs::CollectionRadioButtonsInput
5
- include UiBibz::Ui::Core::Forms::Choices
6
-
4
+ class UiRadioFieldInput < UiCheckboxFieldInput
7
5
  def input(_wrapper_options)
8
- i = UiBibz::Ui::Core::Forms::Choices::RadioField.new(attribute_name, options, input_html_options)
9
- options[:item_wrapper_tag] = :div
10
- options[:item_wrapper_class] = i.html_options[:class]
11
-
12
- label_method, value_method = detect_collection_methods
13
-
14
- @builder.send(:collection_radio_buttons,
15
- attribute_name, collection, value_method, label_method,
16
- input_options, i.html_options,
17
- &collection_block_for_nested_boolean_style)
6
+ UiBibz::Ui::Core::Forms::Choices::RadioField.new(input_attribute_name, new_options, input_html_options).render
18
7
  end
19
8
  end
20
9
  end
@@ -1,23 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UiBibzInputs
4
- class UiSwitchFieldInput < BaseInput
4
+ class UiSwitchFieldInput < UiCheckboxFieldInput
5
5
  include UiBibz::Ui::Core::Forms::Choices
6
6
 
7
7
  def input(_wrapper_options)
8
8
  UiBibz::Ui::Core::Forms::Choices::SwitchField.new(input_attribute_name, new_options, new_input_html_options).render
9
9
  end
10
-
11
- def new_input_html_options
12
- input_html_options.merge({ checked: value.nil? ? false : value })
13
- end
14
-
15
- def value
16
- @value ||= @builder.object.send(attribute_name)
17
- end
18
-
19
- def new_options
20
- options.merge({ label: attribute_name.to_s.titleize })
21
- end
22
10
  end
23
11
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # to load pagination in rails app
4
- require 'will_paginate' if system('gem list -i will_paginate', out: File::NULL)
5
- require 'simple_form' if system('gem list -i simple_form', out: File::NULL)
4
+ require 'will_paginate' if Gem.loaded_specs.key?('will_paginate')
5
+ require 'simple_form' if Gem.loaded_specs.key?('simple_form')
6
6
 
7
7
  module UiBibz
8
8
  module Rails
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiBibz::Ui::Concerns::NavigationConcern #:nodoc:
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def spacer(num = 'auto')
8
+ kls = " me-#{num}"
9
+ @items.last.html_options[:class].nil? ? @items.last.html_options[:class] = kls : @items.last.html_options[:class] << kls
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UiBibz::Ui::Concerns::NotificationConcern #:nodoc:
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def data_attributes
8
+ self.class.const_get('DATA_ATTRIBUTES').map do |data_attribute|
9
+ options[data_attribute].to_s.blank? ? nil : { "data-bs-#{data_attribute}" => data_attribute_value(data_attribute) }
10
+ end.compact.reduce(&:merge) || {}
11
+ end
12
+ end
13
+ end
@@ -90,7 +90,7 @@ module UiBibz::Ui::Core::Boxes
90
90
  class Card < UiBibz::Ui::Core::Component
91
91
  include UiBibz::Ui::Concerns::CardItemableConcern
92
92
 
93
- # See UiBibz::Ui::Core::Component.initialize
93
+ # (see UiBibz::Ui::Core::Component#initialize)
94
94
  def initialize(content = nil, options = nil, html_options = nil, &block)
95
95
  super
96
96
  @items = @content.nil? ? [] : [UiBibz::Ui::Core::Boxes::Components::CardBody.new(@content).render]
@@ -122,6 +122,10 @@ module UiBibz::Ui::Core
122
122
  # To turbolinks
123
123
  data_turbolinks = html_options.try(:[], :data).try(:[], :turbolinks) || options.try(:delete, :turbolinks)
124
124
  add_html_data(:turbolinks, value: data_turbolinks) unless data_turbolinks.nil?
125
+
126
+ # To Turbo
127
+ data_turbo = html_options.try(:[], :data).try(:[], :turbo) || options.try(:delete, :turbo)
128
+ add_html_data(:turbo, value: data_turbo) unless data_turbo.nil?
125
129
  end
126
130
 
127
131
  # Override this method to add html Options
@@ -145,7 +149,7 @@ module UiBibz::Ui::Core
145
149
  def add_html_data(name, value: true)
146
150
  html_options[:data] = {} if html_options[:data].nil?
147
151
  value = value.is_a?(String) ? value.strip : value
148
- html_options[:data].update(Hash[name, value])
152
+ html_options[:data].update({ name => value })
149
153
  end
150
154
 
151
155
  def disabled?
@@ -22,6 +22,8 @@ module UiBibz::Ui::Core::Forms::Choices
22
22
  # * +action+ - String Stimulus Option
23
23
  # * +label+ - [String/Boolean]
24
24
  # * +boolean+ - Boolean Add an hidden field for rails
25
+ # * +wrapper_html+: - Hash html_options for the wrapper
26
+ # * +label_html+: - Hash html_options for the label
25
27
  #
26
28
  # ==== Signatures
27
29
  #
@@ -52,31 +54,35 @@ module UiBibz::Ui::Core::Forms::Choices
52
54
 
53
55
  # Render html tag
54
56
  def pre_render
55
- checkbox_field_html_tag
57
+ content_tag :div, wrapper_html_options do
58
+ concat hidden_field_tag(content, '0', id: "#{content}-hidden") if options[:boolean]
59
+ concat check_box_tag(content, options[:value] || '1', options[:checked] || html_options[:checked], checkbox_html_options)
60
+ concat label_tag(label_name, label_content, label_html_options) if options[:label] != false
61
+ end
56
62
  end
57
63
 
58
64
  private
59
65
 
60
- def checkbox_field_html_tag
61
- content_tag(:div, html_options.except(:id, 'data-action')) do
62
- concat hidden_field_tag content, '0', id: "#{content}-hidden" if options[:boolean]
63
- concat check_box_tag content, options[:value] || '1', options[:checked] || html_options[:checked], checkbox_html_options
64
- concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
66
+ def wrapper_html_options
67
+ (options[:wrapper_html] || {}).tap do |option|
68
+ option[:class] = UiBibz::Utils::Screwdriver.join_classes(wrapper_classes, inline, options[:wrapper_html].try(:[], :class))
65
69
  end
66
70
  end
67
71
 
68
- def checkbox_html_options
69
- {
70
- disabled: disabled?,
71
- checked: options[:state] == :active,
72
- indeterminate: options[:indeterminate],
73
- "data-action": options[:action],
74
- class: UiBibz::Utils::Screwdriver.join_classes('form-check-input', input_status)
75
- }.tap do |html|
76
- html[:id] = html_options[:id] if html_options[:id]
72
+ def label_html_options
73
+ (options[:label_html] || {}).tap do |option|
74
+ option[:class] = UiBibz::Utils::Screwdriver.join_classes(label_classes, options[:label_html].try(:[], :class))
77
75
  end
78
76
  end
79
77
 
78
+ def checkbox_html_options
79
+ html_options.merge({
80
+ disabled: disabled?,
81
+ checked: html_options[:checked] || options[:state] == :active,
82
+ indeterminate: options[:indeterminate]
83
+ })
84
+ end
85
+
80
86
  def label_name
81
87
  html_options[:id] || content
82
88
  end
@@ -93,7 +99,7 @@ module UiBibz::Ui::Core::Forms::Choices
93
99
  end
94
100
 
95
101
  def component_html_classes
96
- super << component_wrapper_html_classes
102
+ super << ['form-check-input', input_status]
97
103
  end
98
104
 
99
105
  def input_status
@@ -106,8 +112,12 @@ module UiBibz::Ui::Core::Forms::Choices
106
112
  'form-check-inline' if options[:inline]
107
113
  end
108
114
 
109
- def component_wrapper_html_classes
110
- ['form-check', inline]
115
+ def wrapper_classes
116
+ 'form-check'
117
+ end
118
+
119
+ def label_classes
120
+ 'form-check-label'
111
121
  end
112
122
  end
113
123
  end
@@ -82,10 +82,14 @@ module UiBibz::Ui::Core::Forms::Choices
82
82
  if options[:label]
83
83
  content_tag :label, options[:label], html_options.merge(for: input_id)
84
84
  else
85
- content_tag :label, html_options.merge(for: input_id) do
86
- concat glyph_and_content_html(options[:text].nil? ? @content : ' ')
87
- concat badge_html unless options[:badge].nil?
88
- end
85
+ generated_label
86
+ end
87
+ end
88
+
89
+ def generated_label
90
+ content_tag :label, html_options.merge(for: input_id) do
91
+ concat glyph_and_content_html(options[:text].nil? ? @content : ' ')
92
+ concat badge_html unless options[:badge].nil?
89
93
  end
90
94
  end
91
95
 
@@ -21,6 +21,8 @@ module UiBibz::Ui::Core::Forms::Choices
21
21
  # * +inline+ - Boolean
22
22
  # * +action+ - String Stimulus Option
23
23
  # * +label+ - String
24
+ # * +wrapper_html+: - Hash html_options for the wrapper
25
+ # * +label_html+: - Hash html_options for the label
24
26
  #
25
27
  # ==== Signatures
26
28
  #
@@ -51,47 +53,16 @@ module UiBibz::Ui::Core::Forms::Choices
51
53
 
52
54
  # Render html tag
53
55
  def pre_render
54
- radio_field_html_tag
55
- end
56
-
57
- private
58
-
59
- def radio_field_html_tag
60
- content_tag :div, html_options.except(:id) do
56
+ content_tag :div, wrapper_html_options do
61
57
  concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
62
58
  concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
63
59
  end
64
60
  end
65
61
 
66
- def checkbox_html_options
67
- {
68
- disabled: disabled?,
69
- checked: options[:state] == :active,
70
- "data-action": options[:action],
71
- class: UiBibz::Utils::Screwdriver.join_classes('form-check-input', input_status)
72
- }
73
- end
62
+ private
74
63
 
75
64
  def label_name
76
- "#{content}_#{options[:value]}"
77
- end
78
-
79
- def component_html_classes
80
- super << component_wrapper_html_classes
81
- end
82
-
83
- def status; end
84
-
85
- def input_status
86
- "form-check-input-#{options[:status]}" if options[:status]
87
- end
88
-
89
- def inline
90
- 'form-check-inline' if options[:inline]
91
- end
92
-
93
- def component_wrapper_html_classes
94
- ['form-check', inline]
65
+ html_options[:id] || "#{content}_#{options[:value]}"
95
66
  end
96
67
  end
97
68
  end
@@ -47,8 +47,8 @@ module UiBibz::Ui::Core::Forms::Choices
47
47
  { boolean: true }
48
48
  end
49
49
 
50
- def component_html_classes
51
- ['form-check', 'form-switch', inline]
50
+ def wrapper_classes
51
+ %w[form-check form-switch]
52
52
  end
53
53
  end
54
54
  end
@@ -25,6 +25,7 @@ module UiBibz::Ui::Core::Forms::Selects
25
25
  # * +searchable+ - Boolean
26
26
  # * +select_all_option+ - Boolean
27
27
  # * +append+ - String, Html
28
+ # * +non_selected_text+ - String
28
29
  # * +open+ - Boolean
29
30
  # * +theme+ - Symbol, defaut: +:dark+
30
31
  # * +prepend+ - String, Html
@@ -83,10 +84,12 @@ module UiBibz::Ui::Core::Forms::Selects
83
84
  clickable_opt_group
84
85
  collapsible_opt_group
85
86
  searchable
87
+ non_selected_text
86
88
  select_all_options
87
89
  number_displayed
88
90
  dropdown_menu_classes
89
91
  dropdown_classes
92
+ n_selected_text
90
93
  end
91
94
 
92
95
  def clickable_opt_group
@@ -101,6 +104,10 @@ module UiBibz::Ui::Core::Forms::Selects
101
104
  add_html_data('enable_filtering') if options[:searchable]
102
105
  end
103
106
 
107
+ def n_selected_text
108
+ add_html_data('n_selected_text', value: options[:n_selected_text]) if options[:n_selected_text]
109
+ end
110
+
104
111
  def number_displayed
105
112
  add_html_data('number_displayed') if options[:number_displayed]
106
113
  end
@@ -109,6 +116,10 @@ module UiBibz::Ui::Core::Forms::Selects
109
116
  add_html_data('include_select_all_option') if options[:select_all_options]
110
117
  end
111
118
 
119
+ def non_selected_text
120
+ add_html_data('non_selected_text', value: options[:non_selected_text]) if options[:non_selected_text]
121
+ end
122
+
112
123
  def dropdown_menu_classes
113
124
  classes = join_classes(theme, alignment, open)
114
125
  add_html_data('dropdown_menu_classes', value: classes.nil? ? nil : classes.join(' '))
@@ -67,6 +67,7 @@ module UiBibz::Ui::Core::Navigations
67
67
  #
68
68
  class Nav < UiBibz::Ui::Core::Component
69
69
  include UiBibz::Ui::Concerns::HtmlConcern
70
+ include UiBibz::Ui::Concerns::NavigationConcern
70
71
 
71
72
  # See UiBibz::Ui::Core::Component.initialize
72
73
  def initialize(content = nil, options = nil, html_options = nil, &block)
@@ -108,11 +109,6 @@ module UiBibz::Ui::Core::Navigations
108
109
  @items << NavDropdown.new(content, options, html_options).tap(&block)
109
110
  end
110
111
 
111
- def spacer(num = 'auto')
112
- kls = " me-#{num}"
113
- @items.last.html_options[:class].nil? ? @items.last.html_options[:class] = kls : @items.last.html_options[:class] << kls
114
- end
115
-
116
112
  protected
117
113
 
118
114
  def component_html_classes
@@ -75,6 +75,7 @@ module UiBibz::Ui::Core::Navigations
75
75
  #
76
76
  class Navbar < UiBibz::Ui::Core::Component
77
77
  include UiBibz::Ui::Concerns::HtmlConcern
78
+ include UiBibz::Ui::Concerns::NavigationConcern
78
79
 
79
80
  # See UiBibz::Ui::Core::Component.initialize
80
81
  def initialize(content = nil, options = nil, html_options = nil, &block)
@@ -124,11 +125,6 @@ module UiBibz::Ui::Core::Navigations
124
125
  @brand = UiBibz::Ui::Core::Navigations::NavbarBrand.new(content, options, html_options, &block).render
125
126
  end
126
127
 
127
- def spacer(num = 'auto')
128
- kls = " me-#{num}"
129
- @items.last.html_options[:class].nil? ? @items.last.html_options[:class] = kls : @items.last.html_options[:class] << kls
130
- end
131
-
132
128
  def id
133
129
  @id ||= generate_id('navbar-id')
134
130
  end
@@ -47,6 +47,8 @@ module UiBibz::Ui::Core::Notifications
47
47
  # ui_glyph("diamond", popover: { title: "My content", position: :right})
48
48
  #
49
49
  class Popover < UiBibz::Ui::Core::Component
50
+ include UiBibz::Ui::Concerns::NotificationConcern
51
+
50
52
  # Note that for security reasons the sanitize, sanitizeFn, and allowList
51
53
  # options cannot be supplied using data attributes.
52
54
  # https://getbootstrap.com/docs/5.0/components/popovers/#options
@@ -76,12 +78,6 @@ module UiBibz::Ui::Core::Notifications
76
78
  end
77
79
  end
78
80
 
79
- def data_attributes
80
- DATA_ATTRIBUTES.map do |data_attribute|
81
- options[data_attribute].to_s.blank? ? nil : { "data-bs-#{data_attribute}" => data_attribute_value(data_attribute) }
82
- end.compact.reduce(&:merge) || {}
83
- end
84
-
85
81
  def data_attribute_value(data_attribute)
86
82
  options[data_attribute].is_a?(String) ? options[data_attribute].html_safe : options[data_attribute]
87
83
  end
@@ -48,6 +48,8 @@ module UiBibz::Ui::Core::Notifications
48
48
  # ui_glyph("diamond", tooltip: { title: "My content", position: :right})
49
49
  #
50
50
  class Tooltip < UiBibz::Ui::Core::Component
51
+ include UiBibz::Ui::Concerns::NotificationConcern
52
+
51
53
  # Note that for security reasons the sanitize, sanitizeFn, and allowList
52
54
  # options cannot be supplied using data attributes.
53
55
  # https://getbootstrap.com/docs/5.0/components/tooltips/#options
@@ -76,12 +78,6 @@ module UiBibz::Ui::Core::Notifications
76
78
  end
77
79
  end
78
80
 
79
- def data_attributes
80
- DATA_ATTRIBUTES.map do |data_attribute|
81
- options[data_attribute].to_s.blank? ? nil : { "data-bs-#{data_attribute}" => data_attribute_value(data_attribute) }
82
- end.compact.reduce(&:merge) || {}
83
- end
84
-
85
81
  def data_attribute_value(data_attribute)
86
82
  options[data_attribute].is_a?(String) ? options[data_attribute].html_safe : options[data_attribute]
87
83
  end
@@ -8,6 +8,9 @@ module UiBibz::Ui::Ux::Tables
8
8
 
9
9
  # Store Use WillPaginate store methods
10
10
  def initialize(store)
11
+ raise 'Store is nil!' if store.nil?
12
+ raise 'Store can be created only with "table_search_pagination" method!' if store.try(:records).nil?
13
+
11
14
  @records = store.records
12
15
  @store = store
13
16
  @model = store.model
@@ -26,9 +26,6 @@ module UiBibz::Ui::Ux::Tables
26
26
  private
27
27
 
28
28
  def store
29
- raise 'Store is nil!' if @search_field.options[:store].nil?
30
- raise 'Store can be created only with "table_search_pagination" method!' if @search_field.options[:store].try(:records).nil?
31
-
32
29
  @store ||= Store.new @search_field.options[:store]
33
30
  end
34
31
  end
@@ -53,9 +53,6 @@ module UiBibz::Ui::Ux::Tables
53
53
 
54
54
  # Store must be generated by *table_search_pagination* method
55
55
  def store
56
- raise 'Store is nil!' if @pagination.options[:store].nil?
57
- raise 'Store can be created only with "table_search_pagination" method!' if @pagination.options[:store].try(:records).nil?
58
-
59
56
  @store ||= Store.new @pagination.options[:store]
60
57
  end
61
58
  end
@@ -46,9 +46,6 @@ module UiBibz::Ui::Ux::Tables
46
46
  private
47
47
 
48
48
  def store
49
- raise 'Store is nil!' if @per_page_field.options[:store].nil?
50
- raise 'Store can be created only with "table_search_pagination" method!' if @per_page_field.options[:store].try(:records).nil?
51
-
52
49
  @store ||= Store.new @per_page_field.options[:store]
53
50
  end
54
51
 
@@ -132,10 +132,10 @@ test1</textarea></div></form>"
132
132
 
133
133
  test 'radio field input in simple form' do
134
134
  actual = simple_form_for @user do |f|
135
- f.input :name_fr, as: :ui_radio_field, collection: @users, label_method: :name_fr
135
+ f.input :name_fr, as: :ui_radio_field, label: 'Radio 1', input_html: { id: "radio_1" }
136
136
  end
137
137
 
138
- expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_radio_field optional user_name_fr\"><label class=\"control-label ui_radio_field optional\">Name fr</label><input type=\"hidden\" name=\"user[name_fr]\" value=\"\" /><div class=\"radio ui_radio_field optional form-check\"><input class=\"ui_radio_field optional form-check\" type=\"radio\" value=\"1\" name=\"user[name_fr]\" id=\"user_name_fr_1\" /><label class=\"collection_radio_buttons\" for=\"user_name_fr_1\">test1</label></div><div class=\"radio ui_radio_field optional form-check\"><input class=\"ui_radio_field optional form-check\" type=\"radio\" value=\"2\" name=\"user[name_fr]\" id=\"user_name_fr_2\" /><label class=\"collection_radio_buttons\" for=\"user_name_fr_2\">test2</label></div></div></form>"
138
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_radio_field optional user_name_fr\"><div class=\"form-check\"><input type=\"radio\" name=\"user[name_fr]\" id=\"radio_1\" value=\"test1\" class=\"ui_radio_field optional form-check-input\" /><label class=\"form-check-label\" for=\"radio_1\">Radio 1</label></div></div></form>"
139
139
 
140
140
  assert_equal expected, actual
141
141
  end
@@ -237,31 +237,40 @@ test1</textarea></div></form>"
237
237
  assert_equal expected, actual
238
238
  end
239
239
 
240
- # test 'choice field' do
241
- # actual = ui_form_for @user do |f|
242
- # f.ui_choice_group do |cg|
243
- # cg.input :name_fr, as: :ui_choice_field
244
- # cg.input :name_fr, as: :ui_choice_field
245
- # end
246
- # end
247
- #
248
- # expected = "<form class=\"simple_form\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"button_group\"><div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" id=\"choice-21472\" /><label class=\"btn-secondary btn checkbox\" checked=\"checked\" for=\"choice-21472\">Name Fr</label><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" id=\"choice-13741\" /><label class=\"btn-secondary btn checkbox\" checked=\"checked\" for=\"choice-13741\">Name Fr</label></div></div></form>"
249
- #
250
- # assert_equal expected, actual
251
- # end
252
-
253
- # test 'test surround field into simple form' do
254
- # actual = ui_form_for @user do |f|
255
- # concat(f.ui_surround_field do |sf|
256
- # sf.input :name_en, as: :text_field
257
- # sf.addon("€")
258
- # end)
259
- # concat f.input(:name_fr, as: :ui_auto_complete_field, collection: @users, label_method: :name_fr)
260
- # end
261
- #
262
- # expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div><div class=\"input-group\"><input type=\"text\" name=\"user[name_en]\" id=\"user_name_en\" value=\"test1 en\" class=\"text_field optional form-control\" /><span class=\"input-group-text\">€</span></div></div><div class=\"form-group ui_auto_complete_field optional user_name_fr\"><label class=\"control-label ui_auto_complete_field optional\" for=\"user_name_fr\">Name fr</label><input type=\"text\" name=\"user[name_fr]\" id=\"user_name_fr\" value=\"test1\" class=\"ui_auto_complete_field optional form-control auto-complete-field\" autocomplete=\"true\" list=\"user_name_fr-datalist\" /><datalist id=\"user_name_fr-datalist\"><option value=\"1\">test1</option>
263
- # <option value=\"2\">test2</option></datalist></div></form>"
264
- #
265
- # assert_equal expected, actual
266
- # end
240
+ test 'ui_button_group' do
241
+ actual = ui_form_for @user do |f|
242
+ f.ui_button_group do |bg|
243
+ bg.button "test"
244
+ end
245
+ end
246
+
247
+ expected = "<form class=\"simple_form\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"button_group\"><div class=\"btn-group\" role=\"group\"><button class=\"btn-secondary btn\">test</button></div></div></form>"
248
+
249
+ assert_equal expected, actual
250
+ end
251
+
252
+ test 'ui_choice_group' do
253
+ actual = ui_form_for @user do |f|
254
+ f.ui_choice_group do |cg|
255
+ cg.input :name_fr, as: :ui_checkbox_field
256
+ end
257
+ end
258
+
259
+ expected = "<form class=\"simple_form\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"button_group\"><div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><div class=\"form-check\"><input type=\"checkbox\" name=\"user[name_fr]\" id=\"user_name_fr\" value=\"test1\" class=\"ui_checkbox_field optional form-check-input\" checked=\"checked\" /><label class=\"form-check-label\" for=\"user_name_fr\">Name Fr</label></div></div></div></form>"
260
+
261
+ assert_equal expected, actual
262
+ end
263
+
264
+ test 'test surround field into simple form' do
265
+ actual = ui_form_for @user do |f|
266
+ f.ui_surround_field do |sf|
267
+ sf.input :name_en, as: :ui_text_field
268
+ sf.addon("€")
269
+ end
270
+ end
271
+
272
+ expected = "<form class=\"simple_form\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group surround_field\"><div class=\"input-group ui_surround_field\"><input type=\"text\" name=\"user[name_en]\" id=\"user_name_en\" value=\"test1 en\" class=\"form-control string ui_text_field optional\" /><span class=\"input-group-text\">€</span></div></div></form>"
273
+
274
+ assert_equal expected, actual
275
+ end
267
276
  end
@@ -16,4 +16,18 @@ class CheckboxFieldTest < ActionView::TestCase
16
16
 
17
17
  assert_equal expected, actual
18
18
  end
19
+
20
+ test 'checkbox_field with options and html_options' do
21
+ actual = UiBibz::Ui::Core::Forms::Choices::CheckboxField.new('John', action: 'click->controller#action', label_html: { class: 'test' }, wrapper_html: { title: "My title" }).render
22
+ expected = "<div title=\"My title\" class=\"form-check\"><input type=\"checkbox\" name=\"John\" id=\"John\" value=\"1\" data-action=\"click-&gt;controller#action\" class=\"form-check-input\" /><label class=\"form-check-label test\" for=\"John\">John</label></div>"
23
+
24
+ assert_equal expected, actual
25
+ end
26
+
27
+ test 'checkbox_field with html_options' do
28
+ actual = UiBibz::Ui::Core::Forms::Choices::CheckboxField.new('John', { checked: true }, { data: { name: 'check' } }).render
29
+ expected = "<div class=\"form-check\"><input type=\"checkbox\" name=\"John\" id=\"John\" value=\"1\" data-name=\"check\" class=\"form-check-input\" checked=\"checked\" /><label class=\"form-check-label\" for=\"John\">John</label></div>"
30
+
31
+ assert_equal expected, actual
32
+ end
19
33
  end
@@ -9,4 +9,11 @@ class RadioFieldTest < ActionView::TestCase
9
9
 
10
10
  assert_equal expected, actual
11
11
  end
12
+
13
+ test 'checkbox_field with options and html_options' do
14
+ actual = UiBibz::Ui::Core::Forms::Choices::RadioField.new('John', action: 'click->controller#action', label_html: { class: 'test' }, wrapper_html: { title: "My title" }).render
15
+ expected = "<div title=\"My title\" class=\"form-check\"><input type=\"radio\" name=\"John\" id=\"John_\" data-action=\"click-&gt;controller#action\" class=\"form-check-input\" /><label class=\"form-check-label\" for=\"John_\">John</label></div>"
16
+
17
+ assert_equal expected, actual
18
+ end
12
19
  end
@@ -3,7 +3,7 @@
3
3
  require 'test_helper'
4
4
 
5
5
  class DropdownSelectFieldTest < ActionView::TestCase
6
- test 'Multi Select Field' do
6
+ test 'Dropdown Select Field' do
7
7
  options = options_for_select(Array.new(2) { |i| "option #{i}" })
8
8
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('example', multiple: true, option_tags: options).render
9
9
  expected = "<select name=\"example[]\" id=\"example\" data-dropdown-classes=\"dropdown\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"><option value=\"option 0\">option 0</option>
@@ -12,10 +12,10 @@ class DropdownSelectFieldTest < ActionView::TestCase
12
12
  assert_equal expected, actual
13
13
  end
14
14
 
15
- test 'Multi Select Field data html options' do
15
+ test 'Dropdown Select Field data html options' do
16
16
  grouped_options = { 'North America' => [['United statuss', 'US'], 'Canada'], 'Europe' => %w[Denmark Germany France] }
17
- actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('example', { multiple: true, option_tags: grouped_options_for_select(grouped_options), clickable_opt_group: true, collapsible_opt_group: true, searchable: true, select_all_options: true, number_displayed: 2, status: :danger }).render
18
- expected = "<select name=\"example[]\" id=\"example\" data-enable-clickable-opt-groups=\"true\" data-enable-collapsible-opt-groups=\"true\" data-enable-filtering=\"true\" data-include-select-all-option=\"true\" data-number-displayed=\"true\" data-dropdown-classes=\"dropdown\" class=\"btn-danger multi-select-field\" multiple=\"multiple\"><optgroup label=\"North America\"><option value=\"US\">United statuss</option>
17
+ actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('example', { multiple: true, option_tags: grouped_options_for_select(grouped_options), clickable_opt_group: true, collapsible_opt_group: true, searchable: true, non_selected_text: 'test', select_all_options: true, number_displayed: 2, status: :danger, n_selected_text: "items selected" }).render
18
+ expected = "<select name=\"example[]\" id=\"example\" data-enable-clickable-opt-groups=\"true\" data-enable-collapsible-opt-groups=\"true\" data-enable-filtering=\"true\" data-non-selected-text=\"test\" data-include-select-all-option=\"true\" data-number-displayed=\"true\" data-dropdown-classes=\"dropdown\" data-n-selected-text=\"items selected\" class=\"btn-danger multi-select-field\" multiple=\"multiple\"><optgroup label=\"North America\"><option value=\"US\">United statuss</option>
19
19
  <option value=\"Canada\">Canada</option></optgroup><optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>
20
20
  <option value=\"Germany\">Germany</option>
21
21
  <option value=\"France\">France</option></optgroup></select>"
@@ -23,7 +23,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
23
23
  assert_equal expected, actual
24
24
  end
25
25
 
26
- test 'Multi select Field refresh option' do
26
+ test 'Dropdown Select Field refresh option' do
27
27
  actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { multiple: true, refresh: { target: { url: '/' } } }).render
28
28
  expected = "<div class=\"field-refresh input-group ui_surround_field\"><select name=\"test[]\" id=\"test\" data-dropdown-classes=\"dropdown\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"></select><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&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>"
29
29
 
@@ -87,7 +87,7 @@ class SurroundFieldTest < ActionView::TestCase
87
87
  sf.button_refresh
88
88
  end.render
89
89
 
90
- expected = "<div class=\"input-group ui_surround_field\"><span class=\"input-group-text\"><i class=\"glyph fas fa-gem\"></i></span><span class=\"input-group-text\">test</span><button class=\"btn-secondary btn\">button</button><div class=\"input-group-btn\" role=\"group\"><button class=\"btn-secondary btn\">test</button></div><a class=\"btn-secondary btn\" role=\"button\" href=\"#\">link</a><div class=\"input-group-text\" label=\"false\"><input type=\"checkbox\" name=\"check\" id=\"check\" value=\"1\" class=\"form-check-input\" /><label class=\"form-check-label\" for=\"check\">check</label></div><div class=\"input-group-text\" label=\"false\"><input type=\"radio\" name=\"radio\" id=\"radio_\" class=\"form-check-input\" /><label class=\"form-check-label\" for=\"radio_\">radio</label></div><input type=\"text\" name=\"text\" id=\"text\" class=\"form-control\" /><input type=\"text\" name=\"date\" id=\"date\" data-date-locale=\"en\" data-provide=\"datepicker\" data-date-format=\"yyyy-mm-dd\" data-date-today-btn=\"linked\" data-date-toggle-active=\"true\" class=\"date_picker form-control\" /><select name=\"dropdown_select\" id=\"dropdown_select\" data-wrapper-classes=\"input-group-btn\" data-dropdown-classes=\"dropdown\" class=\"btn-secondary multi-select-field\"></select><select name=\"select\" id=\"select\" class=\"select-field form-control form-select\"></select><input type=\"text\" name=\"auto\" id=\"auto\" class=\"form-control auto-complete-field\" autocomplete=\"true\" list=\"auto-datalist\" /><datalist id=\"auto-datalist\"></datalist><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;&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>"
90
+ expected = "<div class=\"input-group ui_surround_field\"><span class=\"input-group-text\"><i class=\"glyph fas fa-gem\"></i></span><span class=\"input-group-text\">test</span><button class=\"btn-secondary btn\">button</button><div class=\"input-group-btn\" role=\"group\"><button class=\"btn-secondary btn\">test</button></div><a class=\"btn-secondary btn\" role=\"button\" href=\"#\">link</a><div class=\"form-check\"><input type=\"checkbox\" name=\"check\" id=\"check\" value=\"1\" class=\"form-check-input input-group-text\" label=\"false\" /><label class=\"form-check-label\" for=\"check\">check</label></div><div class=\"form-check\"><input type=\"radio\" name=\"radio\" id=\"radio_\" class=\"form-check-input input-group-text\" label=\"false\" /><label class=\"form-check-label\" for=\"radio_\">radio</label></div><input type=\"text\" name=\"text\" id=\"text\" class=\"form-control\" /><input type=\"text\" name=\"date\" id=\"date\" data-date-locale=\"en\" data-provide=\"datepicker\" data-date-format=\"yyyy-mm-dd\" data-date-today-btn=\"linked\" data-date-toggle-active=\"true\" class=\"date_picker form-control\" /><select name=\"dropdown_select\" id=\"dropdown_select\" data-wrapper-classes=\"input-group-btn\" data-dropdown-classes=\"dropdown\" class=\"btn-secondary multi-select-field\"></select><select name=\"select\" id=\"select\" class=\"select-field form-control form-select\"></select><input type=\"text\" name=\"auto\" id=\"auto\" class=\"form-control auto-complete-field\" autocomplete=\"true\" list=\"auto-datalist\" /><datalist id=\"auto-datalist\"></datalist><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;&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>"
91
91
 
92
92
  assert_equal expected, actual
93
93
  end
data/ui_bibz.gemspec CHANGED
@@ -47,4 +47,5 @@ Gem::Specification.new do |s|
47
47
  s.add_development_dependency 'simplecov'
48
48
  s.add_development_dependency 'simple_form'
49
49
  s.add_development_dependency 'sqlite3'
50
+ s.add_development_dependency 'yard'
50
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ui_bibz
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta11
4
+ version: 3.0.0.beta16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thooams [Thomas HUMMEL]
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -240,7 +240,21 @@ dependencies:
240
240
  - - ">="
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
- description: A Rails Interface Framework using Bootstrap 5.0.0.beta1.
243
+ - !ruby/object:Gem::Dependency
244
+ name: yard
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - ">="
255
+ - !ruby/object:Gem::Version
256
+ version: '0'
257
+ description: A Rails Interface Framework using Bootstrap 5.0.0.beta2.
244
258
  email: thomas@hummel.link
245
259
  executables:
246
260
  - test
@@ -312,6 +326,8 @@ files:
312
326
  - lib/ui_bibz/ui/base.rb
313
327
  - lib/ui_bibz/ui/concerns/card_itemable_concern.rb
314
328
  - lib/ui_bibz/ui/concerns/html_concern.rb
329
+ - lib/ui_bibz/ui/concerns/navigation_concern.rb
330
+ - lib/ui_bibz/ui/concerns/notification_concern.rb
315
331
  - lib/ui_bibz/ui/core/boxes/card.rb
316
332
  - lib/ui_bibz/ui/core/boxes/card_accordion.rb
317
333
  - lib/ui_bibz/ui/core/boxes/card_column.rb
@@ -544,8 +560,8 @@ files:
544
560
  - test/ui/core/forms/numbers/number_field_test.rb
545
561
  - test/ui/core/forms/numbers/range_field_test.rb
546
562
  - test/ui/core/forms/numbers/slider_field_test.rb
563
+ - test/ui/core/forms/selects/dropdown_select_field_test.rb
547
564
  - test/ui/core/forms/selects/multi_column_field_test.rb
548
- - test/ui/core/forms/selects/multi_select_field_test.rb
549
565
  - test/ui/core/forms/selects/select_field_test.rb
550
566
  - test/ui/core/forms/surrounds/surround_field_test.rb
551
567
  - test/ui/core/forms/textareas/markdown_editor_field_test.rb
@@ -666,7 +682,7 @@ rubygems_version: 3.1.2
666
682
  signing_key:
667
683
  specification_version: 4
668
684
  summary: Ui Bibz is an Ui Framework that allows you to build an interface very quickly
669
- and simply using Bootstrap 5.0.0.beta1.
685
+ and simply using Bootstrap 5.0.0.beta2.
670
686
  test_files:
671
687
  - test/dummy/README.rdoc
672
688
  - test/dummy/Rakefile
@@ -757,8 +773,8 @@ test_files:
757
773
  - test/ui/core/forms/numbers/number_field_test.rb
758
774
  - test/ui/core/forms/numbers/range_field_test.rb
759
775
  - test/ui/core/forms/numbers/slider_field_test.rb
776
+ - test/ui/core/forms/selects/dropdown_select_field_test.rb
760
777
  - test/ui/core/forms/selects/multi_column_field_test.rb
761
- - test/ui/core/forms/selects/multi_select_field_test.rb
762
778
  - test/ui/core/forms/selects/select_field_test.rb
763
779
  - test/ui/core/forms/surrounds/surround_field_test.rb
764
780
  - test/ui/core/forms/textareas/markdown_editor_field_test.rb