ui_bibz 2.1.6 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -10
- data/app/assets/javascripts/interface.coffee +8 -0
- data/app/assets/javascripts/ui_bibz.coffee.erb +3 -0
- data/app/assets/stylesheets/fix_addon.sass +2 -2
- data/lib/ui_bibz.rb +8 -0
- data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +35 -0
- data/lib/ui_bibz/infos.rb +2 -2
- data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_box_switch_field_input.rb +18 -0
- data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_file_field_input.rb +10 -0
- data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_range_field_input.rb +10 -0
- data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_switch_field_input.rb +5 -1
- data/lib/ui_bibz/ui/core/component.rb +4 -0
- data/lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb +141 -0
- data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +18 -27
- data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +15 -40
- data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +11 -95
- data/lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb +25 -0
- data/lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb +5 -1
- data/lib/ui_bibz/ui/core/forms/files/file_field.rb +72 -0
- data/lib/ui_bibz/ui/core/forms/numbers/number_field.rb +15 -0
- data/lib/ui_bibz/ui/core/forms/numbers/range_field.rb +66 -0
- data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +9 -1
- data/lib/ui_bibz/ui/core/forms/texts/text_field.rb +3 -0
- data/test/simple_form_test.rb +33 -3
- data/test/ui/core/forms/choices/{switch_field_test.rb → box_switch_field_test.rb} +21 -21
- data/test/ui/core/forms/choices/checkbox_field_test.rb +1 -1
- data/test/ui/core/forms/choices/radio_field_test.rb +1 -1
- data/test/ui/core/forms/files/text_field_test.rb +11 -0
- data/test/ui/core/forms/numbers/number_field_test.rb +18 -0
- data/test/ui/core/forms/numbers/range_field_test.rb +18 -0
- data/vendor/assets/javascripts/bs-custom-file-input.min.js +7 -0
- metadata +19 -6
@@ -17,6 +17,11 @@ module UiBibz::Ui::Core::Forms::Numbers
|
|
17
17
|
# You can pass arguments in options attribute:
|
18
18
|
# * +prepend+ - String, Html
|
19
19
|
# * +append+ - String, Html
|
20
|
+
# * +max+ - [Float, Integer]
|
21
|
+
# * +min+ - [Float, Integer]
|
22
|
+
# * +step+ - [Float, Integer]
|
23
|
+
# * +in+ - Array
|
24
|
+
# * +within+ - Array
|
20
25
|
#
|
21
26
|
# ==== Signatures
|
22
27
|
#
|
@@ -59,5 +64,15 @@ module UiBibz::Ui::Core::Forms::Numbers
|
|
59
64
|
number_field_tag content, options[:value] || html_options[:value], html_options
|
60
65
|
end
|
61
66
|
|
67
|
+
def component_html_options
|
68
|
+
{
|
69
|
+
min: options[:min],
|
70
|
+
max: options[:max],
|
71
|
+
step: options[:step],
|
72
|
+
in: options[:in],
|
73
|
+
within: options[:within]
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
62
77
|
end
|
63
78
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module UiBibz::Ui::Core::Forms::Numbers
|
2
|
+
|
3
|
+
# Create a RangeField
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Core::Component.
|
6
|
+
#
|
7
|
+
# ==== Attributes
|
8
|
+
#
|
9
|
+
# * +content+ - Content of element
|
10
|
+
# * +options+ - Options of element
|
11
|
+
# * +html_options+ - Html Options of element
|
12
|
+
#
|
13
|
+
# ==== Options
|
14
|
+
#
|
15
|
+
# You can add HTML attributes using the +html_options+.
|
16
|
+
# You can pass arguments in options attribute:
|
17
|
+
# * +max+ - [Float, Integer]
|
18
|
+
# * +min+ - [Float, Integer]
|
19
|
+
# * +step+ - [Float, Integer]
|
20
|
+
# * +in+ - Array
|
21
|
+
# * +within+ - Array
|
22
|
+
#
|
23
|
+
# ==== Signatures
|
24
|
+
#
|
25
|
+
# UiBibz::Ui::Core::Forms::Numbers::RangeField.new(content, options = {}, html_options = {}).render
|
26
|
+
#
|
27
|
+
# UiBibz::Ui::Core::Forms::Numbers::RangeField.new(options = {}, html_options = {}) do
|
28
|
+
# content
|
29
|
+
# end.render
|
30
|
+
#
|
31
|
+
# ==== Examples
|
32
|
+
#
|
33
|
+
# UiBibz::Ui::Core::Forms::Numbers::RangeField.new(4, max: 20, min: 0, step: 2)
|
34
|
+
#
|
35
|
+
# UiBibz::Ui::Core::Forms::Numbers::RangeField.new(max: 2, min: -3, step: 0.5) do
|
36
|
+
# 5
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# ==== Helper
|
40
|
+
#
|
41
|
+
# ui_range_field(content, options = {}, html_options = {})
|
42
|
+
#
|
43
|
+
# ui_range_field(options = {}, html_options = {}) do
|
44
|
+
# # content
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
class RangeField < UiBibz::Ui::Core::Forms::Numbers::NumberField
|
48
|
+
|
49
|
+
# See UiBibz::Ui::Core::Component.initialize
|
50
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
# Render html tag
|
55
|
+
def pre_render
|
56
|
+
range_field_tag content, options[:value] || html_options[:value], html_options
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def component_html_classes
|
62
|
+
'custom-range'
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -69,7 +69,7 @@ module UiBibz::Ui::Core::Forms::Selects
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def component_html_classes
|
72
|
-
super << [size, type, status, 'multi-select-field']
|
72
|
+
super << [size, type, status, button_outline, 'multi-select-field']
|
73
73
|
end
|
74
74
|
|
75
75
|
def component_html_data
|
@@ -114,5 +114,13 @@ module UiBibz::Ui::Core::Forms::Selects
|
|
114
114
|
"btn-#{ options[:size] }" if options[:size]
|
115
115
|
end
|
116
116
|
|
117
|
+
def button_outline
|
118
|
+
["btn", outline, @status || :secondary].compact.join('-')
|
119
|
+
end
|
120
|
+
|
121
|
+
def outline
|
122
|
+
"outline" if @options[:outline]
|
123
|
+
end
|
124
|
+
|
117
125
|
end
|
118
126
|
end
|
data/test/simple_form_test.rb
CHANGED
@@ -136,10 +136,10 @@ test1</textarea></div></form>"
|
|
136
136
|
test 'switch field input in simple form' do
|
137
137
|
@user.active = true
|
138
138
|
actual = simple_form_for @user do |f|
|
139
|
-
f.input :active, as: :
|
139
|
+
f.input :active, as: :ui_box_switch_field, collection: @users, label_method: :name_fr
|
140
140
|
end
|
141
141
|
|
142
|
-
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group
|
142
|
+
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_box_switch_field optional user_active\"><label class=\"control-label ui_box_switch_field optional\" for=\"user_active\">Active</label><div class=\"switch-field-container\"><input type=\"hidden\" name=\"user[active]\" id=\"user_active\" value=\"0\" /><input type=\"checkbox\" name=\"user[active]\" id=\"user_active\" value=\"1\" class=\"ui_box_switch_field optional switch-field\" checked=\"checked\" /></div></div></form>"
|
143
143
|
|
144
144
|
assert_equal expected, actual
|
145
145
|
end
|
@@ -149,7 +149,7 @@ test1</textarea></div></form>"
|
|
149
149
|
f.input :name_fr, as: :ui_radio_field, collection: @users, label_method: :name_fr
|
150
150
|
end
|
151
151
|
|
152
|
-
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><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
|
152
|
+
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><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 custom-control custom-radio\"><input class=\"ui_radio_field optional custom-control custom-radio\" 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 custom-control custom-radio\"><input class=\"ui_radio_field optional custom-control custom-radio\" 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>"
|
153
153
|
|
154
154
|
assert_equal expected, actual
|
155
155
|
end
|
@@ -214,6 +214,36 @@ test1</textarea></div></form>"
|
|
214
214
|
assert_equal expected, actual
|
215
215
|
end
|
216
216
|
|
217
|
+
test 'number field' do
|
218
|
+
actual = simple_form_for @user do |f|
|
219
|
+
f.input :name_fr, as: :ui_number_field
|
220
|
+
end
|
221
|
+
|
222
|
+
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_number_field optional user_name_fr\"><label class=\"control-label ui_number_field optional\" for=\"user_name_fr\">Name fr</label><input type=\"number\" name=\"user[name_fr]\" id=\"user_name_fr\" value=\"test1\" class=\"ui_number_field optional form-control\" /></div></form>"
|
223
|
+
|
224
|
+
assert_equal expected, actual
|
225
|
+
end
|
226
|
+
|
227
|
+
test 'file field' do
|
228
|
+
actual = simple_form_for @user do |f|
|
229
|
+
f.input :name_fr, as: :ui_file_field
|
230
|
+
end
|
231
|
+
|
232
|
+
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_file_field optional user_name_fr\"><label class=\"control-label ui_file_field optional\" for=\"user_name_fr\">Name fr</label><div class=\"ui_file_field optional custom-file\"><input type=\"file\" name=\"user[name_fr]\" id=\"user_name_fr\" class=\"custom-file-input\" /><label class=\"custom-file-label\" for=\"user_name_fr\">test1</label></div></div></form>"
|
233
|
+
|
234
|
+
assert_equal expected, actual
|
235
|
+
end
|
236
|
+
|
237
|
+
test 'range field' do
|
238
|
+
actual = simple_form_for @user do |f|
|
239
|
+
f.input :name_fr, as: :ui_range_field
|
240
|
+
end
|
241
|
+
|
242
|
+
expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_range_field optional user_name_fr\"><label class=\"control-label ui_range_field optional\" for=\"user_name_fr\">Name fr</label><input type=\"range\" name=\"user[name_fr]\" id=\"user_name_fr\" value=\"test1\" class=\"ui_range_field optional custom-range\" /></div></form>"
|
243
|
+
|
244
|
+
assert_equal expected, actual
|
245
|
+
end
|
246
|
+
|
217
247
|
# test 'test surround field into simple form' do
|
218
248
|
# actual = ui_form_for @user do |f|
|
219
249
|
# concat(f.ui_surround_field do |sf|
|
@@ -1,82 +1,82 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class BoxBoxSwitchFieldTest < ActionView::TestCase
|
4
4
|
|
5
5
|
# OK
|
6
|
-
test '
|
7
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
6
|
+
test 'box_switch_field size' do
|
7
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', size: :lg).render
|
8
8
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" data-size=\"large\" class=\"switch-field\" /></div>"
|
9
9
|
|
10
10
|
assert_equal expected, actual
|
11
11
|
end
|
12
12
|
|
13
13
|
# OK
|
14
|
-
test '
|
15
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
14
|
+
test 'box_switch_field animate' do
|
15
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', animate: false).render
|
16
16
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" data-animate=\"false\" class=\"switch-field\" /></div>"
|
17
17
|
|
18
18
|
assert_equal expected, actual
|
19
19
|
end
|
20
20
|
|
21
21
|
# OK
|
22
|
-
test '
|
23
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
22
|
+
test 'box_switch_field checked' do
|
23
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', {}, checked: true).render
|
24
24
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" checked=\"checked\" class=\"switch-field\" /></div>"
|
25
25
|
|
26
26
|
assert_equal expected, actual
|
27
27
|
end
|
28
28
|
|
29
29
|
# OK
|
30
|
-
test '
|
31
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
30
|
+
test 'box_switch_field state' do
|
31
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', {}, state: "disabled").render
|
32
32
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" state=\"disabled\" class=\"switch-field\" /></div>"
|
33
33
|
|
34
34
|
assert_equal expected, actual
|
35
35
|
end
|
36
36
|
|
37
37
|
# NON FONCTIONNEL
|
38
|
-
test '
|
39
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
38
|
+
test 'box_switch_field readonly' do
|
39
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', {}, readonly: true).render
|
40
40
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" readonly=\"readonly\" class=\"switch-field\" /></div>"
|
41
41
|
|
42
42
|
assert_equal expected, actual
|
43
43
|
end
|
44
44
|
|
45
45
|
# OK
|
46
|
-
test '
|
47
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
46
|
+
test 'box_switch_field left_color' do
|
47
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', left_color: "success").render
|
48
48
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" data-on-color=\"success\" class=\"switch-field\" /></div>"
|
49
49
|
|
50
50
|
assert_equal expected, actual
|
51
51
|
end
|
52
52
|
|
53
53
|
# OK
|
54
|
-
test '
|
55
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
54
|
+
test 'box_switch_field right_color' do
|
55
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', right_color: "info").render
|
56
56
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" data-off-color=\"info\" class=\"switch-field\" /></div>"
|
57
57
|
|
58
58
|
assert_equal expected, actual
|
59
59
|
end
|
60
60
|
|
61
61
|
# OK
|
62
|
-
test '
|
63
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
62
|
+
test 'box_switch_field middle_text' do
|
63
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', middle_text: "testlabeltext").render
|
64
64
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" data-label-text=\"testlabeltext\" class=\"switch-field\" /></div>"
|
65
65
|
|
66
66
|
assert_equal expected, actual
|
67
67
|
end
|
68
68
|
|
69
69
|
# OK
|
70
|
-
test '
|
71
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
70
|
+
test 'box_switch_field left_text' do
|
71
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', left_text: 'testonlabel').render
|
72
72
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" data-on-text=\"testonlabel\" class=\"switch-field\" /></div>"
|
73
73
|
|
74
74
|
assert_equal expected, actual
|
75
75
|
end
|
76
76
|
|
77
77
|
# OK
|
78
|
-
test '
|
79
|
-
actual = UiBibz::Ui::Core::Forms::Choices::
|
78
|
+
test 'box_switch_field right_text' do
|
79
|
+
actual = UiBibz::Ui::Core::Forms::Choices::BoxSwitchField.new('test', right_text: "testofflabel").render
|
80
80
|
expected = "<div class=\"switch-field-container\"><input type=\"hidden\" name=\"test\" id=\"test\" value=\"0\" /><input type=\"checkbox\" name=\"test\" id=\"test\" value=\"1\" data-off-text=\"testofflabel\" class=\"switch-field\" /></div>"
|
81
81
|
|
82
82
|
assert_equal expected, actual
|
@@ -4,7 +4,7 @@ class CheckboxFieldTest < ActionView::TestCase
|
|
4
4
|
|
5
5
|
test 'checkbox_field' do
|
6
6
|
actual = UiBibz::Ui::Core::Forms::Choices::CheckboxField.new('John', { value: 1, status: :primary, type: :circle }).render
|
7
|
-
expected = "<div class=\"
|
7
|
+
expected = "<div class=\"custom-control custom-checkbox\"><input type=\"hidden\" name=\"John\" id=\"John-hidden\" value=\"0\" /><input type=\"checkbox\" name=\"John\" id=\"John\" value=\"1\" class=\"custom-control-input\" /><label class=\"custom-control-label\" for=\"John\">John</label></div>"
|
8
8
|
|
9
9
|
assert_equal expected, actual
|
10
10
|
end
|
@@ -4,7 +4,7 @@ class RadioFieldTest < ActionView::TestCase
|
|
4
4
|
|
5
5
|
test 'radio_field' do
|
6
6
|
actual = UiBibz::Ui::Core::Forms::Choices::RadioField.new('John', { value: 1, status: :primary, type: :square }).render
|
7
|
-
expected = "<div class=\"
|
7
|
+
expected = "<div class=\"custom-control custom-radio\"><input type=\"radio\" name=\"John\" id=\"John_1\" value=\"1\" class=\"custom-control-input\" /><label class=\"custom-control-label\" for=\"John_1\">John</label></div>"
|
8
8
|
|
9
9
|
assert_equal expected, actual
|
10
10
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TextFieldTest < ActionView::TestCase
|
4
|
+
|
5
|
+
test 'file_field' do
|
6
|
+
actual = UiBibz::Ui::Core::Forms::Files::FileField.new('test').render
|
7
|
+
expected = "<div class=\"custom-file\"><input type=\"file\" name=\"test\" id=\"test\" class=\"custom-file-input\" /><label class=\"custom-file-label\" for=\"test\"></label></div>"
|
8
|
+
|
9
|
+
assert_equal expected, actual
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class NumberFieldTest < ActionView::TestCase
|
4
|
+
|
5
|
+
test 'number_field' do
|
6
|
+
actual = UiBibz::Ui::Core::Forms::Numbers::NumberField.new('mynumber').render
|
7
|
+
expected = "<input type=\"number\" name=\"mynumber\" id=\"mynumber\" class=\"form-control\" />"
|
8
|
+
|
9
|
+
assert_equal expected, actual
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'number_field with options' do
|
13
|
+
actual = UiBibz::Ui::Core::Forms::Numbers::NumberField.new('mynumber', value: 5, min: -9, max: 6, step: 0.2).render
|
14
|
+
expected = "<input type=\"number\" name=\"mynumber\" id=\"mynumber\" value=\"5\" class=\"form-control\" min=\"-9\" max=\"6\" step=\"0.2\" />"
|
15
|
+
|
16
|
+
assert_equal expected, actual
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RangeFieldTest < ActionView::TestCase
|
4
|
+
|
5
|
+
test 'range_field' do
|
6
|
+
actual = UiBibz::Ui::Core::Forms::Numbers::RangeField.new('myrange').render
|
7
|
+
expected = "<input type=\"range\" name=\"myrange\" id=\"myrange\" class=\"custom-range\" />"
|
8
|
+
|
9
|
+
assert_equal expected, actual
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'range_field with options' do
|
13
|
+
actual = UiBibz::Ui::Core::Forms::Numbers::RangeField.new('myrange', value: 5, min: -9, max: 6, step: 0.2).render
|
14
|
+
expected = "<input type=\"range\" name=\"myrange\" id=\"myrange\" value=\"5\" class=\"custom-range\" min=\"-9\" max=\"6\" step=\"0.2\" />"
|
15
|
+
|
16
|
+
assert_equal expected, actual
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* bsCustomFileInput v1.3.1 (https://github.com/Johann-S/bs-custom-file-input)
|
3
|
+
* Copyright 2018 Johann-S <johann.servoire@gmail.com>
|
4
|
+
* Licensed under MIT (https://github.com/Johann-S/bs-custom-file-input/blob/master/LICENSE)
|
5
|
+
*/
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.bsCustomFileInput=t()}(this,function(){"use strict";var d={CUSTOMFILE:'.custom-file input[type="file"]',CUSTOMFILELABEL:".custom-file-label",FORM:"form",INPUT:"input"},r=function(e){if(0<e.childNodes.length)for(var t=[].slice.call(e.childNodes),n=0;n<t.length;n++){var r=t[n];if(3!==r.nodeType)return r}return e},u=function(e){var t=e.bsCustomFileInput.defaultText,n=e.parentNode.querySelector(d.CUSTOMFILELABEL);n&&(r(n).innerHTML=t)},n=!!window.File,l=function(e){if(e.hasAttribute("multiple")&&n)return[].slice.call(e.files).map(function(e){return e.name}).join(", ");if(-1===e.value.indexOf("fakepath"))return e.value;var t=e.value.split("\\");return t[t.length-1]};function v(){var e=this.parentNode.querySelector(d.CUSTOMFILELABEL);if(e){var t=r(e),n=l(this);n.length?t.innerHTML=n:u(this)}}function p(){for(var e=[].slice.call(this.querySelectorAll(d.INPUT)).filter(function(e){return!!e.bsCustomFileInput}),t=0,n=e.length;t<n;t++)u(e[t])}var m="bsCustomFileInput",L="reset",h="change";return{init:function(e,t){void 0===e&&(e=d.CUSTOMFILE),void 0===t&&(t=d.FORM);for(var n,r,l,i=[].slice.call(document.querySelectorAll(e)),o=[].slice.call(document.querySelectorAll(t)),u=0,c=i.length;u<c;u++){var f=i[u];Object.defineProperty(f,m,{value:{defaultText:(n=f,r=void 0,void 0,r="",l=n.parentNode.querySelector(d.CUSTOMFILELABEL),l&&(r=l.innerHTML),r)},writable:!0}),f.addEventListener(h,v)}for(var a=0,s=o.length;a<s;a++)o[a].addEventListener(L,p),Object.defineProperty(o[a],m,{value:!0,writable:!0})},destroy:function(){for(var e=[].slice.call(document.querySelectorAll(d.FORM)).filter(function(e){return!!e.bsCustomFileInput}),t=[].slice.call(document.querySelectorAll(d.INPUT)).filter(function(e){return!!e.bsCustomFileInput}),n=0,r=t.length;n<r;n++){var l=t[n];u(l),l[m]=void 0,l.removeEventListener(h,v)}for(var i=0,o=e.length;i<o;i++)e[i].removeEventListener(L,p),e[i][m]=void 0}}});
|
7
|
+
//# sourceMappingURL=bs-custom-file-input.min.js.map
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thooams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 4.1
|
131
|
+
version: 4.2.1
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 4.1
|
138
|
+
version: 4.2.1
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: simple_form
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -283,16 +283,19 @@ files:
|
|
283
283
|
- lib/ui_bibz/inputs/ui_bibz_inputs/collection_input.rb
|
284
284
|
- lib/ui_bibz/inputs/ui_bibz_inputs/string_input.rb
|
285
285
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_auto_complete_field_input.rb
|
286
|
+
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_box_switch_field_input.rb
|
286
287
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_checkbox_field_input.rb
|
287
288
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb
|
288
289
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_date_picker_field_input.rb
|
289
290
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_dropdown_select_field_input.rb
|
291
|
+
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_file_field_input.rb
|
290
292
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_formula_field_input.rb
|
291
293
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_markdown_editor_field_input.rb
|
292
294
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_multi_column_field_input.rb
|
293
295
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_multi_select_field_input.rb
|
294
296
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_number_field_input.rb
|
295
297
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_radio_field_input.rb
|
298
|
+
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_range_field_input.rb
|
296
299
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_select_field_input.rb
|
297
300
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_switch_field_input.rb
|
298
301
|
- lib/ui_bibz/inputs/ui_bibz_inputs/ui_text_field_input.rb
|
@@ -319,6 +322,7 @@ files:
|
|
319
322
|
- lib/ui_bibz/ui/core/forms/buttons/button_refresh.rb
|
320
323
|
- lib/ui_bibz/ui/core/forms/buttons/components/button_group_dropdown.rb
|
321
324
|
- lib/ui_bibz/ui/core/forms/buttons/components/button_group_split_dropdown.rb
|
325
|
+
- lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb
|
322
326
|
- lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb
|
323
327
|
- lib/ui_bibz/ui/core/forms/choices/choice_group.rb
|
324
328
|
- lib/ui_bibz/ui/core/forms/choices/components/choice.rb
|
@@ -330,8 +334,10 @@ files:
|
|
330
334
|
- lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
|
331
335
|
- lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb
|
332
336
|
- lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb
|
337
|
+
- lib/ui_bibz/ui/core/forms/files/file_field.rb
|
333
338
|
- lib/ui_bibz/ui/core/forms/numbers/formula_field.rb
|
334
339
|
- lib/ui_bibz/ui/core/forms/numbers/number_field.rb
|
340
|
+
- lib/ui_bibz/ui/core/forms/numbers/range_field.rb
|
335
341
|
- lib/ui_bibz/ui/core/forms/selects/abstract_select.rb
|
336
342
|
- lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb
|
337
343
|
- lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb
|
@@ -489,13 +495,16 @@ files:
|
|
489
495
|
- test/ui/core/forms/buttons/button_link_test.rb
|
490
496
|
- test/ui/core/forms/buttons/button_refresh_test.rb
|
491
497
|
- test/ui/core/forms/buttons/button_test.rb
|
498
|
+
- test/ui/core/forms/choices/box_switch_field_test.rb
|
492
499
|
- test/ui/core/forms/choices/checkbox_field_test.rb
|
493
500
|
- test/ui/core/forms/choices/choice_group_test.rb
|
494
501
|
- test/ui/core/forms/choices/radio_field_test.rb
|
495
|
-
- test/ui/core/forms/choices/switch_field_test.rb
|
496
502
|
- test/ui/core/forms/dates/date_picker_field_test.rb
|
497
503
|
- test/ui/core/forms/dropdowns/dropdown_test.rb
|
504
|
+
- test/ui/core/forms/files/text_field_test.rb
|
498
505
|
- test/ui/core/forms/numbers/formula_field_test.rb
|
506
|
+
- test/ui/core/forms/numbers/number_field_test.rb
|
507
|
+
- test/ui/core/forms/numbers/range_field_test.rb
|
499
508
|
- test/ui/core/forms/selects/dropdown_select_field_test.rb
|
500
509
|
- test/ui/core/forms/selects/multi_column_field_test.rb
|
501
510
|
- test/ui/core/forms/selects/multi_select_field_test.rb
|
@@ -549,6 +558,7 @@ files:
|
|
549
558
|
- vendor/assets/javascripts/bootstrap-select.js.map
|
550
559
|
- vendor/assets/javascripts/bootstrap-select.min.js
|
551
560
|
- vendor/assets/javascripts/bootstrap-switch.min.js
|
561
|
+
- vendor/assets/javascripts/bs-custom-file-input.min.js
|
552
562
|
- vendor/assets/javascripts/jquery-2.1.4.min.js
|
553
563
|
- vendor/assets/javascripts/jquery-ui.min.js
|
554
564
|
- vendor/assets/javascripts/jquery.multi-select.min.js
|
@@ -678,13 +688,16 @@ test_files:
|
|
678
688
|
- test/ui/core/forms/buttons/button_link_test.rb
|
679
689
|
- test/ui/core/forms/buttons/button_refresh_test.rb
|
680
690
|
- test/ui/core/forms/buttons/button_test.rb
|
691
|
+
- test/ui/core/forms/choices/box_switch_field_test.rb
|
681
692
|
- test/ui/core/forms/choices/checkbox_field_test.rb
|
682
693
|
- test/ui/core/forms/choices/choice_group_test.rb
|
683
694
|
- test/ui/core/forms/choices/radio_field_test.rb
|
684
|
-
- test/ui/core/forms/choices/switch_field_test.rb
|
685
695
|
- test/ui/core/forms/dates/date_picker_field_test.rb
|
686
696
|
- test/ui/core/forms/dropdowns/dropdown_test.rb
|
697
|
+
- test/ui/core/forms/files/text_field_test.rb
|
687
698
|
- test/ui/core/forms/numbers/formula_field_test.rb
|
699
|
+
- test/ui/core/forms/numbers/number_field_test.rb
|
700
|
+
- test/ui/core/forms/numbers/range_field_test.rb
|
688
701
|
- test/ui/core/forms/selects/dropdown_select_field_test.rb
|
689
702
|
- test/ui/core/forms/selects/multi_column_field_test.rb
|
690
703
|
- test/ui/core/forms/selects/multi_select_field_test.rb
|