ui_bibz 2.0.0.alpha28 → 2.0.0.alpha29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +5 -3
- data/app/assets/javascripts/form.coffee +16 -54
- data/app/assets/javascripts/input-connected.coffee +39 -15
- data/app/assets/javascripts/table.coffee +3 -2
- data/app/assets/stylesheets/fix-dropdown-select.sass +6 -0
- data/app/assets/stylesheets/ui_bibz.sass +3 -3
- data/app/inputs/custom_inputs/{autocomplete_input.rb → auto_complete_field_input.rb} +2 -2
- data/app/inputs/custom_inputs/{dropdown_select_input.rb → collection_input.rb} +19 -12
- data/app/inputs/custom_inputs/{date_picker_input.rb → date_picker_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/dropdown_select_field_input.rb +9 -0
- data/app/inputs/custom_inputs/{formula_input.rb → formula_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/{markdown_editor_input.rb → markdown_editor_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/{multi_column_input.rb → multi_column_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/multi_select_field_input.rb +9 -0
- data/app/inputs/custom_inputs/{radios_input.rb → radio_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/select_field_input.rb +8 -0
- data/app/inputs/custom_inputs/{surround_input.rb → surround_field_input.rb} +1 -1
- data/app/inputs/custom_inputs/{switch_input.rb → switch_field_input.rb} +1 -1
- data/lib/ui_bibz/concerns/models/searchable.rb +6 -1
- data/lib/ui_bibz/helpers/ui_core_helper.rb +2 -2
- data/lib/ui_bibz/ui/core/component.rb +0 -1
- data/lib/ui_bibz/ui/core/connected_component.rb +80 -0
- data/lib/ui_bibz/ui/core/forms/buttons/button.rb +1 -1
- data/lib/ui_bibz/ui/core/forms/buttons/button_refresh.rb +3 -3
- data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +1 -1
- data/lib/ui_bibz/ui/core/forms/numbers/formula_field.rb +5 -5
- data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +12 -21
- data/lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb +8 -3
- data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +7 -12
- data/lib/ui_bibz/ui/core/forms/selects/select_field.rb +11 -10
- data/lib/ui_bibz/ui/core/forms/texts/{autocomplete_field.rb → auto_complete_field.rb} +30 -8
- data/lib/ui_bibz/ui/ux/tables/extensions/paginable.rb +2 -2
- data/lib/ui_bibz/ui/ux/tables/extensions/searchable.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/extensions/sortable.rb +4 -2
- data/lib/ui_bibz/ui/ux/tables/table_card.rb +3 -3
- data/lib/ui_bibz/ui/ux/tables/table_pagination.rb +5 -1
- data/lib/ui_bibz/ui/ux/tables/table_pagination_per_page.rb +3 -3
- data/lib/ui_bibz/ui/ux/tables/table_search_field.rb +6 -4
- data/lib/ui_bibz/version.rb +1 -1
- data/lib/ui_bibz.rb +2 -1
- data/test/dummy/app/models/continent.rb +3 -0
- data/test/dummy/app/models/country.rb +3 -0
- data/test/dummy/db/migrate/20170309084406_continents.rb +9 -0
- data/test/dummy/db/migrate/20170309084453_countries.rb +10 -0
- data/test/dummy/db/schema.rb +15 -3
- data/test/simple_form_test.rb +98 -36
- data/test/ui/core/forms/choices/switch_field_test.rb +10 -10
- data/test/ui/core/forms/numbers/formula_field_test.rb +1 -1
- data/test/ui/core/forms/selects/dropdown_select_field_test.rb +10 -10
- data/test/ui/core/forms/selects/multi_column_field_test.rb +2 -2
- data/test/ui/core/forms/selects/multi_select_field_test.rb +3 -3
- data/test/ui/core/forms/selects/select_field_test.rb +1 -1
- data/test/ui/core/forms/texts/auto_complete_field_test.rb +23 -0
- data/test/ui/ux/tables/table_test.rb +5 -5
- metadata +26 -16
- data/app/inputs/custom_inputs/multi_select_input.rb +0 -15
- data/app/inputs/custom_inputs/select_input.rb +0 -15
- data/test/ui/core/forms/texts/autocomplete_field_test.rb +0 -14
data/test/simple_form_test.rb
CHANGED
@@ -7,115 +7,177 @@ include SimpleForm::ActionViewExtensions::FormHelper
|
|
7
7
|
class SimpleFormTest < ActionView::TestCase
|
8
8
|
|
9
9
|
setup do
|
10
|
-
User.
|
11
|
-
User.
|
12
|
-
|
13
|
-
|
10
|
+
User.where(name_fr: 'test1').first_or_create
|
11
|
+
User.where(name_fr: 'test2').first_or_create
|
12
|
+
continent = Continent.where(name: 'Europe').first_or_create
|
13
|
+
Country.where(name: 'France', continent_id: continent.id).first_or_create
|
14
|
+
Country.where(name: 'Deutchland', continent_id: continent.id).first_or_create
|
15
|
+
|
16
|
+
@continents = Continent.all
|
17
|
+
@countries = Country.all
|
18
|
+
@users = User.all
|
19
|
+
@user = @users.first
|
14
20
|
end
|
15
21
|
|
16
|
-
test '
|
22
|
+
test 'auto complete field input in simple form' do
|
17
23
|
actual = simple_form_for @user do |f|
|
18
|
-
f.input :name_fr, as: :
|
24
|
+
f.input :name_fr, as: :auto_complete_field, collection: @users, label_method: :name_fr
|
19
25
|
end
|
20
26
|
|
21
|
-
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
|
27
|
+
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 auto_complete_field optional user_name_fr\"><label class=\"control-label auto_complete_field optional\" for=\"user_name_fr\">Name fr</label><input class=\"auto_complete_field optional form-control\" autocomplete=\"true\" list=\"name_fr-datalist\" type=\"text\" value=\"test1\" name=\"user[name_fr]\" id=\"user_name_fr\" /><datalist id=\"name_fr-datalist\"><option value=\"test1\">test1</option>
|
22
28
|
<option value=\"test2\">test2</option></datalist></div></form>"
|
23
29
|
|
24
30
|
assert_equal expected, actual
|
25
31
|
end
|
26
32
|
|
27
|
-
test 'date picker input in simple form' do
|
33
|
+
test 'date picker field input in simple form' do
|
28
34
|
actual = simple_form_for @user do |f|
|
29
|
-
f.input :name_fr, as: :
|
35
|
+
f.input :name_fr, as: :date_picker_field
|
30
36
|
end
|
31
37
|
|
32
|
-
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
|
38
|
+
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 date_picker_field optional user_name_fr\"><label class=\"control-label date_picker_field optional\" for=\"user_name_fr\">Name fr</label><input class=\"date_picker_field optional date_picker form-control\" data-date-locale=\"en\" data-provide=\"datepicker\" data-date-format=\"dd/mm/yyyy\" data-date-today-btn=\"linked\" type=\"text\" value=\"test1\" name=\"user[name_fr]\" id=\"user_name_fr\" /></div></form>"
|
33
39
|
|
34
40
|
assert_equal expected, actual
|
35
41
|
end
|
36
42
|
|
37
|
-
test 'dropdown select input in simple form' do
|
43
|
+
test 'dropdown field select input in simple form' do
|
38
44
|
actual = simple_form_for @user do |f|
|
39
|
-
f.input :name_fr, as: :
|
45
|
+
f.input :name_fr, as: :dropdown_select_field, collection: @users, label_method: :name_fr
|
40
46
|
end
|
41
47
|
|
42
|
-
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
|
43
|
-
<option value=\"1\">test1</option>
|
48
|
+
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 dropdown_select_field optional user_name_fr\"><label class=\"control-label dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr\" id=\"name_fr\" class=\"dropdown_select_field optional dropdown-select-field\"><option value=\"\" label=\" \"></option><option value=\"1\">test1</option>
|
44
49
|
<option value=\"2\">test2</option></select></div></form>"
|
45
50
|
|
46
51
|
assert_equal expected, actual
|
47
52
|
end
|
48
53
|
|
49
|
-
test '
|
54
|
+
test 'dropdown field select input with grouped option in simple form' do
|
55
|
+
|
56
|
+
actual = simple_form_for @user do |f|
|
57
|
+
f.input :name_fr, as: :dropdown_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
|
58
|
+
end
|
59
|
+
|
60
|
+
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 dropdown_select_field optional user_name_fr\"><label class=\"control-label dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr\" id=\"name_fr\" class=\"dropdown_select_field optional dropdown-select-field\"><option value=\"\" label=\" \"></option><optgroup label=\"Europe\"><option value=\"1\">France</option>
|
61
|
+
<option value=\"2\">Deutchland</option></optgroup></select></div></form>"
|
62
|
+
|
63
|
+
assert_equal expected, actual
|
64
|
+
end
|
65
|
+
|
66
|
+
test 'formula field input in simple form' do
|
50
67
|
actual = simple_form_for @user do |f|
|
51
|
-
f.input :name_fr, as: :
|
68
|
+
f.input :name_fr, as: :formula_field
|
52
69
|
end
|
53
70
|
|
54
|
-
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
|
71
|
+
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 formula_field optional user_name_fr\"><label class=\"control-label formula_field optional\" for=\"user_name_fr\">Name fr</label><div class=\"input-group formula_field\"><input class=\"formula_field optional formula-field form-control\" type=\"text\" name=\"user[name_fr_formula]\" id=\"user_name_fr_formula\" /><span class=\"formula-field-sign input-group-addon\">=</span><input readonly=\"readonly\" class=\"formula-field-result form-control\" type=\"text\" value=\"test1\" name=\"user[name_fr]\" id=\"user_name_fr\" /><span class=\"formula-field-alert input-group-addon\" data-toggle=\"tooltip\"><i class=\"glyph-danger glyph fa fa-exclamation-triangle\"></i></span></div></div></form>"
|
55
72
|
|
56
73
|
assert_equal expected, actual
|
57
74
|
end
|
58
75
|
|
59
|
-
test 'mardown editor input in simple form' do
|
76
|
+
test 'mardown editor field input in simple form' do
|
60
77
|
actual = simple_form_for @user do |f|
|
61
|
-
f.input :name_fr, as: :
|
78
|
+
f.input :name_fr, as: :markdown_editor_field
|
62
79
|
end
|
63
80
|
|
64
|
-
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
|
81
|
+
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 markdown_editor_field optional user_name_fr\"><label class=\"control-label markdown_editor_field optional\" for=\"user_name_fr\">Name fr</label><textarea class=\"markdown_editor_field optional\" data-provide=\"markdown\" data-iconlibrary=\"fa\" name=\"user[name_fr]\" id=\"user_name_fr\">
|
65
82
|
test1</textarea></div></form>"
|
66
83
|
|
67
84
|
assert_equal expected, actual
|
68
85
|
end
|
69
86
|
|
70
|
-
test 'multi column input in simple form' do
|
87
|
+
test 'multi column field input in simple form' do
|
71
88
|
actual = simple_form_for @user do |f|
|
72
|
-
f.input :name_fr, as: :
|
89
|
+
f.input :name_fr, as: :multi_column_field, collection: @users, label_method: :name_fr
|
73
90
|
end
|
74
91
|
|
75
|
-
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
|
92
|
+
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 multi_column_field optional user_name_fr\"><label class=\"control-label multi_column_field optional\" for=\"user_name_fr\">Name fr</label><input name=\"user[name_fr][]\" type=\"hidden\" value=\"\" /><select class=\"multi_column_field optional multi-column-field\" multiple=\"multiple\" name=\"user[name_fr][]\" id=\"user_name_fr\"><option value=\"1\">test1</option>
|
76
93
|
<option value=\"2\">test2</option></select></div></form>"
|
77
94
|
|
78
95
|
assert_equal expected, actual
|
79
96
|
end
|
80
97
|
|
81
|
-
test 'multi select input in simple form' do
|
98
|
+
test 'multi select field input in simple form' do
|
82
99
|
actual = simple_form_for @user do |f|
|
83
|
-
f.input :name_fr, as: :
|
100
|
+
f.input :name_fr, as: :multi_select_field, collection: @users, label_method: :name_fr
|
84
101
|
end
|
85
102
|
|
86
|
-
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
|
87
|
-
<option value=\"1\">test1</option>
|
103
|
+
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 multi_select_field optional user_name_fr\"><label class=\"control-label multi_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr[]\" id=\"name_fr\" class=\"multi_select_field optional btn-secondary multi-select-field\" multiple=\"multiple\"><option value=\"1\">test1</option>
|
88
104
|
<option value=\"2\">test2</option></select></div></form>"
|
89
105
|
|
90
106
|
assert_equal expected, actual
|
91
107
|
end
|
92
108
|
|
93
|
-
test '
|
109
|
+
test 'multi select input with grouped option in simple form' do
|
110
|
+
|
111
|
+
actual = simple_form_for @user do |f|
|
112
|
+
f.input :name_fr, as: :multi_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
|
113
|
+
end
|
114
|
+
|
115
|
+
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 multi_select_field optional user_name_fr\"><label class=\"control-label multi_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr[]\" id=\"name_fr\" class=\"multi_select_field optional btn-secondary multi-select-field\" multiple=\"multiple\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
|
116
|
+
<option value=\"2\">Deutchland</option></optgroup></select></div></form>"
|
117
|
+
|
118
|
+
assert_equal expected, actual
|
119
|
+
end
|
120
|
+
|
121
|
+
test 'surround field input in simple form' do
|
94
122
|
actual = simple_form_for @user do |f|
|
95
|
-
f.input :name_fr, as: :
|
123
|
+
f.input :name_fr, as: :surround_field
|
96
124
|
end
|
97
125
|
|
98
|
-
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
|
126
|
+
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 surround_field optional user_name_fr\"><label class=\"control-label surround_field optional\" for=\"user_name_fr\">Name fr</label><input class=\"surround_field optional form-control\" type=\"text\" value=\"test1\" name=\"user[name_fr]\" id=\"user_name_fr\" /></div></form>"
|
99
127
|
|
100
128
|
assert_equal expected, actual
|
101
129
|
end
|
102
130
|
|
103
|
-
test 'switch input in simple form' do
|
131
|
+
test 'switch field input in simple form' do
|
104
132
|
actual = simple_form_for @user do |f|
|
105
|
-
f.input :name_fr, as: :
|
133
|
+
f.input :name_fr, as: :switch_field, collection: @users, label_method: :name_fr
|
106
134
|
end
|
107
135
|
|
108
|
-
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
|
136
|
+
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 switch_field optional user_name_fr\"><label class=\"control-label switch_field optional\" for=\"user_name_fr\">Name fr</label><input name=\"user[name_fr]\" type=\"hidden\" value=\"0\" /><input class=\"switch_field optional switch-field\" type=\"checkbox\" value=\"1\" name=\"user[name_fr]\" id=\"user_name_fr\" /></div></form>"
|
109
137
|
|
110
138
|
assert_equal expected, actual
|
111
139
|
end
|
112
140
|
|
113
|
-
test '
|
141
|
+
test 'radio field input in simple form' do
|
142
|
+
actual = simple_form_for @user do |f|
|
143
|
+
f.input :name_fr, as: :radio_field, collection: @users, label_method: :name_fr
|
144
|
+
end
|
145
|
+
|
146
|
+
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 radio_field optional user_name_fr\"><label class=\"control-label radio_field optional\">Name fr</label><input type=\"hidden\" name=\"user[name_fr]\" value=\"\" /><div class=\"radio radio_field optional abc-radio-default radio abc-radio\"><input class=\"radio_field optional abc-radio-default radio abc-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 radio_field optional abc-radio-default radio abc-radio\"><input class=\"radio_field optional abc-radio-default radio abc-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>"
|
147
|
+
|
148
|
+
assert_equal expected, actual
|
149
|
+
end
|
150
|
+
|
151
|
+
test 'select field input in simple form' do
|
152
|
+
actual = simple_form_for @user do |f|
|
153
|
+
f.input :name_fr, as: :select_field, collection: @users, label_method: :name_fr
|
154
|
+
end
|
155
|
+
|
156
|
+
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 select_field optional user_name_fr\"><label class=\"control-label select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr\" id=\"name_fr\" class=\"select_field optional select-field form-control\"><option value=\"\" label=\" \"></option><option value=\"1\">test1</option>
|
157
|
+
<option value=\"2\">test2</option></select></div></form>"
|
158
|
+
|
159
|
+
assert_equal expected, actual
|
160
|
+
end
|
161
|
+
|
162
|
+
test 'select field input with refresh button in simple form' do
|
163
|
+
actual = simple_form_for @user do |f|
|
164
|
+
f.input :name_fr, as: :select_field, refresh: { target: { data: [] }}, collection: @users, label_method: :name_fr
|
165
|
+
end
|
166
|
+
|
167
|
+
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 select_field optional user_name_fr\"><label class=\"control-label select_field optional\" for=\"user_name_fr\">Name fr</label><div class=\"input-group field-refresh\"><select name=\"name_fr\" id=\"name_fr\" class=\"select_field optional select-field form-control\"><option value=\"\" label=\" \"></option><option value=\"1\">test1</option>
|
168
|
+
<option value=\"2\">test2</option></select><span class=\"input-group-btn\"><button data-connect=\"{"events":"click","mode":"remote","target":{"selector":"#name_fr","url":"","data":[]}}\" class=\"btn-primary ui-bibz-connect input-refresh-button btn\"><i class=\"glyph fa fa-refresh\"></i> </button></span></div></div></form>"
|
169
|
+
|
170
|
+
assert_equal expected, actual
|
171
|
+
end
|
172
|
+
|
173
|
+
test 'select input with grouped option in simple form' do
|
174
|
+
|
114
175
|
actual = simple_form_for @user do |f|
|
115
|
-
f.input :name_fr, as: :
|
176
|
+
f.input :name_fr, as: :select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
|
116
177
|
end
|
117
178
|
|
118
|
-
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
|
179
|
+
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 select_field optional user_name_fr\"><label class=\"control-label select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr\" id=\"name_fr\" class=\"select_field optional select-field form-control\"><option value=\"\" label=\" \"></option><optgroup label=\"Europe\"><option value=\"1\">France</option>
|
180
|
+
<option value=\"2\">Deutchland</option></optgroup></select></div></form>"
|
119
181
|
|
120
182
|
assert_equal expected, actual
|
121
183
|
end
|
@@ -6,7 +6,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
6
6
|
# OK
|
7
7
|
test 'switch_field size' do
|
8
8
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', size: :lg).render
|
9
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-size=\"large\" class=\"switch\" />"
|
9
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-size=\"large\" class=\"switch-field\" />"
|
10
10
|
|
11
11
|
assert_equal expected, actual
|
12
12
|
end
|
@@ -14,7 +14,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
14
14
|
# OK
|
15
15
|
test 'switch_field animate' do
|
16
16
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', animate: false).render
|
17
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-animate=\"false\" class=\"switch\" />"
|
17
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-animate=\"false\" class=\"switch-field\" />"
|
18
18
|
|
19
19
|
assert_equal expected, actual
|
20
20
|
end
|
@@ -22,7 +22,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
22
22
|
# OK
|
23
23
|
test 'switch_field checked' do
|
24
24
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', {}, checked: true).render
|
25
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" checked=\"checked\" class=\"switch\" />"
|
25
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" checked=\"checked\" class=\"switch-field\" />"
|
26
26
|
|
27
27
|
assert_equal expected, actual
|
28
28
|
end
|
@@ -30,7 +30,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
30
30
|
# OK
|
31
31
|
test 'switch_field state' do
|
32
32
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', {}, state: "disabled").render
|
33
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" state=\"disabled\" class=\"switch\" />"
|
33
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" state=\"disabled\" class=\"switch-field\" />"
|
34
34
|
|
35
35
|
assert_equal expected, actual
|
36
36
|
end
|
@@ -38,7 +38,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
38
38
|
# NON FONCTIONNEL
|
39
39
|
test 'switch_field readonly' do
|
40
40
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', {}, readonly: true).render
|
41
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" readonly=\"readonly\" class=\"switch\" />"
|
41
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" readonly=\"readonly\" class=\"switch-field\" />"
|
42
42
|
|
43
43
|
assert_equal expected, actual
|
44
44
|
end
|
@@ -46,7 +46,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
46
46
|
# OK
|
47
47
|
test 'switch_field left_color' do
|
48
48
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', left_color: "success").render
|
49
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-on-color=\"success\" class=\"switch\" />"
|
49
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-on-color=\"success\" class=\"switch-field\" />"
|
50
50
|
|
51
51
|
assert_equal expected, actual
|
52
52
|
end
|
@@ -54,7 +54,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
54
54
|
# OK
|
55
55
|
test 'switch_field right_color' do
|
56
56
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', right_color: "info").render
|
57
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-off-color=\"info\" class=\"switch\" />"
|
57
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-off-color=\"info\" class=\"switch-field\" />"
|
58
58
|
|
59
59
|
assert_equal expected, actual
|
60
60
|
end
|
@@ -62,7 +62,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
62
62
|
# OK
|
63
63
|
test 'switch_field middle_text' do
|
64
64
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', middle_text: "testlabeltext").render
|
65
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-label-text=\"testlabeltext\" class=\"switch\" />"
|
65
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-label-text=\"testlabeltext\" class=\"switch-field\" />"
|
66
66
|
|
67
67
|
assert_equal expected, actual
|
68
68
|
end
|
@@ -70,7 +70,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
70
70
|
# OK
|
71
71
|
test 'switch_field left_text' do
|
72
72
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', left_text: 'testonlabel').render
|
73
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-on-text=\"testonlabel\" class=\"switch\" />"
|
73
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-on-text=\"testonlabel\" class=\"switch-field\" />"
|
74
74
|
|
75
75
|
assert_equal expected, actual
|
76
76
|
end
|
@@ -78,7 +78,7 @@ class SwitchFieldTest < ActionView::TestCase
|
|
78
78
|
# OK
|
79
79
|
test 'switch_field right_text' do
|
80
80
|
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', right_text: "testofflabel").render
|
81
|
-
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-off-text=\"testofflabel\" class=\"switch\" />"
|
81
|
+
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-off-text=\"testofflabel\" class=\"switch-field\" />"
|
82
82
|
|
83
83
|
assert_equal expected, actual
|
84
84
|
end
|
@@ -5,7 +5,7 @@ class FormulaFieldTest < ActionView::TestCase
|
|
5
5
|
|
6
6
|
test 'formula_field' do
|
7
7
|
actual = UiBibz::Ui::Core::Forms::Numbers::FormulaField.new('value').render
|
8
|
-
expected = "<div class=\"input-group formula_field\"><input type=\"text\" name=\"value_formula\" id=\"value_formula\" value=\"\" class=\"
|
8
|
+
expected = "<div class=\"input-group formula_field\"><input type=\"text\" name=\"value_formula\" id=\"value_formula\" value=\"\" class=\"formula-field form-control\" /><span class=\"formula-field-sign input-group-addon\">=</span><input type=\"text\" name=\"value\" id=\"value\" readonly=\"readonly\" class=\"formula-field-result form-control\" /><span class=\"formula-field-alert input-group-addon\" data-toggle=\"tooltip\"><i class=\"glyph-danger glyph fa fa-exclamation-triangle\"></i></span></div>"
|
9
9
|
|
10
10
|
assert_equal expected, actual
|
11
11
|
end
|
@@ -6,7 +6,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
6
6
|
test 'dropdown_select_field' do
|
7
7
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
8
8
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', options_tags: options).render
|
9
|
-
expected = "<select name=\"test\" id=\"test\" class=\"
|
9
|
+
expected = "<select name=\"test\" id=\"test\" class=\"dropdown-select-field\"></select>"
|
10
10
|
|
11
11
|
assert_equal expected, actual
|
12
12
|
end
|
@@ -14,7 +14,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
14
14
|
test 'dropdown_select_field searchable' do
|
15
15
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
16
16
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, searchable: true }).render
|
17
|
-
expected = "<select name=\"test\" id=\"test\" data-live-search=\"true\" class=\"
|
17
|
+
expected = "<select name=\"test\" id=\"test\" data-live-search=\"true\" class=\"dropdown-select-field\"></select>"
|
18
18
|
|
19
19
|
assert_equal expected, actual
|
20
20
|
end
|
@@ -22,7 +22,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
22
22
|
test 'dropdown_select_field max_options' do
|
23
23
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
24
24
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, max_options: 2 }).render
|
25
|
-
expected = "<select name=\"test\" id=\"test\" data-max-options=\"2\" class=\"
|
25
|
+
expected = "<select name=\"test\" id=\"test\" data-max-options=\"2\" class=\"dropdown-select-field\"></select>"
|
26
26
|
|
27
27
|
assert_equal expected, actual
|
28
28
|
end
|
@@ -30,7 +30,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
30
30
|
test 'dropdown_select_field selected_text_format' do
|
31
31
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
32
32
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, selected_text_format: "count > x" }).render
|
33
|
-
expected = "<select name=\"test\" id=\"test\" data-selected-text-format=\"count > x\" class=\"
|
33
|
+
expected = "<select name=\"test\" id=\"test\" data-selected-text-format=\"count > x\" class=\"dropdown-select-field\"></select>"
|
34
34
|
|
35
35
|
assert_equal expected, actual
|
36
36
|
end
|
@@ -38,7 +38,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
38
38
|
test 'dropdown_select_field menu_size' do
|
39
39
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
40
40
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, menu_size: 2 }).render
|
41
|
-
expected = "<select name=\"test\" id=\"test\" data-size=\"2\" class=\"
|
41
|
+
expected = "<select name=\"test\" id=\"test\" data-size=\"2\" class=\"dropdown-select-field\"></select>"
|
42
42
|
|
43
43
|
assert_equal expected, actual
|
44
44
|
end
|
@@ -46,7 +46,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
46
46
|
test 'dropdown_select_field actions_box' do
|
47
47
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
48
48
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, actions_box: true }).render
|
49
|
-
expected = "<select name=\"test\" id=\"test\" data-actions-box=\"true\" class=\"
|
49
|
+
expected = "<select name=\"test\" id=\"test\" data-actions-box=\"true\" class=\"dropdown-select-field\"></select>"
|
50
50
|
|
51
51
|
assert_equal expected, actual
|
52
52
|
end
|
@@ -54,7 +54,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
54
54
|
test 'dropdown_select_field show_tick' do
|
55
55
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
56
56
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, show_tick: true }).render
|
57
|
-
expected = "<select name=\"test\" id=\"test\" class=\"
|
57
|
+
expected = "<select name=\"test\" id=\"test\" class=\"dropdown-select-field show-tick\"></select>"
|
58
58
|
|
59
59
|
assert_equal expected, actual
|
60
60
|
end
|
@@ -62,7 +62,7 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
62
62
|
test 'dropdown_select_field show_menu_arrow' do
|
63
63
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
64
64
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, show_menu_arrow: true }).render
|
65
|
-
expected = "<select name=\"test\" id=\"test\" class=\"
|
65
|
+
expected = "<select name=\"test\" id=\"test\" class=\"dropdown-select-field show-menu-arrow\"></select>"
|
66
66
|
|
67
67
|
assert_equal expected, actual
|
68
68
|
end
|
@@ -70,14 +70,14 @@ class DropdownSelectFieldTest < ActionView::TestCase
|
|
70
70
|
test 'dropdown_select_field dropup' do
|
71
71
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
72
72
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, dropup: true }).render
|
73
|
-
expected = "<select name=\"test\" id=\"test\" class=\"
|
73
|
+
expected = "<select name=\"test\" id=\"test\" class=\"dropdown-select-field dropup\"></select>"
|
74
74
|
|
75
75
|
assert_equal expected, actual
|
76
76
|
end
|
77
77
|
|
78
78
|
test 'dropdown_select_field refresh' do
|
79
79
|
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { refresh: { mode: 'local', target: { data: [] }}}).render
|
80
|
-
expected = "<div class=\"input-group
|
80
|
+
expected = "<div class=\"input-group field-refresh\"><select name=\"test\" id=\"test\" class=\"dropdown-select-field\"></select><span class=\"input-group-btn\"><button data-connect=\"{"events":"click","mode":"local","target":{"selector":"#test","url":"","data":[]}}\" class=\"btn-primary ui-bibz-connect input-refresh-button btn\"><i class=\"glyph fa fa-refresh\"></i> </button></span></div>"
|
81
81
|
|
82
82
|
assert_equal expected, actual
|
83
83
|
end
|
@@ -6,7 +6,7 @@ class MultiColumnFieldTest < ActionView::TestCase
|
|
6
6
|
test "Multi Column Field" do
|
7
7
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
8
8
|
actual = UiBibz::Ui::Core::Forms::Selects::MultiColumnField.new('example', option_tags: options).render
|
9
|
-
expected = "<select name=\"example[]\" id=\"example\" class=\"multi-column\" multiple=\"multiple\"><option value=\"option 0\">option 0</option>
|
9
|
+
expected = "<select name=\"example[]\" id=\"example\" class=\"multi-column-field\" multiple=\"multiple\"><option value=\"option 0\">option 0</option>
|
10
10
|
<option value=\"option 1\">option 1</option></select>"
|
11
11
|
|
12
12
|
assert_equal expected, actual
|
@@ -15,7 +15,7 @@ class MultiColumnFieldTest < ActionView::TestCase
|
|
15
15
|
test "Multi Column Field data html options" do
|
16
16
|
grouped_options = { 'North America' => [['United statuss','US'], 'Canada'], 'Europe' => ['Denmark','Germany','France'] }
|
17
17
|
actual = UiBibz::Ui::Core::Forms::Selects::MultiColumnField.new('example', { option_tags: grouped_options_for_select(grouped_options), searchable: true, selectable_opt_group: true }).render
|
18
|
-
expected = "<select name=\"example[]\" id=\"example\" data-searchable=\"true\" data-selectable-optgroup=\"true\" class=\"multi-column\" multiple=\"multiple\"><optgroup label=\"North America\"><option value=\"US\">United statuss</option>
|
18
|
+
expected = "<select name=\"example[]\" id=\"example\" data-searchable=\"true\" data-selectable-optgroup=\"true\" class=\"multi-column-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>"
|
@@ -6,7 +6,7 @@ class MultiSelectFieldTest < ActionView::TestCase
|
|
6
6
|
test "Multi Select Field" do
|
7
7
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
8
8
|
actual = UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new('example', option_tags: options).render
|
9
|
-
expected = "<select name=\"example[]\" id=\"example\" class=\"btn-secondary
|
9
|
+
expected = "<select name=\"example[]\" id=\"example\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"><option value=\"option 0\">option 0</option>
|
10
10
|
<option value=\"option 1\">option 1</option></select>"
|
11
11
|
|
12
12
|
assert_equal expected, actual
|
@@ -15,7 +15,7 @@ class MultiSelectFieldTest < ActionView::TestCase
|
|
15
15
|
test "Multi Select Field data html options" do
|
16
16
|
grouped_options = { 'North America' => [['United statuss','US'], 'Canada'], 'Europe' => ['Denmark','Germany','France'] }
|
17
17
|
actual = UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new('example', { option_tags: grouped_options_for_select(grouped_options), clickable_opt_group: true, collapsible_opt_group: true, searchable: true, select_all_option: true, 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\" class=\"btn-danger
|
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\" 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>"
|
@@ -25,7 +25,7 @@ class MultiSelectFieldTest < ActionView::TestCase
|
|
25
25
|
|
26
26
|
test 'Multi select Field refresh option' do
|
27
27
|
actual = UiBibz::Ui::Core::Forms::Selects::MultiSelectField.new('test', { refresh: { target: { url: '/'}}}).render
|
28
|
-
expected = "<div class=\"input-group
|
28
|
+
expected = "<div class=\"input-group field-refresh\"><select name=\"test[]\" id=\"test\" class=\"btn-secondary multi-select-field\" multiple=\"multiple\"></select><span class=\"input-group-btn\"><button data-connect=\"{"events":"click","mode":"remote","target":{"selector":"#test","url":"/","data":[]}}\" class=\"btn-primary ui-bibz-connect input-refresh-button btn\"><i class=\"glyph fa fa-refresh\"></i> </button></span></div>"
|
29
29
|
|
30
30
|
assert_equal expected, actual
|
31
31
|
end
|
@@ -14,7 +14,7 @@ class SelectFieldTest < ActionView::TestCase
|
|
14
14
|
|
15
15
|
test "Select Field refresh" do
|
16
16
|
actual = UiBibz::Ui::Core::Forms::Selects::SelectField.new('example', refresh: { target: { url: '/' }}).render
|
17
|
-
expected = "<div class=\"input-group
|
17
|
+
expected = "<div class=\"input-group field-refresh\"><select name=\"example\" id=\"example\" class=\"select-field form-control\"></select><span class=\"input-group-btn\"><button data-connect=\"{"events":"click","mode":"remote","target":{"selector":"#example","url":"/","data":[]}}\" class=\"btn-primary ui-bibz-connect input-refresh-button btn\"><i class=\"glyph fa fa-refresh\"></i> </button></span></div>"
|
18
18
|
|
19
19
|
assert_equal expected, actual
|
20
20
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
include UiBibz::Helpers
|
3
|
+
|
4
|
+
class AutoCompleteFieldTest < ActionView::TestCase
|
5
|
+
|
6
|
+
test 'auto_complete_field' do
|
7
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
8
|
+
actual = UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new('test', { option_tags: options }, { id: 'test' }).render
|
9
|
+
expected = "<input type=\"text\" name=\"test\" id=\"test\" class=\"form-control\" autocomplete=\"true\" list=\"test-datalist\" /><datalist id=\"test-datalist\"><option value=\"option 0\">option 0</option>
|
10
|
+
<option value=\"option 1\">option 1</option></datalist>"
|
11
|
+
|
12
|
+
assert_equal expected, actual
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'auto_complete_field with refresh button' do
|
16
|
+
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
17
|
+
actual = UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new('test', { option_tags: options, refresh: { target: { url: '/'}} }, { id: 'test' }).render
|
18
|
+
expected = "<div class=\"input-group field-refresh\"><input type=\"text\" name=\"test\" id=\"test\" class=\"form-control\" autocomplete=\"true\" list=\"test-datalist\" /><datalist id=\"test-datalist\"><option value=\"option 0\">option 0</option>
|
19
|
+
<option value=\"option 1\">option 1</option></datalist><span class=\"input-group-btn\"><button data-connect=\"{"events":"click","mode":"remote","target":{"selector":"#test-datalist","url":"/","data":[]}}\" class=\"btn-primary ui-bibz-connect input-refresh-button btn\"><i class=\"glyph fa fa-refresh\"></i> </button></span></div>"
|
20
|
+
|
21
|
+
assert_equal expected, actual
|
22
|
+
end
|
23
|
+
end
|