ui_bibz 2.0.0.alpha32 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,8 +1,7 @@
1
1
  module KlassExtension
2
2
 
3
3
  def join_classes *classes
4
- klasses = [*classes].flatten.compact.uniq.reject(&:blank?)
5
- klasses.empty? ? nil : klasses
4
+ UiBibz::Utils::Screwdriver.join_classes classes
6
5
  end
7
6
 
8
7
  # Override this method to add a status class
@@ -0,0 +1,31 @@
1
+ module ConnectExtension
2
+
3
+ private
4
+
5
+ def component_html_data
6
+ super
7
+ connect_options
8
+ end
9
+
10
+ def connect_options_selector
11
+ content.to_s.parameterize.underscore
12
+ end
13
+
14
+ def connect_opts
15
+ selector = options[:refresh][:target][:selector]
16
+ options[:refresh][:target][:selector] = selector.blank? ? "##{ connect_options_selector }" : selector
17
+
18
+ options[:refresh].merge({
19
+ connect: {
20
+ target: options[:refresh].delete(:target),
21
+ event: options[:refresh].delete(:event),
22
+ mode: options[:refresh].delete(:mode)
23
+ }
24
+ })
25
+ end
26
+
27
+ def connect_options
28
+ add_html_data('connect', options[:connect]) if options[:connect]
29
+ end
30
+
31
+ end
@@ -0,0 +1,48 @@
1
+ require 'ui_bibz/ui/extensions/core/forms/connect_extension'
2
+ module SurroundExtension
3
+ include ConnectExtension
4
+
5
+ private
6
+
7
+ def surrounded?
8
+ !options[:append].nil? || !options[:prepend].nil? || !options[:refresh].nil? || !options[:surrounded].nil?
9
+ end
10
+
11
+ def surround_wrapper_tag ct_tag
12
+ UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new(class: surround_classes).tap do |sf|
13
+ sf.addon options[:append] unless options[:append].nil?
14
+ sf.html ct_tag
15
+ sf.button_refresh connect_opts unless options[:refresh].nil?
16
+ sf.addon options[:prepend] unless options[:prepend].nil?
17
+ end.render
18
+ end
19
+
20
+ def surround_field field_tag, options = {}
21
+ surrounded? ? surround_wrapper_tag(field_tag) : field_tag
22
+ end
23
+
24
+ def input_group_classes
25
+ end
26
+
27
+ def surround_classes
28
+ [input_group_refresh, input_group_classes]
29
+ end
30
+
31
+ def input_group_refresh
32
+ "field-refresh" unless options[:refresh].nil?
33
+ end
34
+
35
+ def input_group_classes
36
+ [input_group_status, input_group_size]
37
+ end
38
+
39
+ # :lg, :sm or :xs
40
+ def input_group_size
41
+ "input-group-#{ options[:size] }" unless options[:size].nil?
42
+ end
43
+
44
+ def input_group_status
45
+ "has-#{ options[:status] }" unless options[:status].nil?
46
+ end
47
+
48
+ end
@@ -1,4 +1,13 @@
1
1
  module UiBibz::Utils
2
+ class Screwdriver
3
+ include Singleton
4
+
5
+ def self.join_classes *classes
6
+ klasses = [*classes].flatten.compact.uniq.reject(&:blank?)
7
+ klasses.empty? ? nil : klasses
8
+ end
9
+
10
+ end
2
11
  class Internationalization
3
12
 
4
13
  def initialize translation, options = {}
@@ -1,3 +1,3 @@
1
1
  module UiBibz
2
- VERSION = "2.0.0.alpha32"
2
+ VERSION = "2.0.0.beta2"
3
3
  end
data/lib/ui_bibz.rb CHANGED
@@ -42,6 +42,7 @@ module UiBibz
42
42
  end
43
43
 
44
44
  module Selects
45
+ autoload :AbstractSelect, "ui_bibz/ui/core/forms/selects/abstract_select"
45
46
  autoload :DropdownSelectField, "ui_bibz/ui/core/forms/selects/dropdown_select_field"
46
47
  autoload :SelectField, "ui_bibz/ui/core/forms/selects/select_field"
47
48
  autoload :MultiColumnField, "ui_bibz/ui/core/forms/selects/multi_column_field"
@@ -54,11 +55,16 @@ module UiBibz
54
55
  autoload :ButtonGroup, "ui_bibz/ui/core/forms/buttons/button_group"
55
56
  autoload :ButtonLink, "ui_bibz/ui/core/forms/buttons/button_link"
56
57
  autoload :ButtonRefresh, "ui_bibz/ui/core/forms/buttons/button_refresh"
58
+ autoload :ButtonToolbar, "ui_bibz/ui/core/forms/buttons/button_toolbar"
59
+ end
60
+
61
+ module Surrounds
62
+ autoload :SurroundField, "ui_bibz/ui/core/forms/surrounds/surround_field"
57
63
  end
58
64
 
59
65
  module Texts
60
66
  autoload :AutoCompleteField, "ui_bibz/ui/core/forms/texts/auto_complete_field"
61
- autoload :SurroundField, "ui_bibz/ui/core/forms/texts/surround_field"
67
+ autoload :TextField, "ui_bibz/ui/core/forms/texts/text_field"
62
68
  end
63
69
 
64
70
  module Textareas
@@ -80,23 +86,30 @@ module UiBibz
80
86
  module Navs
81
87
  autoload :Nav, "ui_bibz/ui/core/navs/nav"
82
88
  autoload :Navbar, "ui_bibz/ui/core/navs/navbar"
89
+ autoload :Pagination, "ui_bibz/ui/core/navs/pagination"
90
+ end
91
+
92
+ module Notifications
93
+ autoload :Alert, "ui_bibz/ui/core/notifications/alert"
83
94
  end
84
95
 
85
96
  module Paths
86
97
  autoload :Breadcrumb, "ui_bibz/ui/core/paths/breadcrumb"
87
98
  end
88
99
 
100
+ module Progresses
101
+ autoload :ProgressBar, "ui_bibz/ui/core/progresses/progress_bar"
102
+ end
103
+
89
104
  module Windows
90
105
  autoload :Modal, "ui_bibz/ui/core/windows/modal"
91
106
  end
92
107
 
93
108
  # Other section
94
- autoload :Alert, "ui_bibz/ui/core/alert"
95
- autoload :ConnectedComponent, "ui_bibz/ui/core/connected_component"
96
109
  autoload :Component, "ui_bibz/ui/core/component"
97
110
  autoload :Glyph, "ui_bibz/ui/core/glyph"
98
111
  autoload :Jumbotron, "ui_bibz/ui/core/jumbotron"
99
- autoload :Tag, "ui_bibz/ui/core/tag"
112
+ autoload :Badge, "ui_bibz/ui/core/badge"
100
113
  autoload :Progress, "ui_bibz/ui/core/progress"
101
114
  autoload :Star, "ui_bibz/ui/core/star"
102
115
  end
@@ -117,9 +130,12 @@ module UiBibz
117
130
  end
118
131
 
119
132
  module Helpers
120
- autoload :UiCoreHelper, "ui_bibz/helpers/ui_core_helper"
121
- autoload :UiUxHelper, "ui_bibz/helpers/ui_ux_helper"
122
- autoload :UtilsHelper, "ui_bibz/helpers/utils_helper"
133
+ module Ui
134
+ autoload :CoreHelper, "ui_bibz/helpers/ui/core_helper"
135
+ autoload :UxHelper, "ui_bibz/helpers/ui/ux_helper"
136
+ module Core end
137
+ end
138
+ autoload :UtilsHelper, "ui_bibz/helpers/utils_helper"
123
139
  end
124
140
 
125
141
  module Concerns
@@ -1,14 +1,16 @@
1
1
  # encoding: UTF-8
2
2
  require 'test_helper'
3
- require 'simple_form'
4
-
5
- include SimpleForm::ActionViewExtensions::FormHelper
6
3
 
7
4
  class SimpleFormTest < ActionView::TestCase
8
5
 
6
+ include SimpleForm::ActionViewExtensions::FormHelper
7
+ include UiBibz::Helpers::UtilsHelper
8
+
9
9
  setup do
10
- User.where(name_fr: 'test1', active: true).first_or_create
11
- User.where(name_fr: 'test2', active: false).first_or_create
10
+ user = User.where(name_fr: 'test1', name_en: 'test1 en', active: true).first_or_create
11
+ user.update_attribute(:created_at, "2017-04-26 14:48:43 UTC")
12
+ user = User.where(name_fr: 'test2', name_en: 'test2 en', active: false).first_or_create
13
+ user.update_attribute(:created_at, "2017-04-26 14:48:43 UTC")
12
14
  continent = Continent.where(name: 'Europe').first_or_create
13
15
  Country.where(name: 'France', continent_id: continent.id).first_or_create
14
16
  Country.where(name: 'Deutchland', continent_id: continent.id).first_or_create
@@ -21,10 +23,10 @@ class SimpleFormTest < ActionView::TestCase
21
23
 
22
24
  test 'auto complete field input in simple form' do
23
25
  actual = simple_form_for @user do |f|
24
- f.input :name_fr, as: :auto_complete_field, collection: @users, label_method: :name_fr
26
+ f.input :name_fr, as: :ui_auto_complete_field, collection: @users, label_method: :name_fr
25
27
  end
26
28
 
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=\"&#x2713;\" /><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 type=\"text\" name=\"user[name_fr]\" id=\"user_name_fr\" value=\"test1\" class=\"auto_complete_field optional form-control\" autocomplete=\"true\" list=\"user_name_fr-datalist\" /><datalist id=\"user_name_fr-datalist\"><option value=\"1\">test1</option>
29
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_auto_complete_field optional user_name_fr\"><label class=\"control-label ui_auto_complete_field optional\" for=\"user_name_fr\">Name fr</label><input type=\"text\" name=\"user[name_fr]\" id=\"user_name_fr\" value=\"test1\" class=\"ui_auto_complete_field optional form-control auto-complete-field\" autocomplete=\"true\" list=\"user_name_fr-datalist\" /><datalist id=\"user_name_fr-datalist\"><option value=\"1\">test1</option>
28
30
  <option value=\"2\">test2</option></datalist></div></form>"
29
31
 
30
32
  assert_equal expected, actual
@@ -32,20 +34,20 @@ class SimpleFormTest < ActionView::TestCase
32
34
 
33
35
  test 'date picker field input in simple form' do
34
36
  actual = simple_form_for @user do |f|
35
- f.input :created_at, as: :date_picker_field
37
+ f.input :created_at, as: :ui_date_picker_field
36
38
  end
37
39
 
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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group date_picker_field optional user_created_at\"><label class=\"control-label date_picker_field optional\" for=\"user_created_at\">Created at</label><input type=\"text\" name=\"user[created_at]\" id=\"user_created_at\" 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\" /></div></form>"
40
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_date_picker_field optional user_created_at\"><label class=\"control-label ui_date_picker_field optional\" for=\"user_created_at\">Created at</label><input type=\"text\" name=\"user[created_at]\" id=\"user_created_at\" value=\"2017-04-26 14:48:43 UTC\" class=\"ui_date_picker_field optional date_picker form-control\" data-date-locale=\"en\" data-provide=\"datepicker\" data-date-format=\"yyyy-mm-dd\" data-date-today-btn=\"linked\" data-date-toggle-active=\"true\" /></div></form>"
39
41
 
40
42
  assert_equal expected, actual
41
43
  end
42
44
 
43
45
  test 'dropdown field select input in simple form' do
44
46
  actual = simple_form_for @user do |f|
45
- f.input :name_fr, as: :dropdown_select_field, collection: @users, label_method: :name_fr
47
+ f.input :name_fr, as: :ui_dropdown_select_field, collection: @users, label_method: :name_fr
46
48
  end
47
49
 
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=\"&#x2713;\" /><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=\"user[name_fr]\" id=\"user_name_fr\" class=\"dropdown_select_field optional dropdown-select-field\"><option value=\"1\">test1</option>
50
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"ui_dropdown_select_field optional dropdown-select-field\"><option value=\"1\">test1</option>
49
51
  <option value=\"2\">test2</option></select></div></form>"
50
52
 
51
53
  assert_equal expected, actual
@@ -54,10 +56,10 @@ class SimpleFormTest < ActionView::TestCase
54
56
  test 'dropdown field select input with grouped option in simple form' do
55
57
 
56
58
  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
59
+ f.input :name_fr, as: :ui_dropdown_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
58
60
  end
59
61
 
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=\"&#x2713;\" /><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=\"user[name_fr]\" id=\"user_name_fr\" class=\"dropdown_select_field optional dropdown-select-field\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
62
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_dropdown_select_field optional user_name_fr\"><label class=\"control-label ui_dropdown_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"ui_dropdown_select_field optional dropdown-select-field\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
61
63
  <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
62
64
 
63
65
  assert_equal expected, actual
@@ -68,20 +70,20 @@ class SimpleFormTest < ActionView::TestCase
68
70
  @user.price_formula = "1+2"
69
71
 
70
72
  actual = simple_form_for @user do |f|
71
- f.input :price, as: :formula_field
73
+ f.input :price, as: :ui_formula_field
72
74
  end
73
75
 
74
- 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group formula_field optional user_price\"><label class=\"control-label formula_field optional\" for=\"user_price\">Price</label><div class=\"input-group formula_field\"><input type=\"text\" name=\"user[price_formula]\" id=\"user_price_formula\" value=\"1+2\" class=\"formula_field optional formula-field form-control\" /><span class=\"formula-field-sign input-group-addon\">=</span><input type=\"text\" name=\"user[price]\" id=\"user_price\" value=\"3.0\" 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></div></form>"
76
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_formula_field optional user_price\"><label class=\"control-label ui_formula_field optional\" for=\"user_price\">Price</label><div class=\"formula_field input-group\"><input type=\"text\" name=\"user[price_formula]\" id=\"user_price_formula\" value=\"1+2\" class=\"ui_formula_field optional formula-field form-control\" formula_field_value=\"1+2\" /><span class=\"formula-field-sign input-group-addon\">=</span><input type=\"text\" name=\"user[price]\" id=\"user_price\" value=\"3.0\" class=\"formula-field-result form-control\" readonly=\"readonly\" /><span data-toggle=\"tooltip\" class=\"formula-field-alert input-group-addon\"><i class=\"glyph-danger glyph fa fa-exclamation-triangle\"></i></span></div></div></form>"
75
77
 
76
78
  assert_equal expected, actual
77
79
  end
78
80
 
79
81
  test 'mardown editor field input in simple form' do
80
82
  actual = simple_form_for @user do |f|
81
- f.input :name_fr, as: :markdown_editor_field
83
+ f.input :name_fr, as: :ui_markdown_editor_field
82
84
  end
83
85
 
84
- 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=\"&#x2713;\" /><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 name=\"user[name_fr]\" id=\"user_name_fr\" class=\"markdown_editor_field optional\" data-provide=\"markdown\" data-iconlibrary=\"fa\">
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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_markdown_editor_field optional user_name_fr\"><label class=\"control-label ui_markdown_editor_field optional\" for=\"user_name_fr\">Name fr</label><textarea name=\"user[name_fr]\" id=\"user_name_fr\" class=\"ui_markdown_editor_field optional\" data-provide=\"markdown\" data-iconlibrary=\"fa\">
85
87
  </textarea></div></form>"
86
88
 
87
89
  assert_equal expected, actual
@@ -89,10 +91,10 @@ class SimpleFormTest < ActionView::TestCase
89
91
 
90
92
  test 'multi column field input in simple form' do
91
93
  actual = simple_form_for @user do |f|
92
- f.input :name_fr, as: :multi_column_field, collection: @users, label_method: :name_fr
94
+ f.input :name_fr, as: :ui_multi_column_field, collection: @users, label_method: :name_fr
93
95
  end
94
96
 
95
- 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=\"&#x2713;\" /><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><select name=\"name_fr[]\" id=\"name_fr\" class=\"multi_column_field optional multi-column-field\" multiple=\"multiple\"><option value=\"1\">test1</option>
97
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_multi_column_field optional user_name_fr\"><label class=\"control-label ui_multi_column_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr[]\" id=\"name_fr\" class=\"ui_multi_column_field optional multi-column-field\" multiple=\"multiple\"><option value=\"1\">test1</option>
96
98
  <option value=\"2\">test2</option></select></div></form>"
97
99
 
98
100
  assert_equal expected, actual
@@ -100,10 +102,10 @@ class SimpleFormTest < ActionView::TestCase
100
102
 
101
103
  test 'multi select field input in simple form' do
102
104
  actual = simple_form_for @user do |f|
103
- f.input :name_fr, as: :multi_select_field, collection: @users, label_method: :name_fr
105
+ f.input :name_fr, as: :ui_multi_select_field, collection: @users, label_method: :name_fr
104
106
  end
105
107
 
106
- 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=\"&#x2713;\" /><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>
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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_multi_select_field optional user_name_fr\"><label class=\"control-label ui_multi_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr[]\" id=\"name_fr\" class=\"ui_multi_select_field optional btn-secondary multi-select-field\" multiple=\"multiple\"><option value=\"1\">test1</option>
107
109
  <option value=\"2\">test2</option></select></div></form>"
108
110
 
109
111
  assert_equal expected, actual
@@ -112,21 +114,21 @@ class SimpleFormTest < ActionView::TestCase
112
114
  test 'multi select input with grouped option in simple form' do
113
115
 
114
116
  actual = simple_form_for @user do |f|
115
- f.input :name_fr, as: :multi_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
117
+ f.input :name_fr, as: :ui_multi_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
116
118
  end
117
119
 
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=\"&#x2713;\" /><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>
120
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_multi_select_field optional user_name_fr\"><label class=\"control-label ui_multi_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"name_fr[]\" id=\"name_fr\" class=\"ui_multi_select_field optional btn-secondary multi-select-field\" multiple=\"multiple\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
119
121
  <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
120
122
 
121
123
  assert_equal expected, actual
122
124
  end
123
125
 
124
- test 'surround field input in simple form' do
126
+ test 'text field input in simple form' do
125
127
  actual = simple_form_for @user do |f|
126
- f.input :name_fr, as: :surround_field
128
+ f.input :name_fr, as: :ui_text_field
127
129
  end
128
130
 
129
- 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=\"&#x2713;\" /><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 type=\"text\" name=\"user[name_fr]\" id=\"user_name_fr\" class=\"surround_field optional form-control\" /></div></form>"
131
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_text_field optional user_name_fr\"><label class=\"control-label ui_text_field optional\" for=\"user_name_fr\">Name fr</label><input type=\"text\" name=\"user[name_fr]\" id=\"user_name_fr\" value=\"test1\" class=\"ui_text_field optional form-control\" /></div></form>"
130
132
 
131
133
  assert_equal expected, actual
132
134
  end
@@ -134,30 +136,30 @@ class SimpleFormTest < ActionView::TestCase
134
136
  test 'switch field input in simple form' do
135
137
  @user.active = true
136
138
  actual = simple_form_for @user do |f|
137
- f.input :active, as: :switch_field, collection: @users, label_method: :name_fr
139
+ f.input :active, as: :ui_switch_field, collection: @users, label_method: :name_fr
138
140
  end
139
141
 
140
- 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group switch_field optional user_active\"><label class=\"control-label switch_field optional\" for=\"user_active\">Active</label><div class=\"switch-field-container\"><input type=\"hidden\" name=\"user[active]\" id=\"user_active\" value=\"0\" /><input type=\"checkbox\" name=\"user[active]\" id=\"user_active\" value=\"1\" class=\"switch_field optional switch-field\" checked=\"checked\" /></div></div></form>"
142
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_switch_field optional user_active\"><label class=\"control-label ui_switch_field optional\" for=\"user_active\">Active</label><div class=\"switch-field-container\"><input type=\"hidden\" name=\"user[active]\" id=\"user_active\" value=\"0\" /><input type=\"checkbox\" name=\"user[active]\" id=\"user_active\" value=\"1\" class=\"ui_switch_field optional switch-field\" checked=\"checked\" /></div></div></form>"
141
143
 
142
144
  assert_equal expected, actual
143
145
  end
144
146
 
145
147
  test 'radio field input in simple form' do
146
148
  actual = simple_form_for @user do |f|
147
- f.input :name_fr, as: :radio_field, collection: @users, label_method: :name_fr
149
+ f.input :name_fr, as: :ui_radio_field, collection: @users, label_method: :name_fr
148
150
  end
149
151
 
150
- 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=\"&#x2713;\" /><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>"
152
+ expected = "<form class=\"simple_form edit_user\" id=\"edit_user_1\" action=\"/users/1\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_radio_field optional user_name_fr\"><label class=\"control-label ui_radio_field optional\">Name fr</label><input type=\"hidden\" name=\"user[name_fr]\" value=\"\" /><div class=\"radio ui_radio_field optional abc-radio-default radio abc-radio\"><input class=\"ui_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 ui_radio_field optional abc-radio-default radio abc-radio\"><input class=\"ui_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>"
151
153
 
152
154
  assert_equal expected, actual
153
155
  end
154
156
 
155
157
  test 'select field input in simple form' do
156
158
  actual = simple_form_for @user do |f|
157
- f.input :name_fr, as: :select_field, collection: @users, label_method: :name_fr
159
+ f.input :name_fr, as: :ui_select_field, collection: @users, label_method: :name_fr
158
160
  end
159
161
 
160
- 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=\"&#x2713;\" /><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=\"user[name_fr]\" id=\"user_name_fr\" class=\"select_field optional select-field form-control\"><option value=\"1\">test1</option>
162
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"ui_select_field optional select-field form-control\"><option value=\"1\">test1</option>
161
163
  <option value=\"2\">test2</option></select></div></form>"
162
164
 
163
165
  assert_equal expected, actual
@@ -165,11 +167,11 @@ class SimpleFormTest < ActionView::TestCase
165
167
 
166
168
  test 'select field input with refresh button in simple form' do
167
169
  actual = simple_form_for @user do |f|
168
- f.input :name_fr, as: :select_field, refresh: { target: { data: [] }}, collection: @users, label_method: :name_fr
170
+ f.input :name_fr, as: :ui_select_field, refresh: { target: { data: [] }}, collection: @users, label_method: :name_fr
169
171
  end
170
172
 
171
- 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=\"&#x2713;\" /><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=\"user[name_fr]\" id=\"user_name_fr\" class=\"select_field optional select-field form-control\"><option value=\"1\">test1</option>
172
- <option value=\"2\">test2</option></select><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;#user_name_fr&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></div></form>"
173
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><div class=\"field-refresh input-group\"><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"ui_select_field optional select-field form-control\"><option value=\"1\">test1</option>
174
+ <option value=\"2\">test2</option></select><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;#user_name_fr&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></div></form>"
173
175
 
174
176
  assert_equal expected, actual
175
177
  end
@@ -177,10 +179,10 @@ class SimpleFormTest < ActionView::TestCase
177
179
  test 'select input with grouped option in simple form' do
178
180
 
179
181
  actual = simple_form_for @user do |f|
180
- f.input :name_fr, as: :select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
182
+ f.input :name_fr, as: :ui_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
181
183
  end
182
184
 
183
- 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=\"&#x2713;\" /><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=\"user[name_fr]\" id=\"user_name_fr\" class=\"select_field optional select-field form-control\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
185
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"ui_select_field optional select-field form-control\"><optgroup label=\"Europe\"><option value=\"1\">France</option>
184
186
  <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
185
187
 
186
188
  assert_equal expected, actual
@@ -190,10 +192,10 @@ class SimpleFormTest < ActionView::TestCase
190
192
 
191
193
  @user.name_fr = 1
192
194
  actual = simple_form_for @user do |f|
193
- f.input :name_fr, as: :select_field, collection: @countries
195
+ f.input :name_fr, as: :ui_select_field, collection: @countries
194
196
  end
195
197
 
196
- 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=\"&#x2713;\" /><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=\"user[name_fr]\" id=\"user_name_fr\" class=\"select_field optional select-field form-control\"><option selected=\"selected\" value=\"1\">France</option>
198
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"ui_select_field optional select-field form-control\"><option selected=\"selected\" value=\"1\">France</option>
197
199
  <option value=\"2\">Deutchland</option></select></div></form>"
198
200
 
199
201
  assert_equal expected, actual
@@ -203,13 +205,28 @@ class SimpleFormTest < ActionView::TestCase
203
205
 
204
206
  @user.name_fr = 1
205
207
  actual = simple_form_for @user do |f|
206
- f.input :name_fr, as: :select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
208
+ f.input :name_fr, as: :ui_select_field, collection: @continents, toto: 'lala', grouped: true, group_method: :countries
207
209
  end
208
210
 
209
- 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=\"&#x2713;\" /><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=\"user[name_fr]\" id=\"user_name_fr\" class=\"select_field optional select-field form-control\"><optgroup label=\"Europe\"><option selected=\"selected\" value=\"1\">France</option>
211
+ 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div class=\"form-group ui_select_field optional user_name_fr\"><label class=\"control-label ui_select_field optional\" for=\"user_name_fr\">Name fr</label><select name=\"user[name_fr]\" id=\"user_name_fr\" class=\"ui_select_field optional select-field form-control\"><optgroup label=\"Europe\"><option selected=\"selected\" value=\"1\">France</option>
210
212
  <option value=\"2\">Deutchland</option></optgroup></select></div></form>"
211
213
 
212
214
  assert_equal expected, actual
213
215
  end
216
+
217
+ # test 'test surround field into simple form' do
218
+ # actual = ui_form_for @user do |f|
219
+ # concat(f.ui_surround_field do |sf|
220
+ # sf.input :name_en, as: :text_field
221
+ # sf.addon("€")
222
+ # end)
223
+ # concat f.input(:name_fr, as: :ui_auto_complete_field, collection: @users, label_method: :name_fr)
224
+ # end
225
+ #
226
+ # 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=\"&#x2713;\" /><input type=\"hidden\" name=\"_method\" value=\"patch\" /><div><div class=\"input-group\"><input type=\"text\" name=\"user[name_en]\" id=\"user_name_en\" value=\"test1 en\" class=\"text_field optional form-control\" /><span class=\"input-group-addon\">€</span></div></div><div class=\"form-group ui_auto_complete_field optional user_name_fr\"><label class=\"control-label ui_auto_complete_field optional\" for=\"user_name_fr\">Name fr</label><input type=\"text\" name=\"user[name_fr]\" id=\"user_name_fr\" value=\"test1\" class=\"ui_auto_complete_field optional form-control auto-complete-field\" autocomplete=\"true\" list=\"user_name_fr-datalist\" /><datalist id=\"user_name_fr-datalist\"><option value=\"1\">test1</option>
227
+ # <option value=\"2\">test2</option></datalist></div></form>"
228
+ #
229
+ # assert_equal expected, actual
230
+ # end
214
231
  end
215
232
 
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+ class BadgeTest < ActionView::TestCase
3
+ include UiBibz::Helpers::Ui::CoreHelper
4
+
5
+ test 'badge' do
6
+ actual = ui_badge 'state', status: :success, glyph: 'pencil'
7
+ expected = "<span class=\"badge-success badge\"><i class=\"glyph fa fa-pencil\"></i> state</span>"
8
+
9
+ assert_equal expected, actual
10
+ end
11
+
12
+ test 'badge pill' do
13
+ actual = ui_badge 'state', status: :success, type: :pill, glyph: 'pencil'
14
+ expected = "<span class=\"badge-success badge badge-pill\"><i class=\"glyph fa fa-pencil\"></i> state</span>"
15
+
16
+ assert_equal expected, actual
17
+ end
18
+
19
+ end