ui_bibz 2.0.0.alpha24 → 2.0.0.alpha26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTORS.md +19 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +60 -55
- data/app/assets/javascripts/interface.coffee +11 -0
- data/app/assets/javascripts/ui_bibz.coffee +3 -1
- data/app/assets/stylesheets/table.sass +1 -2
- data/app/assets/stylesheets/ui_bibz.sass +2 -0
- data/app/inputs/custom_inputs/autocomplete_input.rb +3 -2
- data/app/inputs/custom_inputs/date_picker_input.rb +2 -2
- data/app/inputs/custom_inputs/dropdown_select_input.rb +2 -2
- data/app/inputs/custom_inputs/formula_input.rb +2 -2
- data/app/inputs/custom_inputs/markdown_editor_input.rb +2 -2
- data/app/inputs/custom_inputs/multi_column_input.rb +2 -2
- data/app/inputs/custom_inputs/multi_select_input.rb +2 -2
- data/app/inputs/custom_inputs/radios_input.rb +20 -0
- data/app/inputs/custom_inputs/surround_input.rb +2 -2
- data/app/inputs/custom_inputs/switch_input.rb +2 -2
- data/config/initializers/will_paginate.rb +79 -0
- data/lib/ui_bibz.rb +56 -30
- data/lib/ui_bibz/helpers/ui_core_helper.rb +45 -37
- data/lib/ui_bibz/ui/core/alert.rb +1 -2
- data/lib/ui_bibz/ui/core/{breadcrumb/breadcrumb.rb → breadcrumb.rb} +5 -5
- data/lib/ui_bibz/ui/core/cards/card.rb +6 -6
- data/lib/ui_bibz/ui/core/cards/components/block/card_block_link.rb +1 -1
- data/lib/ui_bibz/ui/core/cards/components/block/card_block_text.rb +1 -1
- data/lib/ui_bibz/ui/core/cards/components/block/card_block_title.rb +1 -1
- data/lib/ui_bibz/ui/core/cards/components/card_block.rb +4 -4
- data/lib/ui_bibz/ui/core/cards/components/card_footer.rb +1 -1
- data/lib/ui_bibz/ui/core/cards/components/card_header.rb +1 -1
- data/lib/ui_bibz/ui/core/cards/components/card_image.rb +1 -1
- data/lib/ui_bibz/ui/core/cards/components/card_list_group.rb +2 -2
- data/lib/ui_bibz/ui/core/component.rb +4 -51
- data/lib/ui_bibz/ui/core/component/glyph_extension.rb +19 -0
- data/lib/ui_bibz/ui/core/component/klass_extension.rb +38 -0
- data/lib/ui_bibz/ui/core/{dropdown → dropdowns}/components/dropdown_divider.rb +1 -1
- data/lib/ui_bibz/ui/core/{dropdown → dropdowns}/components/dropdown_header.rb +2 -2
- data/lib/ui_bibz/ui/core/{dropdown → dropdowns}/components/dropdown_link.rb +2 -2
- data/lib/ui_bibz/ui/core/{dropdown → dropdowns}/dropdown.rb +11 -12
- data/lib/ui_bibz/ui/core/{buttons/button_split_dropdown.rb → dropdowns/split_dropdown.rb} +6 -10
- data/lib/ui_bibz/ui/core/{buttons → forms/buttons}/button.rb +5 -5
- data/lib/ui_bibz/ui/core/{buttons → forms/buttons}/button_choice.rb +8 -8
- data/lib/ui_bibz/ui/core/{buttons → forms/buttons}/button_group.rb +5 -5
- data/lib/ui_bibz/ui/core/{buttons → forms/buttons}/button_link.rb +13 -9
- data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +98 -0
- data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +98 -0
- data/lib/ui_bibz/ui/core/{inputs → forms/choices}/switch_field.rb +3 -3
- data/lib/ui_bibz/ui/core/{inputs → forms/dates}/date_picker_field.rb +6 -6
- data/lib/ui_bibz/ui/core/{inputs → forms/numbers}/formula_field.rb +5 -5
- data/lib/ui_bibz/ui/core/{inputs → forms/selects}/dropdown_select_field.rb +5 -5
- data/lib/ui_bibz/ui/core/{inputs → forms/selects}/multi_column_field.rb +5 -5
- data/lib/ui_bibz/ui/core/{inputs → forms/selects}/multi_select_field.rb +8 -8
- data/lib/ui_bibz/ui/core/{inputs → forms/textareas}/markdown_editor_field.rb +5 -5
- data/lib/ui_bibz/ui/core/{inputs → forms/texts}/autocomplete_field.rb +5 -5
- data/lib/ui_bibz/ui/core/{inputs → forms/texts}/surround_field.rb +5 -5
- data/lib/ui_bibz/ui/core/glyph.rb +2 -1
- data/lib/ui_bibz/ui/core/{list → lists}/components/list.rb +11 -11
- data/lib/ui_bibz/ui/core/{list/components → lists/components/list}/list_body.rb +2 -2
- data/lib/ui_bibz/ui/core/{list/components → lists/components/list}/list_header.rb +2 -2
- data/lib/ui_bibz/ui/core/{list → lists}/list_group.rb +4 -4
- data/lib/ui_bibz/ui/core/navs/components/nav_dropdown.rb +1 -1
- data/lib/ui_bibz/ui/core/navs/components/navbar_form.rb +3 -1
- data/lib/ui_bibz/ui/core/paths/breadcrumb.rb +109 -0
- data/lib/ui_bibz/ui/core/{breadcrumb → paths}/components/breadcrumb_link.rb +6 -6
- data/lib/ui_bibz/ui/core/{stars.rb → star.rb} +14 -14
- data/lib/ui_bibz/ui/core/tag.rb +1 -2
- data/lib/ui_bibz/ui/core/{modal → windows}/components/modal_body.rb +2 -2
- data/lib/ui_bibz/ui/core/{modal → windows}/components/modal_footer.rb +2 -2
- data/lib/ui_bibz/ui/core/{modal → windows}/components/modal_header.rb +2 -2
- data/lib/ui_bibz/ui/core/{modal → windows}/modal.rb +8 -8
- data/lib/ui_bibz/ui/ux/tables/components/actions.rb +9 -9
- data/lib/ui_bibz/ui/ux/tables/extensions/actionable.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/table_pagination.rb +5 -4
- data/lib/ui_bibz/version.rb +1 -1
- data/test/dummy/app/controllers/users_controller.rb +18 -0
- data/test/dummy/app/models/user.rb +1 -0
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/config/initializers/simple_form_bootstrap.rb +155 -0
- data/test/simple_form_test.rb +123 -0
- data/test/test_helper.rb +2 -2
- data/test/ui/breadcrumb_test.rb +2 -2
- data/test/ui/button_test.rb +13 -39
- data/test/ui/dropdown_test.rb +14 -1
- data/test/ui/glyph_test.rb +6 -0
- data/test/ui/input_dropdown_select_field_test.rb +9 -9
- data/test/ui/input_switch_field_test.rb +11 -11
- data/test/ui/inputs_test.rb +26 -12
- data/test/ui/list_group_test.rb +2 -2
- data/test/ui/{stars_test.rb → star_test.rb} +7 -7
- data/test/ui/table_test.rb +3 -3
- data/test/ui_helper_test.rb +6 -1
- data/ui_bibz.gemspec +4 -3
- data/vendor/assets/stylesheets/awesome-bootstrap-checkbox.scss +250 -0
- metadata +65 -39
- data/lib/ui_bibz/helpers/pagination_helper.rb +0 -55
- data/lib/ui_bibz/ui/core/buttons/button_dropdown.rb +0 -82
@@ -0,0 +1,123 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
require 'simple_form'
|
4
|
+
|
5
|
+
include SimpleForm::ActionViewExtensions::FormHelper
|
6
|
+
|
7
|
+
class SimpleFormTest < ActionView::TestCase
|
8
|
+
|
9
|
+
setup do
|
10
|
+
User.create(name_fr: 'test1')
|
11
|
+
User.create(name_fr: 'test2')
|
12
|
+
@users = User.all
|
13
|
+
@user = @users.first
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'autocomplete input in simple form' do
|
17
|
+
actual = simple_form_for @user do |f|
|
18
|
+
f.input :name_fr, as: :autocomplete, collection: @users, label_method: :name_fr
|
19
|
+
end
|
20
|
+
|
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 autocomplete optional user_name_fr\"><label class=\"control-label autocomplete optional\" for=\"user_name_fr\">Name fr</label><input class=\"autocomplete 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
|
+
<option value=\"test2\">test2</option></datalist></div></form>"
|
23
|
+
|
24
|
+
assert_equal expected, actual
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'date picker input in simple form' do
|
28
|
+
actual = simple_form_for @user do |f|
|
29
|
+
f.input :name_fr, as: :date_picker
|
30
|
+
end
|
31
|
+
|
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 date_picker optional user_name_fr\"><label class=\"control-label date_picker optional\" for=\"user_name_fr\">Name fr</label><input class=\"date_picker 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
|
+
|
34
|
+
assert_equal expected, actual
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'dropdown select input in simple form' do
|
38
|
+
actual = simple_form_for @user do |f|
|
39
|
+
f.input :name_fr, as: :dropdown_select, collection: @users, label_method: :name_fr
|
40
|
+
end
|
41
|
+
|
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 dropdown_select optional user_name_fr\"><label class=\"control-label dropdown_select optional\" for=\"user_name_fr\">Name fr</label><select class=\"dropdown_select optional selectpicker\" name=\"user[name_fr]\" id=\"user_name_fr\"><option value=\"\"></option>
|
43
|
+
<option value=\"1\">test1</option>
|
44
|
+
<option value=\"2\">test2</option></select></div></form>"
|
45
|
+
|
46
|
+
assert_equal expected, actual
|
47
|
+
end
|
48
|
+
|
49
|
+
test 'formula input in simple form' do
|
50
|
+
actual = simple_form_for @user do |f|
|
51
|
+
f.input :name_fr, as: :formula
|
52
|
+
end
|
53
|
+
|
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 formula optional user_name_fr\"><label class=\"control-label formula optional\" for=\"user_name_fr\">Name fr</label><div class=\"input-group formula_field\"><input class=\"formula optional formula_field_input 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
|
+
|
56
|
+
assert_equal expected, actual
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'mardown editor input in simple form' do
|
60
|
+
actual = simple_form_for @user do |f|
|
61
|
+
f.input :name_fr, as: :markdown_editor
|
62
|
+
end
|
63
|
+
|
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 markdown_editor optional user_name_fr\"><label class=\"control-label markdown_editor optional\" for=\"user_name_fr\">Name fr</label><textarea class=\"markdown_editor optional\" data-provide=\"markdown\" data-iconlibrary=\"fa\" name=\"user[name_fr]\" id=\"user_name_fr\">
|
65
|
+
test1</textarea></div></form>"
|
66
|
+
|
67
|
+
assert_equal expected, actual
|
68
|
+
end
|
69
|
+
|
70
|
+
test 'multi column input in simple form' do
|
71
|
+
actual = simple_form_for @user do |f|
|
72
|
+
f.input :name_fr, as: :multi_column, collection: @users, label_method: :name_fr
|
73
|
+
end
|
74
|
+
|
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 multi_column optional user_name_fr\"><label class=\"control-label multi_column optional\" for=\"user_name_fr\">Name fr</label><input name=\"user[name_fr][]\" type=\"hidden\" value=\"\" /><select class=\"multi_column optional multi-column\" multiple=\"multiple\" name=\"user[name_fr][]\" id=\"user_name_fr\"><option value=\"1\">test1</option>
|
76
|
+
<option value=\"2\">test2</option></select></div></form>"
|
77
|
+
|
78
|
+
assert_equal expected, actual
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'multi select input in simple form' do
|
82
|
+
actual = simple_form_for @user do |f|
|
83
|
+
f.input :name_fr, as: :multi_select, collection: @users, label_method: :name_fr
|
84
|
+
end
|
85
|
+
|
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 multi_select optional user_name_fr\"><label class=\"control-label multi_select optional\" for=\"user_name_fr\">Name fr</label><input name=\"user[name_fr][]\" type=\"hidden\" value=\"\" /><select class=\"multi_select optional btn-secondary btn multi-select\" multiple=\"multiple\" name=\"user[name_fr][]\" id=\"user_name_fr\"><option value=\"\"></option>
|
87
|
+
<option value=\"1\">test1</option>
|
88
|
+
<option value=\"2\">test2</option></select></div></form>"
|
89
|
+
|
90
|
+
assert_equal expected, actual
|
91
|
+
end
|
92
|
+
|
93
|
+
test 'surround input in simple form' do
|
94
|
+
actual = simple_form_for @user do |f|
|
95
|
+
f.input :name_fr, as: :surround
|
96
|
+
end
|
97
|
+
|
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 surround optional user_name_fr\"><label class=\"control-label surround optional\" for=\"user_name_fr\">Name fr</label><input class=\"surround optional form-control\" type=\"text\" value=\"test1\" name=\"user[name_fr]\" id=\"user_name_fr\" /></div></form>"
|
99
|
+
|
100
|
+
assert_equal expected, actual
|
101
|
+
end
|
102
|
+
|
103
|
+
test 'switch input in simple form' do
|
104
|
+
actual = simple_form_for @user do |f|
|
105
|
+
f.input :name_fr, as: :switch, collection: @users, label_method: :name_fr
|
106
|
+
end
|
107
|
+
|
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 switch optional user_name_fr\"><label class=\"control-label switch optional\" for=\"user_name_fr\">Name fr</label><input name=\"user[name_fr]\" type=\"hidden\" value=\"0\" /><input class=\"switch optional switch\" type=\"checkbox\" value=\"1\" name=\"user[name_fr]\" id=\"user_name_fr\" /></div></form>"
|
109
|
+
|
110
|
+
assert_equal expected, actual
|
111
|
+
end
|
112
|
+
|
113
|
+
test 'radios input in simple form' do
|
114
|
+
actual = simple_form_for @user do |f|
|
115
|
+
f.input :name_fr, as: :radios, collection: @users, label_method: :name_fr
|
116
|
+
end
|
117
|
+
|
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 radios optional user_name_fr\"><label class=\"control-label radios optional\">Name fr</label><input type=\"hidden\" name=\"user[name_fr]\" value=\"\" /><div class=\"radio radios optional abc-radio-default radio abc-radio\"><input class=\"radios 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 radios optional abc-radio-default radio abc-radio\"><input class=\"radios 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>"
|
119
|
+
|
120
|
+
assert_equal expected, actual
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
data/test/test_helper.rb
CHANGED
data/test/ui/breadcrumb_test.rb
CHANGED
@@ -3,7 +3,7 @@ include UiBibz::Helpers
|
|
3
3
|
class NavTest < ActionView::TestCase
|
4
4
|
|
5
5
|
test 'breadcrumb' do
|
6
|
-
actual = UiBibz::Ui::Core::Breadcrumb.new.tap do |b|
|
6
|
+
actual = UiBibz::Ui::Core::Paths::Breadcrumb.new.tap do |b|
|
7
7
|
b.link 'Home', url: '#home', glyph: 'home'
|
8
8
|
b.link 'state', { url: '#state', state: :active }
|
9
9
|
end.render
|
@@ -14,7 +14,7 @@ class NavTest < ActionView::TestCase
|
|
14
14
|
|
15
15
|
test 'breadcrumb with store' do
|
16
16
|
users = create_list(:user, 3)
|
17
|
-
actual = UiBibz::Ui::Core::Breadcrumb.new(store: users, link_label: :name_fr, link_url: user_path(:id)).render
|
17
|
+
actual = UiBibz::Ui::Core::Paths::Breadcrumb.new(store: users, link_label: :name_fr, link_url: user_path(:id)).render
|
18
18
|
expected = "<ol class=\"breadcrumb\"><li class=\"breadcrumb-item\"><a href=\"/users/1/\">Name fr</a></li><li class=\"breadcrumb-item\"><a href=\"/users/2/\">Name fr</a></li><li class=\"breadcrumb-item\">Name fr</li></ol>"
|
19
19
|
|
20
20
|
assert_equal expected, actual
|
data/test/ui/button_test.rb
CHANGED
@@ -4,15 +4,15 @@ include UiBibz::Helpers
|
|
4
4
|
class ButtonTest < ActionView::TestCase
|
5
5
|
|
6
6
|
test "button" do
|
7
|
-
actual = UiBibz::Ui::Core::Buttons::Button.new('state', status: :success).render
|
7
|
+
actual = UiBibz::Ui::Core::Forms::Buttons::Button.new('state', status: :success).render
|
8
8
|
expected = "<button class=\"btn-success btn\">state</button>"
|
9
9
|
|
10
10
|
assert_equal expected, actual
|
11
11
|
end
|
12
12
|
|
13
13
|
test 'button group' do
|
14
|
-
actual = UiBibz::Ui::Core::Buttons::ButtonGroup.new position: :vertical do
|
15
|
-
UiBibz::Ui::Core::Buttons::Button.new('state').render
|
14
|
+
actual = UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new position: :vertical do
|
15
|
+
UiBibz::Ui::Core::Forms::Buttons::Button.new('state').render
|
16
16
|
end.render
|
17
17
|
expected = "<div data-toggle=\"buttons\" class=\"btn-group btn-group-vertical\" role=\"group\"><button class=\"btn-primary btn\">state</button></div>"
|
18
18
|
|
@@ -20,37 +20,37 @@ class ButtonTest < ActionView::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
test 'link button' do
|
23
|
-
actual = UiBibz::Ui::Core::Buttons::ButtonLink.new('state', { url: users_path, status: :danger, glyph: 'add'}).render
|
23
|
+
actual = UiBibz::Ui::Core::Forms::Buttons::ButtonLink.new('state', { url: users_path, status: :danger, glyph: 'add'}).render
|
24
24
|
expected = "<a class=\"btn-danger btn\" href=\"/users\"><i class=\"glyph fa fa-add\"></i> state</a>"
|
25
25
|
|
26
26
|
assert_equal expected, actual
|
27
27
|
end
|
28
28
|
|
29
29
|
test 'button outline' do
|
30
|
-
actual = UiBibz::Ui::Core::Buttons::Button.new('state', status: :success, outline: true).render
|
30
|
+
actual = UiBibz::Ui::Core::Forms::Buttons::Button.new('state', status: :success, outline: true).render
|
31
31
|
expected = "<button class=\"btn-outline-success btn\">state</button>"
|
32
32
|
|
33
33
|
assert_equal expected, actual
|
34
34
|
end
|
35
35
|
|
36
36
|
test 'checkbox button checked' do
|
37
|
-
actual = UiBibz::Ui::Core::Buttons::ButtonChoice.new('state', { state: :active }).render
|
37
|
+
actual = UiBibz::Ui::Core::Forms::Buttons::ButtonChoice.new('state', { state: :active }).render
|
38
38
|
expected = "<label class=\"active btn-primary btn\"><input type=\"checkbox\" autocomplete=\"off\" checked=\"checked\" />state</label>"
|
39
39
|
|
40
40
|
assert_equal expected, actual
|
41
41
|
end
|
42
42
|
|
43
43
|
test 'checkbox button non checked' do
|
44
|
-
actual = UiBibz::Ui::Core::Buttons::ButtonChoice.new('state', { name: 'state', id: 'state', input_html_options: { class: 'state'}}).render
|
44
|
+
actual = UiBibz::Ui::Core::Forms::Buttons::ButtonChoice.new('state', { name: 'state', id: 'state', input_html_options: { class: 'state'}}).render
|
45
45
|
expected = "<label class=\"btn-primary btn\"><input type=\"checkbox\" autocomplete=\"off\" name=\"state\" id=\"state\" class=\"state\" />state</label>"
|
46
46
|
|
47
47
|
assert_equal expected, actual
|
48
48
|
end
|
49
49
|
|
50
50
|
test 'button group choice checkbox' do
|
51
|
-
actual = UiBibz::Ui::Core::Buttons::ButtonGroup.new do
|
52
|
-
concat UiBibz::Ui::Core::Buttons::ButtonChoice.new('state1').render
|
53
|
-
concat UiBibz::Ui::Core::Buttons::ButtonChoice.new('state2').render
|
51
|
+
actual = UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new do
|
52
|
+
concat UiBibz::Ui::Core::Forms::Buttons::ButtonChoice.new('state1').render
|
53
|
+
concat UiBibz::Ui::Core::Forms::Buttons::ButtonChoice.new('state2').render
|
54
54
|
end.render
|
55
55
|
expected = "<div data-toggle=\"buttons\" class=\"btn-group\" role=\"group\"><label class=\"btn-primary btn\"><input type=\"checkbox\" autocomplete=\"off\" />state1</label><label class=\"btn-primary btn\"><input type=\"checkbox\" autocomplete=\"off\" />state2</label></div>"
|
56
56
|
|
@@ -58,39 +58,13 @@ class ButtonTest < ActionView::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
test 'button group choice radio' do
|
61
|
-
actual = UiBibz::Ui::Core::Buttons::ButtonGroup.new do
|
62
|
-
concat UiBibz::Ui::Core::Buttons::ButtonChoice.new('state1', type: :radio).render
|
63
|
-
concat UiBibz::Ui::Core::Buttons::ButtonChoice.new('state2', type: :radio).render
|
61
|
+
actual = UiBibz::Ui::Core::Forms::Buttons::ButtonGroup.new do
|
62
|
+
concat UiBibz::Ui::Core::Forms::Buttons::ButtonChoice.new('state1', type: :radio).render
|
63
|
+
concat UiBibz::Ui::Core::Forms::Buttons::ButtonChoice.new('state2', type: :radio).render
|
64
64
|
end.render
|
65
65
|
expected = "<div data-toggle=\"buttons\" class=\"btn-group\" role=\"group\"><label class=\"btn-primary btn\"><input type=\"radio\" autocomplete=\"off\" />state1</label><label class=\"btn-primary btn\"><input type=\"radio\" autocomplete=\"off\" />state2</label></div>"
|
66
66
|
|
67
67
|
assert_equal expected, actual
|
68
68
|
end
|
69
69
|
|
70
|
-
test 'button dropdown' do
|
71
|
-
actual = UiBibz::Ui::Core::Buttons::ButtonDropdown.new("Dropdown", type: :dropup, status: :success).tap do |d|
|
72
|
-
d.link 'state'
|
73
|
-
d.header 'header'
|
74
|
-
d.link 'momo'
|
75
|
-
d.divider
|
76
|
-
d.link 'lolo'
|
77
|
-
end.render
|
78
|
-
expected = "<div class=\"btn-group dropup\" role=\"group\"><button class=\"btn btn-success dropdown-toggle\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">Dropdown <span class=\"caret\"></span></button><div class=\"dropdown-menu dropdown-menu-left\"><a class=\"dropdown-item\" href=\"#\">state</a><h6 class=\"dropdown-header\" role=\"presentation\">header</h6><a class=\"dropdown-item\" href=\"#\">momo</a><div class=\"dropdown-divider\"></div><a class=\"dropdown-item\" href=\"#\">lolo</a></div></div>"
|
79
|
-
|
80
|
-
assert_equal expected, actual
|
81
|
-
end
|
82
|
-
|
83
|
-
test 'button split dropdown' do
|
84
|
-
actual = UiBibz::Ui::Core::Buttons::ButtonSplitDropdown.new("Dropdown", type: :dropup, status: :primary).tap do |d|
|
85
|
-
d.link 'state'
|
86
|
-
d.header 'header'
|
87
|
-
d.link 'momo'
|
88
|
-
d.divider
|
89
|
-
d.link 'lolo'
|
90
|
-
end.render
|
91
|
-
expected = "<div class=\"btn-group dropup\" role=\"group\"><button class=\"btn btn-primary\">Dropdown</button><button class=\"btn btn-primary dropdown-toggle dropdown-toggle-split\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"sr-only\">Toggle Dropdown</span></button><div class=\"dropdown-menu dropdown-menu-left\"><a class=\"dropdown-item\" href=\"#\">state</a><h6 class=\"dropdown-header\" role=\"presentation\">header</h6><a class=\"dropdown-item\" href=\"#\">momo</a><div class=\"dropdown-divider\"></div><a class=\"dropdown-item\" href=\"#\">lolo</a></div></div>"
|
92
|
-
|
93
|
-
assert_equal expected, actual
|
94
|
-
end
|
95
|
-
|
96
70
|
end
|
data/test/ui/dropdown_test.rb
CHANGED
@@ -3,7 +3,7 @@ include UiBibz::Helpers
|
|
3
3
|
class DropdownTest < ActionView::TestCase
|
4
4
|
|
5
5
|
test 'Dropdown' do
|
6
|
-
actual = UiBibz::Ui::Core::Dropdown.new("Dropdown", type: :dropup, status: :success).tap do |d|
|
6
|
+
actual = UiBibz::Ui::Core::Dropdowns::Dropdown.new("Dropdown", type: :dropup, status: :success).tap do |d|
|
7
7
|
d.link 'Link 1', url: '#link1', glyph: 'eye'
|
8
8
|
d.header 'header'
|
9
9
|
d.link 'Link 2', url: '#link2'
|
@@ -15,4 +15,17 @@ class DropdownTest < ActionView::TestCase
|
|
15
15
|
assert_equal expected, actual
|
16
16
|
end
|
17
17
|
|
18
|
+
test 'Split Dropdown' do
|
19
|
+
actual = UiBibz::Ui::Core::Dropdowns::SplitDropdown.new("Split Dropdown", type: :dropup, status: :primary).tap do |d|
|
20
|
+
d.link 'state'
|
21
|
+
d.header 'header'
|
22
|
+
d.link 'momo'
|
23
|
+
d.divider
|
24
|
+
d.link 'lolo'
|
25
|
+
end.render
|
26
|
+
expected = "<div class=\"btn-group dropup\"><button class=\"btn btn-primary\">Split Dropdown</button><button class=\"btn btn-primary dropdown-toggle dropdown-toggle-split\" type=\"button\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\"><span class=\"sr-only\">Toggle Dropdown</span></button><div class=\"dropdown-menu dropdown-menu-left\"><a class=\"dropdown-item\" href=\"#\">state</a><h6 class=\"dropdown-header\" role=\"presentation\">header</h6><a class=\"dropdown-item\" href=\"#\">momo</a><div class=\"dropdown-divider\"></div><a class=\"dropdown-item\" href=\"#\">lolo</a></div></div>"
|
27
|
+
|
28
|
+
assert_equal expected, actual
|
29
|
+
end
|
30
|
+
|
18
31
|
end
|
data/test/ui/glyph_test.rb
CHANGED
@@ -20,4 +20,10 @@ class GlyphTest < ActionView::TestCase
|
|
20
20
|
expected = '<i class="glyph fa fa-add fa-3x fa-li"></i>'
|
21
21
|
assert_equal expected, actual
|
22
22
|
end
|
23
|
+
|
24
|
+
test 'create glyph with label' do
|
25
|
+
actual = UiBibz::Ui::Core::Glyph.new('add', { label: 'Example' }).render
|
26
|
+
expected = "<i class=\"glyph fa fa-add\"></i> Example"
|
27
|
+
assert_equal expected, actual
|
28
|
+
end
|
23
29
|
end
|
@@ -5,7 +5,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
5
5
|
|
6
6
|
test 'dropdowm_select_field' do
|
7
7
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
8
|
-
actual = UiBibz::Ui::Core::
|
8
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', options_tags: options).render
|
9
9
|
expected = "<select name=\"test\" id=\"test\" class=\"selectpicker\"></select>"
|
10
10
|
|
11
11
|
assert_equal expected, actual
|
@@ -13,7 +13,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
13
13
|
|
14
14
|
test 'dropdowm_select_field searchable' do
|
15
15
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
16
|
-
actual = UiBibz::Ui::Core::
|
16
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, searchable: true }).render
|
17
17
|
expected = "<select name=\"test\" id=\"test\" data-live-search=\"true\" class=\"selectpicker\"></select>"
|
18
18
|
|
19
19
|
assert_equal expected, actual
|
@@ -21,7 +21,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
21
21
|
|
22
22
|
test 'dropdowm_select_field max_options' do
|
23
23
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
24
|
-
actual = UiBibz::Ui::Core::
|
24
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, max_options: 2 }).render
|
25
25
|
expected = "<select name=\"test\" id=\"test\" data-max-options=\"2\" class=\"selectpicker\"></select>"
|
26
26
|
|
27
27
|
assert_equal expected, actual
|
@@ -29,7 +29,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
29
29
|
|
30
30
|
test 'dropdowm_select_field selected_text_format' do
|
31
31
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
32
|
-
actual = UiBibz::Ui::Core::
|
32
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, selected_text_format: "count > x" }).render
|
33
33
|
expected = "<select name=\"test\" id=\"test\" data-selected-text-format=\"count > x\" class=\"selectpicker\"></select>"
|
34
34
|
|
35
35
|
assert_equal expected, actual
|
@@ -37,7 +37,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
37
37
|
|
38
38
|
test 'dropdowm_select_field menu_size' do
|
39
39
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
40
|
-
actual = UiBibz::Ui::Core::
|
40
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, menu_size: 2 }).render
|
41
41
|
expected = "<select name=\"test\" id=\"test\" data-size=\"2\" class=\"selectpicker\"></select>"
|
42
42
|
|
43
43
|
assert_equal expected, actual
|
@@ -45,7 +45,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
45
45
|
|
46
46
|
test 'dropdowm_select_field actions_box' do
|
47
47
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
48
|
-
actual = UiBibz::Ui::Core::
|
48
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, actions_box: true }).render
|
49
49
|
expected = "<select name=\"test\" id=\"test\" data-actions-box=\"true\" class=\"selectpicker\"></select>"
|
50
50
|
|
51
51
|
assert_equal expected, actual
|
@@ -53,7 +53,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
53
53
|
|
54
54
|
test 'dropdowm_select_field show_tick' do
|
55
55
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
56
|
-
actual = UiBibz::Ui::Core::
|
56
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, show_tick: true }).render
|
57
57
|
expected = "<select name=\"test\" id=\"test\" class=\"selectpicker show-tick\"></select>"
|
58
58
|
|
59
59
|
assert_equal expected, actual
|
@@ -61,7 +61,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
61
61
|
|
62
62
|
test 'dropdowm_select_field show_menu_arrow' do
|
63
63
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
64
|
-
actual = UiBibz::Ui::Core::
|
64
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, show_menu_arrow: true }).render
|
65
65
|
expected = "<select name=\"test\" id=\"test\" class=\"selectpicker show-menu-arrow\"></select>"
|
66
66
|
|
67
67
|
assert_equal expected, actual
|
@@ -69,7 +69,7 @@ class InputDropdownSelectFieldTest < ActionView::TestCase
|
|
69
69
|
|
70
70
|
test 'dropdowm_select_field dropup' do
|
71
71
|
options = options_for_select(2.times.map{ |i| "option #{i}" })
|
72
|
-
actual = UiBibz::Ui::Core::
|
72
|
+
actual = UiBibz::Ui::Core::Forms::Selects::DropdownSelectField.new('test', { options_tags: options, dropup: true }).render
|
73
73
|
expected = "<select name=\"test\" id=\"test\" class=\"selectpicker dropup\"></select>"
|
74
74
|
|
75
75
|
assert_equal expected, actual
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
include UiBibz::Helpers
|
4
|
-
class
|
4
|
+
class ChoicesSwitchFieldTest < ActionView::TestCase
|
5
5
|
|
6
6
|
# OK
|
7
7
|
test 'switch_field size' do
|
8
|
-
actual = UiBibz::Ui::Core::
|
8
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', size: :lg).render
|
9
9
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-size=\"large\" class=\"switch\" />"
|
10
10
|
|
11
11
|
assert_equal expected, actual
|
@@ -13,7 +13,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
13
13
|
|
14
14
|
# OK
|
15
15
|
test 'switch_field animate' do
|
16
|
-
actual = UiBibz::Ui::Core::
|
16
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', animate: false).render
|
17
17
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-animate=\"false\" class=\"switch\" />"
|
18
18
|
|
19
19
|
assert_equal expected, actual
|
@@ -21,7 +21,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
21
21
|
|
22
22
|
# OK
|
23
23
|
test 'switch_field checked' do
|
24
|
-
actual = UiBibz::Ui::Core::
|
24
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', {}, checked: true).render
|
25
25
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" checked=\"checked\" class=\"switch\" />"
|
26
26
|
|
27
27
|
assert_equal expected, actual
|
@@ -29,7 +29,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
29
29
|
|
30
30
|
# OK
|
31
31
|
test 'switch_field state' do
|
32
|
-
actual = UiBibz::Ui::Core::
|
32
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', {}, state: "disabled").render
|
33
33
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" state=\"disabled\" class=\"switch\" />"
|
34
34
|
|
35
35
|
assert_equal expected, actual
|
@@ -37,7 +37,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
37
37
|
|
38
38
|
# NON FONCTIONNEL
|
39
39
|
test 'switch_field readonly' do
|
40
|
-
actual = UiBibz::Ui::Core::
|
40
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', {}, readonly: true).render
|
41
41
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" readonly=\"readonly\" class=\"switch\" />"
|
42
42
|
|
43
43
|
assert_equal expected, actual
|
@@ -45,7 +45,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
45
45
|
|
46
46
|
# OK
|
47
47
|
test 'switch_field left_color' do
|
48
|
-
actual = UiBibz::Ui::Core::
|
48
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', left_color: "success").render
|
49
49
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-on-color=\"success\" class=\"switch\" />"
|
50
50
|
|
51
51
|
assert_equal expected, actual
|
@@ -53,7 +53,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
53
53
|
|
54
54
|
# OK
|
55
55
|
test 'switch_field right_color' do
|
56
|
-
actual = UiBibz::Ui::Core::
|
56
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', right_color: "info").render
|
57
57
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-off-color=\"info\" class=\"switch\" />"
|
58
58
|
|
59
59
|
assert_equal expected, actual
|
@@ -61,7 +61,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
61
61
|
|
62
62
|
# OK
|
63
63
|
test 'switch_field middle_text' do
|
64
|
-
actual = UiBibz::Ui::Core::
|
64
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', middle_text: "testlabeltext").render
|
65
65
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-label-text=\"testlabeltext\" class=\"switch\" />"
|
66
66
|
|
67
67
|
assert_equal expected, actual
|
@@ -69,7 +69,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
69
69
|
|
70
70
|
# OK
|
71
71
|
test 'switch_field left_text' do
|
72
|
-
actual = UiBibz::Ui::Core::
|
72
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', left_text: 'testonlabel').render
|
73
73
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-on-text=\"testonlabel\" class=\"switch\" />"
|
74
74
|
|
75
75
|
assert_equal expected, actual
|
@@ -77,7 +77,7 @@ class InputsSwitchFieldTest < ActionView::TestCase
|
|
77
77
|
|
78
78
|
# OK
|
79
79
|
test 'switch_field right_text' do
|
80
|
-
actual = UiBibz::Ui::Core::
|
80
|
+
actual = UiBibz::Ui::Core::Forms::Choices::SwitchField.new('test', right_text: "testofflabel").render
|
81
81
|
expected = "<input type=\"checkbox\" name=\"test\" id=\"test\" data-off-text=\"testofflabel\" class=\"switch\" />"
|
82
82
|
|
83
83
|
assert_equal expected, actual
|