ui_bibz 3.0.0.beta8 → 3.0.0.beta13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d3e72f23a91692fcd9919939cac116b0434333c8597b11dcef0f7b8cb766d87
4
- data.tar.gz: f3b225819371ddbe82c9f2f3c84388f4e2fed1edce822e539e649e761f6224b8
3
+ metadata.gz: c8e9f704fae6975451f3f51f700ee7df8e880045c95b686065e2992b9ed027ea
4
+ data.tar.gz: 6ae209045ca11867361a63347150cf8435984976f00026b89c556fcf2dea5674
5
5
  SHA512:
6
- metadata.gz: ff3ce0988337055522cfb625287a83104691d0931219c76763e8014b0e8775496fa21312721896bc3fed30b26473f058abf2f3f7f87ea3d9cb7a19bf94409f14
7
- data.tar.gz: 64cdd3c257b47403e4ebf83ab47fb56b3c0f73136a1d4db0fbbf300925b32999b374c6054271bba50bca2b0b7da0dc37db1d9c21178c718397d1f7d6fd110ae5
6
+ metadata.gz: d387972cb0c0b4a0d4d8768782e92608876e0c90fb16a1f3895c5b130707df80901317440b5e69cfaecefebc691d03a614935d595bbcf8246664340d564923df
7
+ data.tar.gz: 5786310071a16944f8a45d3c0bb0e282cd21c151fd8513d45a8d31b5e43892e44113e8f2800a326e528b6f424b73db8952b27c508cc6ffca1e1ea063b4591027
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ui_bibz (3.0.0.beta8)
4
+ ui_bibz (3.0.0.beta13)
5
5
  will-paginate-i18n
6
6
  will_paginate (~> 3.3.0)
7
7
  will_paginate-bootstrap4
@@ -9,56 +9,56 @@ 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)
@@ -114,7 +114,7 @@ GEM
114
114
  mini_mime (1.0.2)
115
115
  mini_portile2 (2.5.0)
116
116
  minitest (5.14.3)
117
- nio4r (2.5.4)
117
+ nio4r (2.5.5)
118
118
  nokogiri (1.11.1)
119
119
  mini_portile2 (~> 2.5.0)
120
120
  racc (~> 1.4)
@@ -128,29 +128,29 @@ 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)
@@ -182,9 +182,9 @@ GEM
182
182
  ruby_parser (3.15.1)
183
183
  sexp_processor (~> 4.9)
184
184
  sexp_processor (4.15.2)
185
- simple_form (5.0.3)
186
- actionpack (>= 5.0)
187
- activemodel (>= 5.0)
185
+ simple_form (5.1.0)
186
+ actionpack (>= 5.2)
187
+ activemodel (>= 5.2)
188
188
  simplecov (0.21.2)
189
189
  docile (~> 1.1)
190
190
  simplecov-html (~> 0.11)
data/lib/ui_bibz/infos.rb CHANGED
@@ -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.beta8'
15
+ VERSION = '3.0.0.beta13'
16
16
  AUTHORS = ['Thooams'].freeze
17
17
  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
@@ -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,30 +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
- indeterminate: options[:indeterminate],
72
- "data-action": options[:action],
73
- class: UiBibz::Utils::Screwdriver.join_classes('form-check-input', input_status)
74
- }.tap do |html|
75
- 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))
76
75
  end
77
76
  end
78
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
+
79
86
  def label_name
80
87
  html_options[:id] || content
81
88
  end
@@ -92,7 +99,7 @@ module UiBibz::Ui::Core::Forms::Choices
92
99
  end
93
100
 
94
101
  def component_html_classes
95
- super << component_wrapper_html_classes
102
+ super << ['form-check-input', input_status]
96
103
  end
97
104
 
98
105
  def input_status
@@ -105,8 +112,12 @@ module UiBibz::Ui::Core::Forms::Choices
105
112
  'form-check-inline' if options[:inline]
106
113
  end
107
114
 
108
- def component_wrapper_html_classes
109
- ['form-check', inline]
115
+ def wrapper_classes
116
+ 'form-check'
117
+ end
118
+
119
+ def label_classes
120
+ 'form-check-label'
110
121
  end
111
122
  end
112
123
  end
@@ -116,5 +116,7 @@ module UiBibz::Ui::Core::Forms::Choices
116
116
  def input_id
117
117
  @input_id ||= @options[:id] || generate_id('choice')
118
118
  end
119
+
120
+ def state; end
119
121
  end
120
122
  end
@@ -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,46 +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: options[:state] == :disabled,
69
- "data-action": options[:action],
70
- class: UiBibz::Utils::Screwdriver.join_classes('form-check-input', input_status)
71
- }
72
- end
62
+ private
73
63
 
74
64
  def label_name
75
- "#{content}_#{options[:value]}"
76
- end
77
-
78
- def component_html_classes
79
- super << component_wrapper_html_classes
80
- end
81
-
82
- def status; end
83
-
84
- def input_status
85
- "form-check-input-#{options[:status]}" if options[:status]
86
- end
87
-
88
- def inline
89
- 'form-check-inline' if options[:inline]
90
- end
91
-
92
- def component_wrapper_html_classes
93
- ['form-check', inline]
65
+ html_options[:id] || "#{content}_#{options[:value]}"
94
66
  end
95
67
  end
96
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
@@ -1,12 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PopoverExtension
4
+ # Add popover to a component
5
+ #
6
+ # By tooltip object
7
+ #
8
+ # popover = UiBibz::Ui::Core::Notifications::Popover.new("My Popover")
9
+ # UiBibz::Ui::Core::Component.new("My content", popover: popover)
10
+ #
11
+ # By Hash
12
+ #
13
+ # UiBibz::Ui::Core::Component.new("My content", popover: { content: "My Popover" })
14
+ #
15
+ # By String
16
+ #
17
+ # UiBibz::Ui::Core::Component.new("My content", popover: "My Popover")
18
+ #
4
19
  def popover_data_html
5
20
  return if options[:popover].nil?
6
21
 
7
22
  html_options.update(generate_popover.render)
8
23
  end
9
24
 
25
+ # Add tooltip to a component
26
+ #
27
+ # By tooltip object
28
+ #
29
+ # tooltip = UiBibz::Ui::Core::Notifications::Tooltip.new("My tooltip")
30
+ # UiBibz::Ui::Core::Component.new("My content", tooltip: tooltip)
31
+ #
32
+ # By Boolean
33
+ #
34
+ # UiBibz::Ui::Core::Component.new("My content", tooltip: true)
35
+ # # or
36
+ # UiBibz::Ui::Core::Component.new("My content", {tooltip: true}, { title: 'My tooltip' })
37
+ #
38
+ # By Hash
39
+ #
40
+ # UiBibz::Ui::Core::Component.new("My content", tooltip: { title: 'My tooltip' })
41
+ #
10
42
  def tooltip_data_html
11
43
  return if options[:tooltip].nil?
12
44
 
@@ -20,7 +52,8 @@ module PopoverExtension
20
52
  when 'UiBibz::Ui::Core::Notifications::Tooltip'
21
53
  options[:tooltip]
22
54
  when 'TrueClass'
23
- UiBibz::Ui::Core::Notifications::Tooltip.new(html_options.delete(:title))
55
+ tooltip_content = html_options.delete(:title) || (sanitize_text(content) if options[:text] == false)
56
+ UiBibz::Ui::Core::Notifications::Tooltip.new(tooltip_content)
24
57
  else
25
58
  UiBibz::Ui::Core::Notifications::Tooltip.new(options[:tooltip])
26
59
  end
@@ -35,7 +35,7 @@ module UiBibz::Ui::Ux::Tables
35
35
 
36
36
  return if default_actions? != true && @actions.raw_list.empty?
37
37
 
38
- UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new(dropdown_action_name, { position: :right, size: :sm, glyph: actions_glyph }, { class: 'dropdown-action' }).tap do |d|
38
+ UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.new(dropdown_action_name, { size: :sm, glyph: actions_glyph }, { class: 'dropdown-action' }).tap do |d|
39
39
  actions_links(record).each do |l|
40
40
  d.html l.to_s.html_safe
41
41
  end
@@ -42,7 +42,8 @@ module UiBibz::Ui::Ux::Tables
42
42
  # * +size+
43
43
  # (+:sm+)
44
44
  # * +responsive+ - Boolean
45
- # * +reflow+ - Boolean
45
+ # * +breakpoint+
46
+ # (+:sm+, +:md+, +:lg+, +:xl+, +:xxl+)
46
47
  #
47
48
  # ==== Signatures
48
49
  #
@@ -118,7 +119,7 @@ module UiBibz::Ui::Ux::Tables
118
119
 
119
120
  # Render html tag
120
121
  def pre_render
121
- table_html
122
+ options[:responsive] ? content_tag(:div, table_html, class: responsive) : table_html
122
123
  end
123
124
 
124
125
  # Store must be generated by *table_search_pagination* method
@@ -184,7 +185,7 @@ module UiBibz::Ui::Ux::Tables
184
185
  private
185
186
 
186
187
  def component_html_classes
187
- ['table', striped, bordered, hoverable, size, responsive, reflow]
188
+ ['table', striped, bordered, hoverable, size]
188
189
  end
189
190
 
190
191
  def status
@@ -208,11 +209,7 @@ module UiBibz::Ui::Ux::Tables
208
209
  end
209
210
 
210
211
  def responsive
211
- 'table-responsive' unless @options[:responsive].nil?
212
- end
213
-
214
- def reflow
215
- 'table-reflow' unless @options[:reflow].nil?
212
+ ['table-responsive', @options[:breakpoint]].compact.join('-') unless @options[:responsive].nil?
216
213
  end
217
214
  end
218
215
  end
@@ -32,7 +32,8 @@ module UiBibz::Ui::Ux::Tables
32
32
  # * +size+
33
33
  # (+sm+)
34
34
  # * +responsive+ - Boolean
35
- # * +reflow+ - Boolean
35
+ # * +breakpoint+
36
+ # (+:sm+, +:md+, +:lg+, +:xl+, +:xxl+)
36
37
  #
37
38
  #
38
39
  # ==== Signatures
@@ -21,6 +21,16 @@ class SimpleFormTest < ActionView::TestCase
21
21
  @user = @users.first
22
22
  end
23
23
 
24
+ test 'simple form input' do
25
+ actual = simple_form_for @user do |f|
26
+ f.input :name_fr
27
+ end
28
+
29
+ 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 string optional user_name_fr\"><label class=\"control-label string optional\" for=\"user_name_fr\">Name fr</label><input class=\"form-control string optional\" type=\"text\" value=\"test1\" name=\"user[name_fr]\" id=\"user_name_fr\" /></div></form>"
30
+
31
+ assert_equal expected, actual
32
+ end
33
+
24
34
  test 'auto complete field input in simple form' do
25
35
  actual = simple_form_for @user do |f|
26
36
  f.input :name_fr, as: :ui_auto_complete_field, collection: @users, label_method: :name_fr
@@ -122,10 +132,10 @@ test1</textarea></div></form>"
122
132
 
123
133
  test 'radio field input in simple form' do
124
134
  actual = simple_form_for @user do |f|
125
- 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" }
126
136
  end
127
137
 
128
- 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>"
129
139
 
130
140
  assert_equal expected, actual
131
141
  end
@@ -16,4 +16,11 @@ 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
19
26
  end
@@ -11,7 +11,7 @@ class ChoiceGroupTest < ActionView::TestCase
11
11
  bc.choice 'Checkbox 2', state: :active
12
12
  end
13
13
 
14
- expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-secondary btn\" for=\"#{actual.items.first.input_options[:id]}\">Checkbox 1</label><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"active btn-secondary btn\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Checkbox 2</label></div>"
14
+ expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-secondary btn\" for=\"#{actual.items.first.input_options[:id]}\">Checkbox 1</label><input type=\"checkbox\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"btn-secondary btn\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Checkbox 2</label></div>"
15
15
 
16
16
  assert_equal expected, actual.render
17
17
  end
@@ -22,7 +22,7 @@ class ChoiceGroupTest < ActionView::TestCase
22
22
  bc.choice 'Radio 2', state: :active
23
23
  end
24
24
 
25
- expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" name=\"#{actual.items.first.input_options[:name]}\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-secondary btn\" for=\"#{actual.items.first.input_options[:id]}\">Radio 1</label><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" name=\"#{actual.items.last.input_options[:name]}\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"active btn-secondary btn\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Radio 2</label></div>"
25
+ expected = "<div data-toggle=\"buttons\" class=\"btn-group button-choice btn-group-toggle\"><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" name=\"#{actual.items.first.input_options[:name]}\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-secondary btn\" for=\"#{actual.items.first.input_options[:id]}\">Radio 1</label><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" name=\"#{actual.items.last.input_options[:name]}\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"btn-secondary btn\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Radio 2</label></div>"
26
26
 
27
27
  assert_equal expected, actual.render
28
28
  end
@@ -32,7 +32,7 @@ class ChoiceGroupTest < ActionView::TestCase
32
32
  bc.choice 'Radio 1', glyph: 'diamond', status: :primary
33
33
  bc.choice 'Radio 2', state: :active
34
34
  end
35
- expected = "<div data-toggle=\"buttons\" class=\"btn-group btn-group-lg button-choice btn-group-toggle\"><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" name=\"#{actual.items.first.input_options[:name]}\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-outline-primary btn btn-lg\" for=\"#{actual.items.first.input_options[:id]}\"><i class=\"glyph fas fa-diamond\"></i> Radio 1</label><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" name=\"#{actual.items.last.input_options[:name]}\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"active btn-outline-secondary btn btn-lg\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Radio 2</label></div>"
35
+ expected = "<div data-toggle=\"buttons\" class=\"btn-group btn-group-lg button-choice btn-group-toggle\"><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" name=\"#{actual.items.first.input_options[:name]}\" id=\"#{actual.items.first.input_options[:id]}\" /><label class=\"btn-outline-primary btn btn-lg\" for=\"#{actual.items.first.input_options[:id]}\"><i class=\"glyph fas fa-diamond\"></i> Radio 1</label><input type=\"radio\" autocomplete=\"off\" class=\"btn-check\" checked=\"checked\" name=\"#{actual.items.last.input_options[:name]}\" id=\"#{actual.items.last.input_options[:id]}\" /><label class=\"btn-outline-secondary btn btn-lg\" aria-pressed=\"true\" for=\"#{actual.items.last.input_options[:id]}\">Radio 2</label></div>"
36
36
 
37
37
  assert_equal expected, actual.render
38
38
  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
@@ -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
@@ -49,4 +49,11 @@ class PopoverTest < ActionView::TestCase
49
49
 
50
50
  assert_equal expected, actual
51
51
  end
52
+
53
+ test 'glyph with popover String' do
54
+ actual = UiBibz::Ui::Core::Icons::Glyph.new("diamond", popover: "My Content").render
55
+ expected = "<i data-bs-toggle=\"popover\" data-bs-content=\"My Content\" class=\"glyph fas fa-diamond\"></i>"
56
+
57
+ assert_equal expected, actual
58
+ end
52
59
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ require 'ui_bibz/ui/ux/tables/components/store'
5
+ require 'ui_bibz/ui/ux/tables/extensions/paginable'
6
+ require 'ui_bibz/ui/ux/tables/extensions/searchable'
7
+ require 'ui_bibz/ui/ux/tables/extensions/sortable'
8
+ require 'ui_bibz/ui/ux/tables/extensions/actionable'
9
+
10
+ class TableCardTest < ActionView::TestCase
11
+ setup do
12
+ create_list(:user, 25)
13
+ params = ActionController::Parameters.new({
14
+ controller: 'users',
15
+ action: 'index',
16
+ sort: 'users.name_fr',
17
+ direction: 'asc',
18
+ search: 'Name fr',
19
+ per_page: 2,
20
+ page: 1,
21
+ only_path: true
22
+ })
23
+ @users = User.table_search_pagination(params, session)
24
+ @store = UiBibz::Ui::Ux::Tables::Store.new @users
25
+ end
26
+
27
+ test 'table card visual options' do
28
+ table_card = UiBibz::Ui::Ux::Tables::TableCard.new(store: @users, table_options: { striped: true, status: :inverse, responsive: true, bordered: true, size: :sm, hoverable: true, breakpoint: :sm }).render
29
+ actual_table_classes = Nokogiri::HTML(table_card).xpath('//table')[0].attributes['class'].value
30
+ div_classes = Nokogiri::HTML(table_card).xpath('//div').css('.table-responsive-sm')[0].attributes['class'].value
31
+ table_classes = 'table-inverse table table-striped table-bordered table-hoverable table-sm'
32
+ actual_div_classes = 'table-responsive-sm'
33
+
34
+ assert_equal table_classes, actual_table_classes
35
+ assert_equal div_classes, actual_div_classes
36
+ end
37
+ end
@@ -195,11 +195,14 @@ class TableTest < ActionView::TestCase
195
195
  end
196
196
 
197
197
  test 'table visual options' do
198
- table = UiBibz::Ui::Ux::Tables::Table.new(store: @users, striped: true, status: :inverse, responsive: true, bordered: true, size: :sm, hoverable: true, reflow: true).render
199
- actual = Nokogiri::HTML(table).xpath('//table')[0].attributes['class'].value
200
- expected = 'table-inverse table table-striped table-bordered table-hoverable table-sm table-responsive table-reflow'
201
-
202
- assert_equal expected, actual
198
+ table = UiBibz::Ui::Ux::Tables::Table.new(store: @users, striped: true, status: :inverse, responsive: true, bordered: true, size: :sm, hoverable: true, breakpoint: :sm).render
199
+ div_classes = Nokogiri::HTML(table).xpath('//div')[0].attributes['class'].value
200
+ actual_table_classes = Nokogiri::HTML(table).xpath('//table')[0].attributes['class'].value
201
+ table_classes = 'table-inverse table table-striped table-bordered table-hoverable table-sm'
202
+ actual_div_classes = 'table-responsive-sm'
203
+
204
+ assert_equal table_classes, actual_table_classes
205
+ assert_equal div_classes, actual_div_classes
203
206
  end
204
207
 
205
208
  test 'table thead visual options' do
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.beta8
4
+ version: 3.0.0.beta13
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-05 00:00:00.000000000 Z
11
+ date: 2021-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -574,6 +574,7 @@ files:
574
574
  - test/ui/core/windows/modal_test.rb
575
575
  - test/ui/utils/breakdown_class_name_generator_test.rb
576
576
  - test/ui/ux/containers/panel_test.rb
577
+ - test/ui/ux/tables/table_card_test.rb
577
578
  - test/ui/ux/tables/table_test.rb
578
579
  - test/ui_bibz_test.rb
579
580
  - ui_bibz.gemspec
@@ -786,5 +787,6 @@ test_files:
786
787
  - test/ui/core/windows/modal_test.rb
787
788
  - test/ui/utils/breakdown_class_name_generator_test.rb
788
789
  - test/ui/ux/containers/panel_test.rb
790
+ - test/ui/ux/tables/table_card_test.rb
789
791
  - test/ui/ux/tables/table_test.rb
790
792
  - test/ui_bibz_test.rb