ui_bibz 3.0.0.beta11 → 3.0.0.beta12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +51 -51
- data/lib/ui_bibz/infos.rb +1 -1
- data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +22 -20
- data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +18 -28
- data/test/simple_form_test.rb +1 -1
- data/test/ui/core/forms/choices/checkbox_field_test.rb +7 -0
- data/test/ui/core/forms/choices/radio_field_test.rb +7 -0
- data/test/ui/core/forms/surrounds/surround_field_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50692a30f39e9110cec4b66aca482aac06b5954f6785350c66e0e3f5b34fb79f
|
4
|
+
data.tar.gz: 1dcf3b39d353062f5ba6e5265339a98474f78e0fa74b7822f1269db13a036c52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ea403acad7678809350b802ebaab7f3c96b13daa26c3637b46c3b40da038930b2a0a921b96efb7f044bc562d4604ab57c0826781d88bb73b0b2b458f3f76b52
|
7
|
+
data.tar.gz: 1b22114c6aaf66f7de20b8dfd80e8e790eea1a07e1695a3ba31f7c26a95fd30d404babc9981332731605c2015733fa03dd570bb719c4689ba7430102efa6f791
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ui_bibz (3.0.0.
|
4
|
+
ui_bibz (3.0.0.beta12)
|
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.
|
13
|
-
actionpack (= 6.0.3.
|
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.
|
17
|
-
actionpack (= 6.0.3.
|
18
|
-
activejob (= 6.0.3.
|
19
|
-
activerecord (= 6.0.3.
|
20
|
-
activestorage (= 6.0.3.
|
21
|
-
activesupport (= 6.0.3.
|
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.
|
24
|
-
actionpack (= 6.0.3.
|
25
|
-
actionview (= 6.0.3.
|
26
|
-
activejob (= 6.0.3.
|
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.
|
30
|
-
actionview (= 6.0.3.
|
31
|
-
activesupport (= 6.0.3.
|
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.
|
37
|
-
actionpack (= 6.0.3.
|
38
|
-
activerecord (= 6.0.3.
|
39
|
-
activestorage (= 6.0.3.
|
40
|
-
activesupport (= 6.0.3.
|
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.
|
43
|
-
activesupport (= 6.0.3.
|
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.
|
49
|
-
activesupport (= 6.0.3.
|
48
|
+
activejob (6.0.3.5)
|
49
|
+
activesupport (= 6.0.3.5)
|
50
50
|
globalid (>= 0.3.6)
|
51
|
-
activemodel (6.0.3.
|
52
|
-
activesupport (= 6.0.3.
|
53
|
-
activerecord (6.0.3.
|
54
|
-
activemodel (= 6.0.3.
|
55
|
-
activesupport (= 6.0.3.
|
56
|
-
activestorage (6.0.3.
|
57
|
-
actionpack (= 6.0.3.
|
58
|
-
activejob (= 6.0.3.
|
59
|
-
activerecord (= 6.0.3.
|
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.
|
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)
|
@@ -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.
|
132
|
-
actioncable (= 6.0.3.
|
133
|
-
actionmailbox (= 6.0.3.
|
134
|
-
actionmailer (= 6.0.3.
|
135
|
-
actionpack (= 6.0.3.
|
136
|
-
actiontext (= 6.0.3.
|
137
|
-
actionview (= 6.0.3.
|
138
|
-
activejob (= 6.0.3.
|
139
|
-
activemodel (= 6.0.3.
|
140
|
-
activerecord (= 6.0.3.
|
141
|
-
activestorage (= 6.0.3.
|
142
|
-
activesupport (= 6.0.3.
|
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.
|
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.
|
152
|
-
actionpack (= 6.0.3.
|
153
|
-
activesupport (= 6.0.3.
|
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)
|
data/lib/ui_bibz/infos.rb
CHANGED
@@ -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
|
-
|
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
|
61
|
-
|
62
|
-
|
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('form-check', inline, options[:wrapper_html].try(:[], :class))
|
65
69
|
end
|
66
70
|
end
|
67
71
|
|
68
|
-
def
|
69
|
-
{
|
70
|
-
|
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('form-check-label', 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 <<
|
102
|
+
super << ['form-check-input', input_status]
|
97
103
|
end
|
98
104
|
|
99
105
|
def input_status
|
@@ -105,9 +111,5 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
105
111
|
def inline
|
106
112
|
'form-check-inline' if options[:inline]
|
107
113
|
end
|
108
|
-
|
109
|
-
def component_wrapper_html_classes
|
110
|
-
['form-check', inline]
|
111
|
-
end
|
112
114
|
end
|
113
115
|
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,11 +53,26 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
51
53
|
|
52
54
|
# Render html tag
|
53
55
|
def pre_render
|
54
|
-
|
56
|
+
content_tag :div, wrapper_html_options do
|
57
|
+
concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
|
58
|
+
concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
|
59
|
+
end
|
55
60
|
end
|
56
61
|
|
57
62
|
private
|
58
63
|
|
64
|
+
def wrapper_html_options
|
65
|
+
(options[:wrapper_html] || {}).tap do |option|
|
66
|
+
option[:class] = UiBibz::Utils::Screwdriver.join_classes('form-check', inline, options[:wrapper_html].try(:[], :class))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def label_html_options
|
71
|
+
(options[:label_html] || {}).tap do |option|
|
72
|
+
option[:class] = UiBibz::Utils::Screwdriver.join_classes('form-check-label', options[:label_html].try(:[], :class))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
59
76
|
def radio_field_html_tag
|
60
77
|
content_tag :div, html_options.except(:id) do
|
61
78
|
concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
|
@@ -63,35 +80,8 @@ module UiBibz::Ui::Core::Forms::Choices
|
|
63
80
|
end
|
64
81
|
end
|
65
82
|
|
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
|
74
|
-
|
75
83
|
def label_name
|
76
84
|
"#{content}_#{options[:value]}"
|
77
85
|
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]
|
95
|
-
end
|
96
86
|
end
|
97
87
|
end
|
data/test/simple_form_test.rb
CHANGED
@@ -135,7 +135,7 @@ test1</textarea></div></form>"
|
|
135
135
|
f.input :name_fr, as: :ui_radio_field, collection: @users, label_method: :name_fr
|
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\"><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\"><input class=\"ui_radio_field optional form-check-input\" 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\"><input class=\"ui_radio_field optional form-check-input\" 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>"
|
139
139
|
|
140
140
|
assert_equal expected, actual
|
141
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->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
|
@@ -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->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=\"
|
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=\"{"events":"click","mode":"remote","target":{"selector":"","url":"","data":[]}}\" 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
|
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.
|
4
|
+
version: 3.0.0.beta12
|
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-
|
11
|
+
date: 2021-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|