ui_bibz 2.0.0.alpha32 → 2.0.0.beta2

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.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/Gemfile.lock +111 -87
  4. data/app/assets/javascripts/form.coffee +24 -8
  5. data/app/assets/javascripts/ui_bibz.coffee +3 -2
  6. data/app/assets/stylesheets/bootstrap-switch.sass +17 -8
  7. data/app/assets/stylesheets/fix-dropdown-select.sass +1 -1
  8. data/app/assets/stylesheets/table.sass +1 -1
  9. data/app/assets/stylesheets/ui_bibz.sass +60 -22
  10. data/app/inputs/ui_bibz_form/ui_bibz_form_builder.rb +35 -0
  11. data/app/inputs/ui_bibz_inputs/auto_complete_field_input.rb +14 -0
  12. data/app/inputs/{custom_inputs → ui_bibz_inputs}/base_input.rb +7 -1
  13. data/app/inputs/{custom_inputs → ui_bibz_inputs}/collection_input.rb +6 -3
  14. data/app/inputs/{custom_inputs → ui_bibz_inputs}/string_input.rb +5 -1
  15. data/app/inputs/ui_bibz_inputs/ui_auto_complete_field_input.rb +14 -0
  16. data/app/inputs/ui_bibz_inputs/ui_button_choices_input.rb +20 -0
  17. data/app/inputs/{custom_inputs/date_picker_field_input.rb → ui_bibz_inputs/ui_date_picker_field_input.rb} +2 -2
  18. data/app/inputs/{custom_inputs/dropdown_select_field_input.rb → ui_bibz_inputs/ui_dropdown_select_field_input.rb} +2 -2
  19. data/app/inputs/{custom_inputs/formula_field_input.rb → ui_bibz_inputs/ui_formula_field_input.rb} +2 -2
  20. data/app/inputs/{custom_inputs/markdown_editor_field_input.rb → ui_bibz_inputs/ui_markdown_editor_field_input.rb} +2 -2
  21. data/app/inputs/{custom_inputs/multi_column_field_input.rb → ui_bibz_inputs/ui_multi_column_field_input.rb} +2 -2
  22. data/app/inputs/ui_bibz_inputs/ui_multi_select_field_input.rb +9 -0
  23. data/app/inputs/{custom_inputs/radio_field_input.rb → ui_bibz_inputs/ui_radio_field_input.rb} +2 -2
  24. data/app/inputs/{custom_inputs/select_field_input.rb → ui_bibz_inputs/ui_select_field_input.rb} +2 -2
  25. data/app/inputs/{custom_inputs/switch_field_input.rb → ui_bibz_inputs/ui_switch_field_input.rb} +2 -2
  26. data/app/inputs/ui_bibz_inputs/ui_text_field_input.rb +13 -0
  27. data/config/initializers/ui_bibz.rb +7 -0
  28. data/lib/ui_bibz/helpers/ui/core/cards_helper.rb +42 -0
  29. data/lib/ui_bibz/helpers/ui/core/dropdowns_helper.rb +21 -0
  30. data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +148 -0
  31. data/lib/ui_bibz/helpers/ui/core/layouts_helper.rb +27 -0
  32. data/lib/ui_bibz/helpers/ui/core/lists_helper.rb +11 -0
  33. data/lib/ui_bibz/helpers/ui/core/navs_helper.rb +27 -0
  34. data/lib/ui_bibz/helpers/ui/core/paths_helper.rb +16 -0
  35. data/lib/ui_bibz/helpers/ui/core/windows_helper.rb +11 -0
  36. data/lib/ui_bibz/helpers/ui/core_helper.rb +89 -0
  37. data/lib/ui_bibz/helpers/{ui_ux_helper.rb → ui/ux_helper.rb} +8 -18
  38. data/lib/ui_bibz/helpers/utils_helper.rb +22 -1
  39. data/lib/ui_bibz/rails/engine.rb +6 -2
  40. data/lib/ui_bibz/ui/base.rb +4 -0
  41. data/lib/ui_bibz/ui/core/{tag.rb → badge.rb} +10 -10
  42. data/lib/ui_bibz/ui/core/cards/card.rb +37 -13
  43. data/lib/ui_bibz/ui/core/cards/components/{block/card_block_link.rb → body/card_body_link.rb} +6 -6
  44. data/lib/ui_bibz/ui/core/cards/components/{block/card_block_text.rb → body/card_body_text.rb} +6 -6
  45. data/lib/ui_bibz/ui/core/cards/components/{block/card_block_title.rb → body/card_body_title.rb} +6 -6
  46. data/lib/ui_bibz/ui/core/cards/components/{card_block.rb → card_body.rb} +17 -13
  47. data/lib/ui_bibz/ui/core/cards/components/card_footer.rb +5 -1
  48. data/lib/ui_bibz/ui/core/cards/components/card_header.rb +5 -1
  49. data/lib/ui_bibz/ui/core/cards/components/card_image.rb +3 -2
  50. data/lib/ui_bibz/ui/core/component.rb +8 -6
  51. data/lib/ui_bibz/ui/core/dropdowns/dropdown.rb +21 -5
  52. data/lib/ui_bibz/ui/core/forms/buttons/button.rb +37 -8
  53. data/lib/ui_bibz/ui/core/forms/buttons/button_choice.rb +17 -29
  54. data/lib/ui_bibz/ui/core/forms/buttons/button_group.rb +51 -11
  55. data/lib/ui_bibz/ui/core/forms/buttons/button_link.rb +18 -5
  56. data/lib/ui_bibz/ui/core/forms/buttons/button_refresh.rb +13 -4
  57. data/lib/ui_bibz/ui/core/forms/buttons/button_toolbar.rb +90 -0
  58. data/lib/ui_bibz/ui/core/forms/buttons/components/choice.rb +116 -0
  59. data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +21 -8
  60. data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +22 -9
  61. data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +17 -5
  62. data/lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb +36 -16
  63. data/lib/ui_bibz/ui/core/forms/numbers/formula_field.rb +20 -19
  64. data/lib/ui_bibz/ui/core/forms/selects/abstract_select.rb +99 -0
  65. data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +16 -16
  66. data/lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb +8 -13
  67. data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +17 -18
  68. data/lib/ui_bibz/ui/core/forms/selects/select_field.rb +8 -20
  69. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_addon.rb +25 -0
  70. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button.rb +16 -0
  71. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_group.rb +16 -0
  72. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_link.rb +16 -0
  73. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_refresh.rb +16 -0
  74. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_checkbox_field.rb +16 -0
  75. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_dropdown.rb +16 -0
  76. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_radio_field.rb +16 -0
  77. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_switch_field.rb +16 -0
  78. data/lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb +153 -0
  79. data/lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb +13 -38
  80. data/lib/ui_bibz/ui/core/forms/texts/text_field.rb +81 -0
  81. data/lib/ui_bibz/ui/core/glyph.rb +1 -1
  82. data/lib/ui_bibz/ui/core/layouts/col.rb +10 -2
  83. data/lib/ui_bibz/ui/core/layouts/row.rb +7 -1
  84. data/lib/ui_bibz/ui/core/lists/components/list/list_body.rb +4 -2
  85. data/lib/ui_bibz/ui/core/lists/components/list/list_header.rb +5 -2
  86. data/lib/ui_bibz/ui/core/lists/components/list.rb +35 -14
  87. data/lib/ui_bibz/ui/core/lists/list_group.rb +4 -4
  88. data/lib/ui_bibz/ui/core/navs/components/navbar_form.rb +7 -2
  89. data/lib/ui_bibz/ui/core/navs/components/navbar_nav.rb +4 -0
  90. data/lib/ui_bibz/ui/core/navs/components/navbar_text.rb +1 -1
  91. data/lib/ui_bibz/ui/core/navs/components/pagination_link.rb +60 -0
  92. data/lib/ui_bibz/ui/core/navs/nav.rb +31 -3
  93. data/lib/ui_bibz/ui/core/navs/navbar.rb +32 -22
  94. data/lib/ui_bibz/ui/core/navs/pagination.rb +97 -0
  95. data/lib/ui_bibz/ui/core/{alert.rb → notifications/alert.rb} +23 -11
  96. data/lib/ui_bibz/ui/core/notifications/components/alert_body.rb +50 -0
  97. data/lib/ui_bibz/ui/core/notifications/components/alert_header.rb +67 -0
  98. data/lib/ui_bibz/ui/core/{progress.rb → progresses/components/bar.rb} +21 -28
  99. data/lib/ui_bibz/ui/core/progresses/progress_bar.rb +115 -0
  100. data/lib/ui_bibz/ui/core/windows/components/modal_header.rb +1 -1
  101. data/lib/ui_bibz/ui/{core → extensions/core}/component/glyph_extension.rb +2 -2
  102. data/lib/ui_bibz/ui/{core → extensions/core}/component/klass_extension.rb +1 -2
  103. data/lib/ui_bibz/ui/extensions/core/forms/connect_extension.rb +31 -0
  104. data/lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb +48 -0
  105. data/lib/ui_bibz/utils/internationalization.rb +9 -0
  106. data/lib/ui_bibz/version.rb +1 -1
  107. data/lib/ui_bibz.rb +23 -7
  108. data/test/simple_form_test.rb +58 -41
  109. data/test/ui/core/badge_test.rb +19 -0
  110. data/test/ui/core/cards/card_test.rb +34 -35
  111. data/test/ui/{component_test.rb → core/component_test.rb} +0 -1
  112. data/test/ui/core/dropdowns/dropdown_test.rb +5 -5
  113. data/test/ui/core/forms/buttons/button_choice_test.rb +23 -7
  114. data/test/ui/core/forms/buttons/button_group_test.rb +35 -17
  115. data/test/ui/core/forms/buttons/button_link_test.rb +74 -4
  116. data/test/ui/core/forms/buttons/button_refresh_test.rb +1 -2
  117. data/test/ui/core/forms/buttons/button_test.rb +66 -3
  118. data/test/ui/core/forms/choices/checkbox_field_test.rb +1 -2
  119. data/test/ui/core/forms/choices/radio_field_test.rb +1 -2
  120. data/test/ui/core/forms/choices/switch_field_test.rb +0 -1
  121. data/test/ui/core/forms/dates/date_picker_field_test.rb +2 -3
  122. data/test/ui/core/forms/numbers/formula_field_test.rb +1 -2
  123. data/test/ui/core/forms/selects/dropdown_select_field_test.rb +1 -2
  124. data/test/ui/core/forms/selects/multi_column_field_test.rb +0 -1
  125. data/test/ui/core/forms/selects/multi_select_field_test.rb +1 -2
  126. data/test/ui/core/forms/selects/select_field_test.rb +1 -2
  127. data/test/ui/core/forms/surrounds/surround_field_test.rb +58 -0
  128. data/test/ui/core/forms/textareas/markdown_editor_field_test.rb +0 -1
  129. data/test/ui/core/forms/texts/auto_complete_field_test.rb +21 -4
  130. data/test/ui/core/forms/texts/text_field_test.rb +25 -0
  131. data/test/ui/{glyph_test.rb → core/glyph_test.rb} +5 -5
  132. data/test/ui/core/jumbotron_test.rb +20 -0
  133. data/test/ui/core/layouts/col_test.rb +31 -0
  134. data/test/ui/core/layouts/container_test.rb +13 -0
  135. data/test/ui/core/layouts/row_test.rb +24 -0
  136. data/test/ui/core/lists/list_group_test.rb +5 -4
  137. data/test/ui/core/navs/nav_test.rb +4 -5
  138. data/test/ui/core/navs/navbar_test.rb +39 -0
  139. data/test/ui/core/notifications/alert_test.rb +22 -0
  140. data/test/ui/core/paths/breadcrumb_test.rb +15 -4
  141. data/test/ui/core/progress_test.rb +14 -0
  142. data/test/ui/{star_test.rb → core/star_test.rb} +6 -7
  143. data/test/ui/core/windows/modal_test.rb +20 -0
  144. data/test/ui/ux/tables/table_test.rb +2 -3
  145. data/ui_bibz.gemspec +2 -1
  146. data/vendor/assets/javascripts/bootstrap-select.min.js +8 -7
  147. data/vendor/assets/stylesheets/awesome-bootstrap-checkbox.scss +62 -42
  148. data/vendor/assets/stylesheets/bootstrap-multiselect.min.css +1 -1
  149. data/vendor/assets/stylesheets/bootstrap-select.min.css +3 -3
  150. data/vendor/assets/stylesheets/bootstrap-theme.min.css +1 -1
  151. metadata +105 -44
  152. data/app/inputs/custom_inputs/auto_complete_field_input.rb +0 -16
  153. data/app/inputs/custom_inputs/multi_select_field_input.rb +0 -9
  154. data/app/inputs/custom_inputs/surround_field_input.rb +0 -10
  155. data/lib/ui_bibz/helpers/ui_core_helper.rb +0 -347
  156. data/lib/ui_bibz/ui/core/connected_component.rb +0 -87
  157. data/lib/ui_bibz/ui/core/forms/texts/surround_field.rb +0 -87
  158. data/test/ui/core/forms/texts/surround_field_test.rb +0 -26
  159. data/test/ui/grid_test.rb +0 -31
  160. data/test/ui_helper_test.rb +0 -109
@@ -0,0 +1,58 @@
1
+ require 'test_helper'
2
+
3
+ class SurroundFieldTest < ActionView::TestCase
4
+
5
+ test 'surround_field with glyph' do
6
+ actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf|
7
+ sf.glyph 'pencil'
8
+ end.render
9
+ expected = "<div class=\"input-group\"><span class=\"input-group-addon\"><i class=\"glyph fa fa-pencil\"></i></span></div>"
10
+
11
+ assert_equal expected, actual
12
+ end
13
+
14
+ test 'surround_field with addon' do
15
+ actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf|
16
+ sf.addon 'content addon'
17
+ end.render
18
+ expected = "<div class=\"input-group\"><span class=\"input-group-addon\">content addon</span></div>"
19
+
20
+ assert_equal expected, actual
21
+ end
22
+
23
+ test 'surround_field with dropdown' do
24
+ actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf|
25
+ sf.dropdown "Dropdown" do |d|
26
+ d.link 'Link 1', url: '#link1', glyph: 'eye'
27
+ d.header 'header'
28
+ d.link 'Link 2', url: '#link2'
29
+ d.divider
30
+ d.link 'Link3', url: '#link3'
31
+ end
32
+ end.render
33
+ expected = "<div class=\"input-group\"><div class=\"dropdown btn-group input-group-btn\"><button class=\"btn btn-primary 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=\"#link1\"><i class=\"glyph fa fa-eye\"></i> Link 1</a><h6 class=\"dropdown-header\" role=\"presentation\">header</h6><a class=\"dropdown-item\" href=\"#link2\">Link 2</a><div class=\"dropdown-divider\"></div><a class=\"dropdown-item\" href=\"#link3\">Link3</a></div></div></div>"
34
+
35
+ assert_equal expected, actual
36
+ end
37
+
38
+ test 'surround_field with button' do
39
+ actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf|
40
+ sf.button 'Submit'
41
+ end.render
42
+ expected = "<div class=\"input-group\"><div class=\"input-group-btn\"><button class=\"btn-primary btn\">Submit</button></div></div>"
43
+
44
+ assert_equal expected, actual
45
+ end
46
+
47
+ test 'surround_field with button, addon, glyph' do
48
+ actual = UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new.tap do |sf|
49
+ sf.button 'Submit'
50
+ sf.addon '€'
51
+ sf.glyph 'pencil'
52
+ end.render
53
+ expected = "<div class=\"input-group\"><div class=\"input-group-btn\"><button class=\"btn-primary btn\">Submit</button></div><span class=\"input-group-addon\">€</span><span class=\"input-group-addon\"><i class=\"glyph fa fa-pencil\"></i></span></div>"
54
+
55
+ assert_equal expected, actual
56
+ end
57
+ end
58
+
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- include UiBibz::Helpers
3
2
 
4
3
  class MarkdownEditorFieldTest < ActionView::TestCase
5
4
 
@@ -1,12 +1,11 @@
1
1
  require 'test_helper'
2
- include UiBibz::Helpers
3
2
 
4
3
  class AutoCompleteFieldTest < ActionView::TestCase
5
4
 
6
5
  test 'auto_complete_field' do
7
6
  options = options_for_select(2.times.map{ |i| "option #{i}" })
8
7
  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>
8
+ expected = "<input type=\"text\" name=\"test\" id=\"test\" class=\"form-control auto-complete-field\" autocomplete=\"true\" list=\"test-datalist\" /><datalist id=\"test-datalist\"><option value=\"option 0\">option 0</option>
10
9
  <option value=\"option 1\">option 1</option></datalist>"
11
10
 
12
11
  assert_equal expected, actual
@@ -15,8 +14,26 @@ class AutoCompleteFieldTest < ActionView::TestCase
15
14
  test 'auto_complete_field with refresh button' do
16
15
  options = options_for_select(2.times.map{ |i| "option #{i}" })
17
16
  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\"><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;&quot;,&quot;url&quot;:&quot;&quot;,&quot;data&quot;:[]}}\" class=\"btn-primary ui-bibz-connect input-refresh-button btn\"><i class=\"glyph fa fa-refresh\"></i> </span></span></div>"
17
+ expected = "<div class=\"field-refresh input-group\"><input type=\"text\" name=\"test\" id=\"test\" class=\"form-control auto-complete-field\" autocomplete=\"true\" list=\"test-datalist\" /><datalist id=\"test-datalist\"><option value=\"option 0\">option 0</option>
18
+ <option value=\"option 1\">option 1</option></datalist><div class=\"input-group-btn\"><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#test-datalist&quot;,&quot;url&quot;:&quot;/&quot;,&quot;data&quot;:[]}}\" class=\"btn-primary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fa fa-refresh\"></i> </span></div></div>"
19
+
20
+ assert_equal expected, actual
21
+ end
22
+
23
+ test 'auto_complete_field with refresh button and append content' do
24
+ options = options_for_select(2.times.map{ |i| "option #{i}" })
25
+ actual = UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new('test', { option_tags: options, append: 'Append content', refresh: { target: { url: '/'}} }, { id: 'test' }).render
26
+ expected = "<div class=\"field-refresh input-group\"><span class=\"input-group-addon\">Append content</span><input type=\"text\" name=\"test\" id=\"test\" class=\"form-control auto-complete-field\" autocomplete=\"true\" list=\"test-datalist\" /><datalist id=\"test-datalist\"><option value=\"option 0\">option 0</option>
27
+ <option value=\"option 1\">option 1</option></datalist><div class=\"input-group-btn\"><span data-connect=\"{&quot;events&quot;:&quot;click&quot;,&quot;mode&quot;:&quot;remote&quot;,&quot;target&quot;:{&quot;selector&quot;:&quot;#test-datalist&quot;,&quot;url&quot;:&quot;/&quot;,&quot;data&quot;:[]}}\" class=\"btn-primary ui-bibz-connect btn input-refresh-button\"><i class=\"glyph fa fa-refresh\"></i> </span></div></div>"
28
+
29
+ assert_equal expected, actual
30
+ end
31
+
32
+ test 'auto_complete_field with prepend content' do
33
+ options = options_for_select(2.times.map{ |i| "option #{i}" })
34
+ actual = UiBibz::Ui::Core::Forms::Texts::AutoCompleteField.new('test', { option_tags: options, prepend: 'Append content' }, { id: 'test' }).render
35
+ expected = "<div class=\"input-group\"><input type=\"text\" name=\"test\" id=\"test\" class=\"form-control auto-complete-field\" autocomplete=\"true\" list=\"test-datalist\" /><datalist id=\"test-datalist\"><option value=\"option 0\">option 0</option>
36
+ <option value=\"option 1\">option 1</option></datalist><span class=\"input-group-addon\">Append content</span></div>"
20
37
 
21
38
  assert_equal expected, actual
22
39
  end
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+ class TextFieldTest < ActionView::TestCase
4
+
5
+ test 'text_field without prepend and append' do
6
+ actual = UiBibz::Ui::Core::Forms::Texts::TextField.new('test').render
7
+ expected = "<input type=\"text\" name=\"test\" id=\"test\" class=\"form-control\" />"
8
+
9
+ assert_equal expected, actual
10
+ end
11
+
12
+ test 'text_field with prepend and append' do
13
+ actual = UiBibz::Ui::Core::Forms::Texts::TextField.new('test', append: '1', prepend: '2').render
14
+ expected = "<div class=\"input-group\"><span class=\"input-group-addon\">1</span><input type=\"text\" name=\"test\" id=\"test\" class=\"form-control\" /><span class=\"input-group-addon\">2</span></div>"
15
+
16
+ assert_equal expected, actual
17
+ end
18
+
19
+ test 'text_field size' do
20
+ actual = UiBibz::Ui::Core::Forms::Texts::TextField.new('test', size: :xs, append: '1', prepend: '2').render
21
+ expected = "<div class=\"input-group-xs input-group\"><span class=\"input-group-addon\">1</span><input type=\"text\" name=\"test\" id=\"test\" class=\"form-control\" /><span class=\"input-group-addon\">2</span></div>"
22
+
23
+ assert_equal expected, actual
24
+ end
25
+ end
@@ -1,28 +1,28 @@
1
1
  require 'test_helper'
2
2
 
3
- include UiBibz::Helpers
4
3
  class GlyphTest < ActionView::TestCase
4
+ include UiBibz::Helpers::Ui::CoreHelper
5
5
 
6
6
  test 'create glyph with a name' do
7
- actual = UiBibz::Ui::Core::Glyph.new('add').render
7
+ actual = ui_glyph('add')
8
8
  expected = '<i class="glyph fa fa-add"></i>'
9
9
  assert_equal expected, actual
10
10
  end
11
11
 
12
12
  test 'create glyph with hash' do
13
- actual = UiBibz::Ui::Core::Glyph.new({ name: 'add', size: 3, type: 'li'}).render
13
+ actual = ui_glyph({ name: 'add', size: 3, type: 'li'})
14
14
  expected = '<i class="glyph fa fa-add fa-3x fa-li"></i>'
15
15
  assert_equal expected, actual
16
16
  end
17
17
 
18
18
  test 'create glyph with name and hash' do
19
- actual = UiBibz::Ui::Core::Glyph.new('add', { size: 3, type: 'li' }).render
19
+ actual = ui_glyph('add', { size: 3, type: 'li' })
20
20
  expected = '<i class="glyph fa fa-add fa-3x fa-li"></i>'
21
21
  assert_equal expected, actual
22
22
  end
23
23
 
24
24
  test 'create glyph with label' do
25
- actual = UiBibz::Ui::Core::Glyph.new('add', { label: 'Example' }).render
25
+ actual = ui_glyph('add', { label: 'Example' })
26
26
  expected = "<i class=\"glyph fa fa-add\"></i> Example"
27
27
  assert_equal expected, actual
28
28
  end
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+ require 'test_helper'
3
+
4
+ class UiHelperTest < ActionView::TestCase
5
+ include UiBibz::Helpers::Ui::CoreHelper
6
+
7
+ test 'jumbotron with full_width' do
8
+ actual = ui_jumbotron 'state', full_width: true
9
+ expected = "<div class=\"jumbotron\">state</div>"
10
+
11
+ assert_equal expected, actual
12
+ end
13
+
14
+ test 'jumbotron' do
15
+ actual = ui_jumbotron 'state'
16
+ expected = "<div class=\"jumbotron\">state</div>"
17
+
18
+ assert_equal expected, actual
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ class ColTest < ActionView::TestCase
4
+ include UiBibz::Helpers::Ui::CoreHelper
5
+
6
+ test "col with options" do
7
+ actual = ui_col('test', { num: 1, push: 2, offset: 3, pull: 4 }, { class: 'test' })
8
+ expected = "<div class=\"test col-md-1 col-md-push-2 offset-md-3 col-md-pull-4\">test</div>"
9
+
10
+ assert_equal expected, actual
11
+ end
12
+
13
+ test "col with several cols" do
14
+ actual = ui_col(md: { num: 1, push: 2, pull: 4 }, xl: { num: 6, offset: 5 }, class: 'test') do
15
+ "test"
16
+ end
17
+ expected = "<div class=\"test col-md-1 col-md-push-2 col-md-pull-4 col-xl-6 offset-xl-5\">test</div>"
18
+
19
+ assert_equal expected, actual
20
+ end
21
+
22
+ test "col" do
23
+ actual = ui_col do
24
+ "test"
25
+ end
26
+ expected = "<div class=\"col\">test</div>"
27
+
28
+ assert_equal expected, actual
29
+ end
30
+
31
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+ require 'test_helper'
3
+
4
+ class UiHelperTest < ActionView::TestCase
5
+ include UiBibz::Helpers::Ui::CoreHelper
6
+
7
+ test 'container' do
8
+ actual = ui_container type: :fluid
9
+ expected = "<div class=\"container-fluid\"></div>"
10
+
11
+ assert_equal expected, actual
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ require 'test_helper'
2
+
3
+ class RowTest < ActionView::TestCase
4
+ include UiBibz::Helpers::Ui::CoreHelper
5
+
6
+ test 'row' do
7
+ actual = ui_row(class: 'test') do
8
+ 'test'
9
+ end
10
+ expected = "<div class=\"test row\">test</div>"
11
+
12
+ assert_equal expected, actual
13
+ end
14
+
15
+ test 'row form' do
16
+ actual = ui_row(type: :form) do
17
+ 'test'
18
+ end
19
+ expected = "<div class=\"form-row\">test</div>"
20
+
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ end
@@ -1,22 +1,23 @@
1
1
  require 'test_helper'
2
- include UiBibz::Helpers
2
+
3
3
  class ListGroupTest < ActionView::TestCase
4
+ include UiBibz::Helpers::Ui::CoreHelper
4
5
 
5
6
  test 'list_group with link' do
6
- actual = UiBibz::Ui::Core::Lists::ListGroup.new(type: :link).tap do |lg|
7
+ actual = ui_list_group(type: :link) do |lg|
7
8
  lg.list 'Momo', { status: :success, url: '#momo' }
8
9
  lg.list({ tap: true, active: true, url: '#state' }) do |l|
9
10
  l.header 'My title'
10
11
  l.body 'My body'
11
12
  end
12
- end.render
13
+ end
13
14
  expected = "<div class=\"list-group\"><a class=\"list-group-item-success list-group-item\" href=\"#momo\">Momo</a><a type=\"link\" class=\"list-group-item\" href=\"#state\"><h4 class=\"list-group-item-heading\">My title</h4><p class=\"list-group-item-text\">My body</p></a></div>"
14
15
 
15
16
  assert_equal expected, actual
16
17
  end
17
18
 
18
19
  test 'list_group' do
19
- actual = UiBibz::Ui::Core::Lists::ListGroup.new().tap do |lg|
20
+ actual = ui_list_group(type: :link) do |lg|
20
21
  lg.list 'Lulu'
21
22
  lg.list 'state'
22
23
  end.render
@@ -1,23 +1,22 @@
1
1
  require 'test_helper'
2
- include UiBibz::Helpers
3
2
  class NavTest < ActionView::TestCase
4
3
 
5
4
  test 'Nav with tab' do
6
- actual = UiBibz::Ui::Core::Navs::Nav.new(type: :tabs).tap do |n|
5
+ actual = ui_nav(type: :tabs) do |n|
7
6
  n.link 'Home', state: :active, url: "#Home", selector: 'home'
8
7
  n.link 'Profile', url: "#profile", selector: 'profile'
9
8
  n.link 'Messages', url: "#messages", selector: 'messages'
10
- end.render
9
+ end
11
10
  expected = "<ul class=\"nav nav-tabs\"><li class=\"nav-item\"><a class=\"active nav-link\" data-toggle=\"tab\" role=\"tab\" href=\"#Home\">Home</a></li><li class=\"nav-item\"><a class=\"nav-link\" data-toggle=\"tab\" role=\"tab\" href=\"#profile\">Profile</a></li><li class=\"nav-item\"><a class=\"nav-link\" data-toggle=\"tab\" role=\"tab\" href=\"#messages\">Messages</a></li></ul>"
12
11
  assert_equal expected, actual
13
12
  end
14
13
 
15
14
  test 'Nav with pills' do
16
- actual = UiBibz::Ui::Core::Navs::Nav.new(type: :pills, position: :justified).tap do |n|
15
+ actual = ui_nav(type: :pills, position: :justified) do |n|
17
16
  n.link 'Home', state: :active, url: "#Home", selector: 'home'
18
17
  n.link 'Profile', url: "#profile", selector: 'profile', label: 16
19
18
  n.link 'Messages', url: "#messages", selector: 'messages', state: :disabled
20
- end.render
19
+ end
21
20
  expected = "<ul class=\"nav nav-pills pull-justified\"><li class=\"nav-item\"><a class=\"active nav-link\" href=\"#Home\">Home</a></li><li class=\"nav-item\"><a class=\"nav-link\" href=\"#profile\">Profile</a></li><li class=\"nav-item\"><a class=\"disabled nav-link\" href=\"#messages\">Messages</a></li></ul>"
22
21
 
23
22
  assert_equal expected, actual
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+ class NavbarTest < ActionView::TestCase
3
+
4
+ test 'Navbar' do
5
+ actual = UiBibz::Ui::Core::Navs::Navbar.new.tap do |nb|
6
+ end
7
+ expected = "<nav class=\"navbar navbar-light navbar-expand-lg\"><button class=\"navbar-toggler hidden-sm-up\" type=\"button\" data-toggle=\"collapse\" data-target=\"##{ actual.id }\">☰</button><div class=\"collapse navbar-collapse\" id=\"#{ actual.id }\"></div></nav>"
8
+
9
+ assert_equal expected, actual.render
10
+ end
11
+
12
+ test 'Navbar with options' do
13
+ actual = UiBibz::Ui::Core::Navs::Navbar.new(title: 'Brand', expand_size: :xs, status: :primary, position: :top, brand_position: :right).tap do |nb|
14
+ end
15
+ expected = "<nav class=\"bg-primary navbar navbar-light fixed-top navbar-expand-xs\"><button class=\"navbar-toggler hidden-sm-up\" type=\"button\" data-toggle=\"collapse\" data-target=\"##{ actual.id }\">☰</button><a class=\"navbar-brand\" href=\"/\">Brand</a><div class=\"collapse navbar-collapse\" id=\"#{ actual.id }\"></div></nav>"
16
+
17
+ assert_equal expected, actual.render
18
+ end
19
+
20
+ test 'Navbar with brand, nav, form and text' do
21
+ actual = UiBibz::Ui::Core::Navs::Navbar.new.tap do |nb|
22
+ nb.brand "Brand"
23
+ nb.nav do |n|
24
+ n.link 'Home', state: :active, url: "#Home", selector: 'home'
25
+ n.link 'Profile', url: "#profile", selector: 'profile'
26
+ n.link 'Messages', url: "#messages", selector: 'messages'
27
+ end
28
+ nb.form "#", { type: :form_tag, position: :right } do
29
+ UiBibz::Ui::Core::Forms::Texts::TextField.new('search').render
30
+ UiBibz::Ui::Core::Forms::Buttons::Button.new('Search').render
31
+ end
32
+ nb.text 'test'
33
+ end
34
+ expected = "<nav class=\"navbar navbar-light navbar-expand-lg\"><a class=\"navbar-brand\" href=\"/\">Brand</a><button class=\"navbar-toggler hidden-sm-up\" type=\"button\" data-toggle=\"collapse\" data-target=\"##{ actual.id }\">☰</button><div class=\"collapse navbar-collapse\" id=\"#{ actual.id }\"><ul class=\"navbar-nav mr-auto\"><li class=\"nav-item\"><a class=\"active nav-link\" href=\"#Home\">Home</a></li><li class=\"nav-item\"><a class=\"nav-link\" href=\"#profile\">Profile</a></li><li class=\"nav-item\"><a class=\"nav-link\" href=\"#messages\">Messages</a></li></ul><form type=\"form_tag\" position=\"right\" class=\"navbar-form form-inline pull-right\" action=\"#\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><button class=\"btn-primary btn\">Search</button></form><span class=\"navbar-text\">test</span></div></nav>"
35
+
36
+ assert_equal expected, actual.render
37
+ end
38
+
39
+ end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+ class AlertTest < ActionView::TestCase
3
+ include UiBibz::Helpers::Ui::CoreHelper
4
+
5
+ test 'alert' do
6
+ actual = ui_alert 'state'
7
+ expected = "<div class=\"alert-info alert alert-dismissible\" role=\"alert\">state</div>"
8
+
9
+ assert_equal expected, actual
10
+ end
11
+
12
+ test 'alert with more informaton' do
13
+ actual = ui_alert(tap: true, status: :success, glyph: 'thumbs-o-up', closable: true) do |a|
14
+ a.header 'Information'
15
+ a.body 'Body text'
16
+ end
17
+ expected = "<div class=\"alert-success alert alert-dismissible\" role=\"alert\"><h4 class=\"alert-header\"><i class=\"glyph fa fa-thumbs-o-up\"></i> Information<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button></h4><hr /><p class=\"alert-body mb-0\">Body text</p></div>"
18
+
19
+ assert_equal expected, actual
20
+ end
21
+
22
+ end
@@ -1,26 +1,37 @@
1
1
  require 'test_helper'
2
- include UiBibz::Helpers
3
2
 
4
3
  class BreadcrumbTest < ActionView::TestCase
4
+ include UiBibz::Helpers::Ui::CoreHelper
5
5
 
6
6
  test 'breadcrumb' do
7
- actual = UiBibz::Ui::Core::Paths::Breadcrumb.new.tap do |b|
7
+ actual = ui_breadcrumb do |b|
8
8
  b.link 'Home', url: '#home', glyph: 'home'
9
9
  b.link 'state', { url: '#state', state: :active }
10
- end.render
10
+ end
11
11
  expected = "<ol class=\"breadcrumb\"><li class=\"breadcrumb-item\"><a href=\"#home\"><i class=\"glyph fa fa-home\"></i> Home</a></li><li class=\"active breadcrumb-item\"><a href=\"#state\">state</a></li></ol>"
12
12
 
13
13
  assert_equal expected, actual
14
14
  end
15
15
 
16
+ #test 'breadcrumb with nav' do
17
+ #actual = UiBibz::Ui::Core::Paths::Breadcrumb.new(type: :nav).tap do |b|
18
+ #b.link 'Home', url: '#home', glyph: 'home'
19
+ #b.link 'state', { url: '#state', state: :active }
20
+ #end.render
21
+ #expected = ""
22
+
23
+ #assert_equal expected, actual
24
+ #end
25
+
16
26
  test 'breadcrumb with store' do
17
27
  users = create_list(:user, 3)
18
- actual = UiBibz::Ui::Core::Paths::Breadcrumb.new(store: users, link_label: :name_fr, link_url: user_path(:id)).render
28
+ actual = ui_breadcrumb(store: users, link_label: :name_fr, link_url: user_path(:id))
19
29
  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>"
20
30
 
21
31
  assert_equal expected, actual
22
32
  end
23
33
 
24
34
 
35
+
25
36
  end
26
37
 
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+ require 'test_helper'
3
+
4
+ class UiHelperTest < ActionView::TestCase
5
+ include UiBibz::Helpers::Ui::CoreHelper
6
+
7
+ test 'progress bar' do
8
+ actual = ui_progress(20)
9
+ expected = "<progress class=\"progress\" max=\"100\" value=\"20\">20</progress>"
10
+
11
+ assert_equal expected, actual
12
+ end
13
+
14
+ end
@@ -1,40 +1,39 @@
1
1
  require 'test_helper'
2
2
 
3
- include UiBibz::Helpers
4
3
  class StarTest < ActionView::TestCase
5
4
 
6
5
  test "stars with 1" do
7
- actual = UiBibz::Ui::Core::Star.new(1).render
6
+ actual = ui_star(1)
8
7
  expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i></span>"
9
8
  assert_equal expected, actual
10
9
  end
11
10
 
12
11
  test "stars with 2.1" do
13
- actual = UiBibz::Ui::Core::Star.new(2.1).render
12
+ actual = ui_star(2.1)
14
13
  expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star-half-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i></span>"
15
14
  assert_equal expected, actual
16
15
  end
17
16
 
18
17
  test "stars with 3.6 with status danger" do
19
- actual = UiBibz::Ui::Core::Star.new(3.6, { status: :danger }).render
18
+ actual = ui_star(3.6, { status: :danger })
20
19
  expected = "<span class=\"stars-notation\"><i class=\"glyph-danger glyph fa fa-star\"></i> <i class=\"glyph-danger glyph fa fa-star\"></i> <i class=\"glyph-danger glyph fa fa-star\"></i> <i class=\"glyph-danger glyph fa fa-star-half-o\"></i> <i class=\"glyph-danger glyph fa fa-star-o\"></i></span>"
21
20
  assert_equal expected, actual
22
21
  end
23
22
 
24
23
  test "stars with 4.9" do
25
- actual = UiBibz::Ui::Core::Star.new(4.9).render
24
+ actual = ui_star(4.9)
26
25
  expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star-half-o\"></i></span>"
27
26
  assert_equal expected, actual
28
27
  end
29
28
 
30
29
  test "stars with 5" do
31
- actual = UiBibz::Ui::Core::Star.new(5).render
30
+ actual = ui_star.new(5)
32
31
  expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i></span>"
33
32
  assert_equal expected, actual
34
33
  end
35
34
 
36
35
  test "stars with number options 11.2" do
37
- actual = UiBibz::Ui::Core::Star.new(2.5, { num: 11.2 }).render
36
+ actual = ui_star(2.5, { num: 11.2 })
38
37
  expected = "<span class=\"stars-notation\"><i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star\"></i> <i class=\"glyph fa fa-star-half-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i> <i class=\"glyph fa fa-star-o\"></i></span>"
39
38
  assert_equal expected, actual
40
39
  end
@@ -0,0 +1,20 @@
1
+ # encoding: UTF-8
2
+ require 'test_helper'
3
+
4
+ class UiHelperTest < ActionView::TestCase
5
+ include UiBibz::Helpers::Ui::CoreHelper
6
+
7
+ test 'modal' do
8
+ actual = ui_modal do |m|
9
+ m.header 'My title'
10
+ m.body 'My body'
11
+ m.footer do
12
+ concat ui_button_link 'Close', url: '#', status: :link
13
+ concat ui_button_link 'Save', url: '#', status: :primary
14
+ end
15
+ end
16
+ expected = "<div class=\"modal\"><div class=\"modal-dialog \" role=\"document\"><div class=\"modal-content\"><div class=\"modal-header\"><button class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button><h4 class=\"modal-title\">My title</h4></div><div class=\"modal-body\">My body</div><div class=\"modal-footer\"><a class=\"btn-link btn\" href=\"#\">Close</a><a class=\"btn-primary btn\" href=\"#\">Save</a></div></div></div></div>"
17
+
18
+ assert_equal expected, actual
19
+ end
20
+ end
@@ -4,7 +4,6 @@ require "ui_bibz/ui/ux/tables/extensions/paginable"
4
4
  require "ui_bibz/ui/ux/tables/extensions/searchable"
5
5
  require "ui_bibz/ui/ux/tables/extensions/sortable"
6
6
  require "ui_bibz/ui/ux/tables/extensions/actionable"
7
- include UiBibz::Helpers
8
7
 
9
8
  class TableTest < ActionView::TestCase
10
9
 
@@ -154,7 +153,7 @@ class TableTest < ActionView::TestCase
154
153
  test 'complex table_card' do
155
154
  actual = UiBibz::Ui::Ux::Tables::TableCard.new({ store: @users, tap: true }, { class: 'state' }).tap do |pane|
156
155
  pane.header 'Test header'
157
- pane.block class: 'ui' do
156
+ pane.body class: 'ui' do
158
157
  'Test body'
159
158
  end
160
159
  end.render
@@ -163,7 +162,7 @@ class TableTest < ActionView::TestCase
163
162
  test 'complex table_card with custom actions' do
164
163
  actual = UiBibz::Ui::Ux::Tables::TableCard.new({ store: @users, tap: true }, { class: 'state'}).tap do |pane|
165
164
  pane.header 'Test header'
166
- pane.block cls: 'ui' do
165
+ pane.body cls: 'ui' do
167
166
  'Test body'
168
167
  end
169
168
  pane.columns do |c|
data/ui_bibz.gemspec CHANGED
@@ -32,10 +32,11 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency 'will-paginate-i18n'
33
33
  s.add_dependency 'will_paginate-bootstrap4'
34
34
  s.add_dependency 'haml'
35
+ s.add_dependency 'jquery-rails', '>= 3.1.0'
35
36
  s.add_dependency 'haml-rails'
36
37
  s.add_dependency 'sass-rails', '>= 5.0.0'
37
38
  s.add_dependency 'font-awesome-sass'
38
- s.add_dependency 'bootstrap', '4.0.0.alpha5'
39
+ s.add_dependency 'bootstrap', '4.0.0.beta2'
39
40
 
40
41
  # Javascript gems (rails-assets.org)
41
42
  #s.add_dependency 'rails-assets-tether', '>= 1.1.0'