ui_bibz 2.5.6 → 3.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -2
  3. data/.rubocop.yml +78 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +1 -0
  7. data/Gemfile.lock +90 -102
  8. data/README.md +9 -52
  9. data/Rakefile +3 -2
  10. data/bin/test +7 -0
  11. data/config/initializers/will_paginate.rb +2 -1
  12. data/lib/ui_bibz.rb +17 -2
  13. data/lib/ui_bibz/concerns/models/searchable.rb +3 -3
  14. data/lib/ui_bibz/helpers/ui/core/boxes_helper.rb +9 -1
  15. data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +18 -0
  16. data/lib/ui_bibz/helpers/ui/core/layouts_helper.rb +10 -2
  17. data/lib/ui_bibz/helpers/ui/core/lists_helper.rb +1 -1
  18. data/lib/ui_bibz/helpers/ui/core/notifications_helper.rb +9 -5
  19. data/lib/ui_bibz/helpers/ui/ux_helper.rb +2 -6
  20. data/lib/ui_bibz/infos.rb +11 -5
  21. data/lib/ui_bibz/inputs/ui_bibz_form/ui_bibz_form_builder.rb +15 -2
  22. data/lib/ui_bibz/inputs/ui_bibz_inputs/base_input.rb +0 -4
  23. data/lib/ui_bibz/inputs/ui_bibz_inputs/collection_input.rb +6 -9
  24. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_field_input.rb +23 -0
  25. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_slider_field_input.rb +11 -0
  26. data/lib/ui_bibz/rails/engine.rb +2 -13
  27. data/lib/ui_bibz/railtie.rb +6 -0
  28. data/lib/ui_bibz/ui/concerns/card_itemable_concern.rb +65 -0
  29. data/lib/ui_bibz/ui/concerns/html_concern.rb +16 -0
  30. data/lib/ui_bibz/ui/core/boxes/card.rb +5 -50
  31. data/lib/ui_bibz/ui/core/boxes/card_accordion.rb +2 -0
  32. data/lib/ui_bibz/ui/core/boxes/card_column.rb +3 -1
  33. data/lib/ui_bibz/ui/core/boxes/card_deck.rb +3 -1
  34. data/lib/ui_bibz/ui/core/boxes/card_grid.rb +60 -0
  35. data/lib/ui_bibz/ui/core/boxes/card_group.rb +3 -1
  36. data/lib/ui_bibz/ui/core/boxes/components/body/card_body_link.rb +0 -3
  37. data/lib/ui_bibz/ui/core/boxes/components/body/card_body_subtitle.rb +47 -0
  38. data/lib/ui_bibz/ui/core/boxes/components/body/card_body_text.rb +0 -3
  39. data/lib/ui_bibz/ui/core/boxes/components/body/card_body_title.rb +1 -4
  40. data/lib/ui_bibz/ui/core/boxes/components/card_body.rb +7 -0
  41. data/lib/ui_bibz/ui/core/boxes/components/card_col.rb +65 -0
  42. data/lib/ui_bibz/ui/core/boxes/components/card_footer.rb +0 -3
  43. data/lib/ui_bibz/ui/core/boxes/components/card_header.rb +2 -4
  44. data/lib/ui_bibz/ui/core/boxes/components/card_image.rb +0 -3
  45. data/lib/ui_bibz/ui/core/boxes/components/card_row.rb +65 -0
  46. data/lib/ui_bibz/ui/core/boxes/components/card_tab_group.rb +0 -4
  47. data/lib/ui_bibz/ui/core/boxes/jumbotron.rb +1 -4
  48. data/lib/ui_bibz/ui/core/component.rb +16 -9
  49. data/lib/ui_bibz/ui/core/forms/buttons/button.rb +1 -1
  50. data/lib/ui_bibz/ui/core/forms/buttons/button_group.rb +9 -11
  51. data/lib/ui_bibz/ui/core/forms/buttons/button_refresh.rb +0 -3
  52. data/lib/ui_bibz/ui/core/forms/buttons/components/button_group_dropdown.rb +0 -3
  53. data/lib/ui_bibz/ui/core/forms/buttons/components/button_group_split_dropdown.rb +0 -3
  54. data/lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb +7 -10
  55. data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +8 -7
  56. data/lib/ui_bibz/ui/core/forms/choices/choice_group.rb +22 -2
  57. data/lib/ui_bibz/ui/core/forms/choices/components/choice.rb +24 -12
  58. data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +11 -6
  59. data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +1 -5
  60. data/lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb +12 -15
  61. data/lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_divider.rb +0 -1
  62. data/lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_header.rb +0 -3
  63. data/lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb +8 -13
  64. data/lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb +0 -3
  65. data/lib/ui_bibz/ui/core/forms/files/file_field.rb +20 -10
  66. data/lib/ui_bibz/ui/core/forms/numbers/formula_field.rb +16 -8
  67. data/lib/ui_bibz/ui/core/forms/numbers/number_field.rb +20 -3
  68. data/lib/ui_bibz/ui/core/forms/numbers/range_field.rb +33 -5
  69. data/lib/ui_bibz/ui/core/forms/numbers/slider_field.rb +132 -0
  70. data/lib/ui_bibz/ui/core/forms/numbers/slider_header.rb +71 -0
  71. data/lib/ui_bibz/ui/core/forms/selects/abstract_select.rb +0 -3
  72. data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +6 -9
  73. data/lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb +0 -3
  74. data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +0 -3
  75. data/lib/ui_bibz/ui/core/forms/selects/select_field.rb +2 -5
  76. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_addon.rb +1 -4
  77. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button.rb +0 -3
  78. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_group.rb +0 -3
  79. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_link.rb +0 -3
  80. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_refresh.rb +1 -12
  81. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_checkbox_field.rb +9 -4
  82. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_dropdown.rb +0 -3
  83. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_radio_field.rb +9 -4
  84. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_switch_field.rb +0 -3
  85. data/lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb +1 -4
  86. data/lib/ui_bibz/ui/core/forms/textareas/markdown_editor_field.rb +4 -7
  87. data/lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb +2 -5
  88. data/lib/ui_bibz/ui/core/forms/texts/text_field.rb +0 -3
  89. data/lib/ui_bibz/ui/core/icons/components/glyph_counter.rb +0 -3
  90. data/lib/ui_bibz/ui/core/icons/components/glyph_text.rb +1 -4
  91. data/lib/ui_bibz/ui/core/icons/glyph.rb +1 -4
  92. data/lib/ui_bibz/ui/core/icons/star.rb +0 -3
  93. data/lib/ui_bibz/ui/core/layouts/col.rb +5 -42
  94. data/lib/ui_bibz/ui/core/layouts/container.rb +9 -6
  95. data/lib/ui_bibz/ui/core/layouts/row.rb +32 -2
  96. data/lib/ui_bibz/ui/core/lists/components/list.rb +6 -8
  97. data/lib/ui_bibz/ui/core/lists/components/list/list_body.rb +0 -3
  98. data/lib/ui_bibz/ui/core/lists/components/list/list_header.rb +0 -3
  99. data/lib/ui_bibz/ui/core/lists/list_group.rb +9 -6
  100. data/lib/ui_bibz/ui/core/navigations/breadcrumb.rb +3 -2
  101. data/lib/ui_bibz/ui/core/navigations/components/breadcrumb_link.rb +0 -3
  102. data/lib/ui_bibz/ui/core/navigations/components/nav_dropdown.rb +1 -4
  103. data/lib/ui_bibz/ui/core/navigations/components/nav_link.rb +3 -1
  104. data/lib/ui_bibz/ui/core/navigations/components/nav_link_link.rb +14 -5
  105. data/lib/ui_bibz/ui/core/navigations/components/nav_link_list.rb +0 -4
  106. data/lib/ui_bibz/ui/core/navigations/components/nav_link_span.rb +1 -4
  107. data/lib/ui_bibz/ui/core/navigations/components/nav_text.rb +0 -3
  108. data/lib/ui_bibz/ui/core/navigations/components/navbar_brand.rb +0 -3
  109. data/lib/ui_bibz/ui/core/navigations/components/navbar_form.rb +4 -4
  110. data/lib/ui_bibz/ui/core/navigations/components/navbar_nav.rb +1 -4
  111. data/lib/ui_bibz/ui/core/navigations/components/navbar_text.rb +0 -3
  112. data/lib/ui_bibz/ui/core/navigations/components/pagination_link.rb +0 -3
  113. data/lib/ui_bibz/ui/core/navigations/components/toolbar_form.rb +3 -3
  114. data/lib/ui_bibz/ui/core/navigations/link.rb +0 -3
  115. data/lib/ui_bibz/ui/core/navigations/nav.rb +37 -10
  116. data/lib/ui_bibz/ui/core/navigations/navbar.rb +28 -7
  117. data/lib/ui_bibz/ui/core/navigations/pagination.rb +3 -1
  118. data/lib/ui_bibz/ui/core/navigations/tab_group.rb +10 -5
  119. data/lib/ui_bibz/ui/core/navigations/toolbar.rb +2 -0
  120. data/lib/ui_bibz/ui/core/notifications/alert.rb +2 -2
  121. data/lib/ui_bibz/ui/core/notifications/badge.rb +2 -5
  122. data/lib/ui_bibz/ui/core/notifications/components/alert_body.rb +0 -3
  123. data/lib/ui_bibz/ui/core/notifications/components/alert_header.rb +4 -10
  124. data/lib/ui_bibz/ui/core/notifications/components/bar.rb +0 -3
  125. data/lib/ui_bibz/ui/core/notifications/components/toast_body.rb +0 -3
  126. data/lib/ui_bibz/ui/core/notifications/components/toast_header.rb +1 -6
  127. data/lib/ui_bibz/ui/core/notifications/progress_bar.rb +7 -5
  128. data/lib/ui_bibz/ui/core/notifications/spinner.rb +0 -3
  129. data/lib/ui_bibz/ui/core/notifications/toast.rb +14 -3
  130. data/lib/ui_bibz/ui/core/windows/components/modal_body.rb +0 -3
  131. data/lib/ui_bibz/ui/core/windows/components/modal_footer.rb +0 -3
  132. data/lib/ui_bibz/ui/core/windows/components/modal_header.rb +1 -7
  133. data/lib/ui_bibz/ui/core/windows/modal.rb +61 -14
  134. data/lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb +4 -2
  135. data/lib/ui_bibz/ui/extensions/core/component/popover_extension.rb +9 -9
  136. data/lib/ui_bibz/ui/extensions/core/forms/connect_extension.rb +2 -2
  137. data/lib/ui_bibz/ui/ux/containers/components/panel_body.rb +0 -3
  138. data/lib/ui_bibz/ui/ux/containers/components/panel_column.rb +2 -0
  139. data/lib/ui_bibz/ui/ux/containers/components/panel_deck.rb +2 -0
  140. data/lib/ui_bibz/ui/ux/containers/components/panel_footer.rb +0 -3
  141. data/lib/ui_bibz/ui/ux/containers/components/panel_group.rb +2 -0
  142. data/lib/ui_bibz/ui/ux/containers/components/panel_header.rb +1 -4
  143. data/lib/ui_bibz/ui/ux/containers/components/panel_tab_group.rb +0 -4
  144. data/lib/ui_bibz/ui/ux/containers/components/panel_toolbar.rb +0 -3
  145. data/lib/ui_bibz/ui/ux/containers/panel.rb +4 -2
  146. data/lib/ui_bibz/ui/ux/tables/components/thead.rb +0 -3
  147. data/lib/ui_bibz/ui/ux/tables/table.rb +2 -4
  148. data/lib/ui_bibz/ui/ux/tables/table_card.rb +4 -3
  149. data/lib/ui_bibz/ui/ux/tables/table_search_field.rb +5 -5
  150. data/lib/ui_bibz/utils/breakdown_class_name_generator.rb +69 -0
  151. data/lib/ui_bibz/utils/internationalization.rb +1 -1
  152. data/lib/ui_bibz/utils/screwdriver.rb +16 -10
  153. data/package.json +5 -0
  154. data/test/dummy/Rakefile +1 -1
  155. data/test/dummy/app/javascripts/packs/index.js +3 -0
  156. data/test/dummy/app/views/layouts/application.html.erb +4 -1
  157. data/{app/ui/.keep → test/dummy/app/views/users/index.html.erb} +0 -0
  158. data/test/dummy/bin/setup +17 -13
  159. data/test/dummy/config.ru +2 -1
  160. data/test/dummy/config/application.rb +1 -0
  161. data/test/dummy/config/cable.yml +10 -0
  162. data/test/dummy/config/database.yml +1 -1
  163. data/test/dummy/config/environment.rb +1 -1
  164. data/test/dummy/config/environments/development.rb +33 -12
  165. data/test/dummy/config/environments/production.rb +52 -19
  166. data/test/dummy/config/environments/test.rb +18 -12
  167. data/test/dummy/config/initializers/application_controller_renderer.rb +9 -0
  168. data/test/dummy/config/initializers/assets.rb +4 -3
  169. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -1
  170. data/test/dummy/config/initializers/content_security_policy.rb +29 -0
  171. data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
  172. data/test/dummy/config/initializers/inflections.rb +0 -1
  173. data/test/dummy/config/initializers/mime_types.rb +0 -1
  174. data/test/dummy/config/initializers/wrap_parameters.rb +2 -2
  175. data/test/dummy/config/puma.rb +40 -0
  176. data/test/dummy/config/routes.rb +3 -0
  177. data/test/dummy/config/spring.rb +8 -0
  178. data/test/dummy/config/storage.yml +34 -0
  179. data/test/dummy/db/migrate/20150123191805_create_users.rb +1 -1
  180. data/test/dummy/db/schema.rb +24 -24
  181. data/test/dummy/public/404.html +6 -6
  182. data/test/dummy/public/422.html +6 -6
  183. data/test/dummy/public/500.html +6 -6
  184. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  185. data/test/dummy/public/apple-touch-icon.png +0 -0
  186. data/test/dummy/storage/.keep +0 -0
  187. data/test/simple_form_test.rb +45 -22
  188. data/test/store_test.rb +5 -5
  189. data/test/test_helper.rb +18 -9
  190. data/test/ui/core/boxes/card_grid_test.rb +17 -0
  191. data/test/ui/core/boxes/card_test.rb +45 -11
  192. data/test/ui/core/boxes/jumbotron_test.rb +2 -2
  193. data/test/ui/core/component_test.rb +1 -1
  194. data/test/ui/core/forms/buttons/button_link_test.rb +1 -1
  195. data/test/ui/core/forms/buttons/button_test.rb +2 -2
  196. data/test/ui/core/forms/choices/checkbox_field_test.rb +1 -1
  197. data/test/ui/core/forms/choices/choice_group_test.rb +11 -9
  198. data/test/ui/core/forms/choices/radio_field_test.rb +1 -1
  199. data/test/ui/core/forms/dates/date_picker_field_test.rb +1 -1
  200. data/test/ui/core/forms/files/file_field_test.rb +12 -0
  201. data/test/ui/core/forms/numbers/formula_field_test.rb +1 -1
  202. data/test/ui/core/forms/numbers/range_field_test.rb +23 -2
  203. data/test/ui/core/forms/numbers/slider_field_test.rb +26 -0
  204. data/test/ui/core/forms/selects/dropdown_select_field_test.rb +10 -10
  205. data/test/ui/core/forms/selects/multi_column_field_test.rb +1 -1
  206. data/test/ui/core/forms/selects/multi_select_field_test.rb +2 -2
  207. data/test/ui/core/forms/selects/select_field_test.rb +3 -3
  208. data/test/ui/core/forms/surrounds/surround_field_test.rb +15 -3
  209. data/test/ui/core/forms/textareas/markdown_editor_field_test.rb +1 -1
  210. data/test/ui/core/forms/texts/auto_complete_field_test.rb +8 -8
  211. data/test/ui/core/forms/texts/text_field_test.rb +2 -2
  212. data/test/ui/core/layouts/col_test.rb +11 -2
  213. data/test/ui/core/layouts/container_test.rb +15 -1
  214. data/test/ui/core/layouts/row_test.rb +68 -3
  215. data/test/ui/core/lists/list_group_test.rb +1 -1
  216. data/test/ui/core/navigations/breadcrumb_test.rb +1 -1
  217. data/test/ui/core/navigations/link_test.rb +1 -1
  218. data/test/ui/core/navigations/nav_test.rb +11 -0
  219. data/test/ui/core/navigations/navbar_test.rb +4 -4
  220. data/test/ui/core/notifications/alert_test.rb +2 -2
  221. data/test/ui/core/notifications/badge_test.rb +3 -3
  222. data/test/ui/core/notifications/progress_bar_test.rb +1 -1
  223. data/test/ui/core/notifications/toast_test.rb +10 -1
  224. data/test/ui/core/windows/modal_test.rb +15 -1
  225. data/test/ui/utils/breakdown_class_name_generator_test.rb +60 -0
  226. data/test/ui/ux/containers/panel_test.rb +5 -5
  227. data/test/ui/ux/tables/table_test.rb +6 -6
  228. data/test/ui_bibz_test.rb +1 -1
  229. data/ui_bibz.gemspec +16 -16
  230. metadata +100 -105
  231. data/app/assets/javascripts/fix_bootstrap.coffee +0 -7
  232. data/app/assets/javascripts/form.coffee +0 -83
  233. data/app/assets/javascripts/formula.coffee +0 -69
  234. data/app/assets/javascripts/input-connected.coffee +0 -101
  235. data/app/assets/javascripts/interface.coffee +0 -55
  236. data/app/assets/javascripts/jquery.multi-select-extend.coffee +0 -38
  237. data/app/assets/javascripts/table.coffee +0 -36
  238. data/app/assets/javascripts/ui_bibz.coffee.erb +0 -75
  239. data/app/assets/stylesheets/_custom_variables.sass +0 -20
  240. data/app/assets/stylesheets/_panel.scss +0 -315
  241. data/app/assets/stylesheets/bootstrap-switch.sass +0 -159
  242. data/app/assets/stylesheets/boxes.sass +0 -5
  243. data/app/assets/stylesheets/containers.sass +0 -2
  244. data/app/assets/stylesheets/fix-bootstrap-4.sass +0 -19
  245. data/app/assets/stylesheets/fix_addon.sass +0 -216
  246. data/app/assets/stylesheets/forms.sass +0 -91
  247. data/app/assets/stylesheets/navigations.sass +0 -17
  248. data/app/assets/stylesheets/notifications.sass +0 -42
  249. data/app/assets/stylesheets/tables.sass +0 -66
  250. data/app/assets/stylesheets/ui_bibz.sass.erb +0 -55
  251. data/lib/generators/ui_bibz/install_generator.rb +0 -17
  252. data/lib/generators/ui_bibz/templates/ui_bibz_initializer.rb +0 -5
  253. data/lib/ui_bibz/ui/core/icons/glyph_group.rb +0 -101
  254. data/test/dummy/bin/bundle +0 -5
  255. data/test/ui/core/forms/files/text_field_test.rb +0 -12
  256. data/test/ui/core/icons/glyph_group_test.rb +0 -37
@@ -48,9 +48,6 @@ module UiBibz::Ui::Core::Forms::Choices
48
48
  #
49
49
  class CheckboxField < UiBibz::Ui::Core::Component
50
50
  # See UiBibz::Ui::Core::Component.initialize
51
- def initialize(content = nil, options = nil, html_options = nil, &block)
52
- super
53
- end
54
51
 
55
52
  # Render html tag
56
53
  def pre_render
@@ -63,7 +60,7 @@ module UiBibz::Ui::Core::Forms::Choices
63
60
  content_tag(:div, html_options.except(:id, 'data-action')) do
64
61
  concat hidden_field_tag content, '0', id: "#{content}-hidden"
65
62
  concat check_box_tag content, options[:value] || '1', options[:checked] || html_options[:checked], checkbox_html_options
66
- concat label_tag label_name, label_content, class: 'custom-control-label'
63
+ concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
67
64
  end
68
65
  end
69
66
 
@@ -72,7 +69,7 @@ module UiBibz::Ui::Core::Forms::Choices
72
69
  disabled: disabled?,
73
70
  indeterminate: options[:indeterminate],
74
71
  "data-action": options[:action],
75
- class: 'custom-control-input'
72
+ class: 'form-check-input'
76
73
  }
77
74
  end
78
75
 
@@ -92,11 +89,15 @@ module UiBibz::Ui::Core::Forms::Choices
92
89
  end
93
90
 
94
91
  def component_html_classes
95
- super << ['custom-control', 'custom-checkbox', inline]
92
+ super << component_wrapper_html_classes
96
93
  end
97
94
 
98
95
  def inline
99
- 'custom-control-inline' if options[:inline]
96
+ 'form-check-inline' if options[:inline]
97
+ end
98
+
99
+ def component_wrapper_html_classes
100
+ ['form-check', inline]
100
101
  end
101
102
  end
102
103
  end
@@ -47,9 +47,17 @@ module UiBibz::Ui::Core::Forms::Choices
47
47
  # end
48
48
  #
49
49
  class ChoiceGroup < UiBibz::Ui::Core::Forms::Buttons::ButtonGroup
50
+ include UiBibz::Ui::Concerns::HtmlConcern
51
+ attr_reader :errors, :required_fields, :items
52
+
50
53
  # See UiBibz::Ui::Core::Forms::Choices::Button.initialize
54
+ #
51
55
  def initialize(content = nil, options = nil, html_options = nil, &block)
52
56
  super
57
+ @items = []
58
+ @errors = []
59
+ @required_fields = []
60
+ @radio_name = @options[:name] || generate_id('choice')
53
61
  end
54
62
 
55
63
  def choice(content = nil, opts = nil, html_options = nil, &block)
@@ -59,7 +67,19 @@ module UiBibz::Ui::Core::Forms::Choices
59
67
  content = @options.merge(content || {})
60
68
  end
61
69
 
62
- @items << Choice.new(content, opts, html_options, &block).render
70
+ opts = opts.merge(name: @radio_name) if opts[:type] == :radio
71
+
72
+ @items << Choice.new(content, opts, html_options, &block)
73
+ end
74
+
75
+ def input(attribute_name, options = {}, &block)
76
+ new_options = options.merge(old_label: options[:label], label: false, wrapper: false, error: false)
77
+ new_options = new_options.merge(name: @radio_name, type: :radio) if @options[:type] == :radio
78
+
79
+ @items << @options[:form].input(attribute_name, new_options, &block)
80
+ obj = @options[:form].object
81
+ @errors << obj.errors[attribute_name] unless obj.errors[attribute_name].empty?
82
+ @required_fields << (obj._validators[attribute_name].try(:first).class.to_s == 'ActiveRecord::Validations::PresenceValidator')
63
83
  end
64
84
 
65
85
  private
@@ -74,7 +94,7 @@ module UiBibz::Ui::Core::Forms::Choices
74
94
 
75
95
  def component_html_data
76
96
  super
77
- add_html_data 'toggle', 'buttons'
97
+ add_html_data 'toggle', value: 'buttons'
78
98
  end
79
99
  end
80
100
  end
@@ -54,27 +54,39 @@ module UiBibz::Ui::Core::Forms::Choices
54
54
  #
55
55
  class Choice < UiBibz::Ui::Core::Forms::Buttons::Button
56
56
  # See UiBibz::Ui::Core::Forms::Choices::Button.initialize
57
- def initialize(content = nil, options = nil, html_options = nil, &block)
58
- super
59
- end
60
57
 
61
58
  # Render html tag
62
59
  def pre_render
63
60
  button_choice_html_tag
64
61
  end
65
62
 
63
+ def input_options
64
+ @input_options ||= { type: type, autocomplete: :off, class: 'btn-check' }
65
+ .merge(checked)
66
+ .merge(value)
67
+ .merge(name)
68
+ .merge({ id: input_id })
69
+ .merge(input_html_options)
70
+ end
71
+
66
72
  private
67
73
 
68
74
  def button_choice_html_tag
69
- content_tag :label, html_options do
75
+ capture do
70
76
  concat tag(:input, input_options)
71
- concat glyph_and_content_html(options[:text].nil? ? @content : ' ')
72
- concat badge_html unless options[:badge].nil?
77
+ concat label_tag
73
78
  end
74
79
  end
75
80
 
76
- def input_options
77
- { type: type, autocomplete: :off }.merge(checked).merge(value).merge(name).merge(id).merge(input_html_options)
81
+ def label_tag
82
+ if options[:label]
83
+ content_tag :label, options[:label], html_options.merge(for: input_id)
84
+ else
85
+ content_tag :label, html_options.merge(for: input_id) do
86
+ concat glyph_and_content_html(options[:text].nil? ? @content : ' ')
87
+ concat badge_html unless options[:badge].nil?
88
+ end
89
+ end
78
90
  end
79
91
 
80
92
  def checked
@@ -89,10 +101,6 @@ module UiBibz::Ui::Core::Forms::Choices
89
101
  @options[:name].nil? ? {} : { name: @options[:name] }
90
102
  end
91
103
 
92
- def id
93
- @options[:id].nil? ? {} : { id: @options[:id] }
94
- end
95
-
96
104
  def input_html_options
97
105
  @options[:input_html_options].nil? ? {} : @options[:input_html_options]
98
106
  end
@@ -104,5 +112,9 @@ module UiBibz::Ui::Core::Forms::Choices
104
112
  def status
105
113
  ['btn', outline, options[:status] || :secondary].compact.join('-')
106
114
  end
115
+
116
+ def input_id
117
+ @input_id ||= @options[:id] || generate_id('choice')
118
+ end
107
119
  end
108
120
  end
@@ -48,9 +48,6 @@ module UiBibz::Ui::Core::Forms::Choices
48
48
  #
49
49
  class RadioField < UiBibz::Ui::Core::Forms::Choices::CheckboxField
50
50
  # See UiBibz::Ui::Core::Component.initialize
51
- def initialize(content = nil, options = nil, html_options = nil, &block)
52
- super
53
- end
54
51
 
55
52
  # Render html tag
56
53
  def pre_render
@@ -62,7 +59,7 @@ module UiBibz::Ui::Core::Forms::Choices
62
59
  def radio_field_html_tag
63
60
  content_tag :div, html_options.except(:id) do
64
61
  concat radio_button_tag content, options[:value], options[:checked] || false, checkbox_html_options
65
- concat label_tag label_name, label_content, class: 'custom-control-label'
62
+ concat label_tag(label_name, label_content, class: 'form-check-label') if options[:label] != false
66
63
  end
67
64
  end
68
65
 
@@ -70,7 +67,7 @@ module UiBibz::Ui::Core::Forms::Choices
70
67
  {
71
68
  disabled: options[:state] == :disabled,
72
69
  "data-action": options[:action],
73
- class: 'custom-control-input'
70
+ class: 'form-check-input'
74
71
  }
75
72
  end
76
73
 
@@ -79,7 +76,15 @@ module UiBibz::Ui::Core::Forms::Choices
79
76
  end
80
77
 
81
78
  def component_html_classes
82
- ['custom-control', 'custom-radio', inline]
79
+ super << component_wrapper_html_classes
80
+ end
81
+
82
+ def inline
83
+ 'form-check-inline' if options[:inline]
84
+ end
85
+
86
+ def component_wrapper_html_classes
87
+ ['form-check', inline]
83
88
  end
84
89
  end
85
90
  end
@@ -41,14 +41,10 @@ module UiBibz::Ui::Core::Forms::Choices
41
41
  # end
42
42
  #
43
43
  class SwitchField < UiBibz::Ui::Core::Forms::Choices::CheckboxField
44
- def initialize(content = nil, options = nil, html_options = nil, &block)
45
- super
46
- end
47
-
48
44
  private
49
45
 
50
46
  def component_html_classes
51
- ['custom-control', 'custom-switch', inline]
47
+ ['form-check', 'form-switch', inline]
52
48
  end
53
49
  end
54
50
  end
@@ -45,9 +45,6 @@ module UiBibz::Ui::Core::Forms::Dates
45
45
  #
46
46
  class DatePickerField < UiBibz::Ui::Core::Component
47
47
  # See UiBibz::Ui::Core::Component.initialize
48
- def initialize(content = nil, options = nil, html_options = nil, &block)
49
- super
50
- end
51
48
 
52
49
  # Render html tag
53
50
  def pre_render
@@ -98,15 +95,15 @@ module UiBibz::Ui::Core::Forms::Dates
98
95
  end
99
96
 
100
97
  def date_locale
101
- add_html_data 'date_locale', I18n.locale.to_s
98
+ add_html_data 'date_locale', value: I18n.locale.to_s
102
99
  end
103
100
 
104
101
  def provide
105
- add_html_data 'provide', 'datepicker'
102
+ add_html_data 'provide', value: 'datepicker'
106
103
  end
107
104
 
108
105
  def format
109
- add_html_data 'date_format', picker_pattern
106
+ add_html_data 'date_format', value: picker_pattern
110
107
  end
111
108
 
112
109
  def picker_pattern
@@ -114,7 +111,7 @@ module UiBibz::Ui::Core::Forms::Dates
114
111
  end
115
112
 
116
113
  def today_btn
117
- add_html_data 'date_today_btn', 'linked'
114
+ add_html_data 'date_today_btn', value: 'linked'
118
115
  end
119
116
 
120
117
  def today_highlight
@@ -130,35 +127,35 @@ module UiBibz::Ui::Core::Forms::Dates
130
127
  end
131
128
 
132
129
  def dates_disabled
133
- add_html_data('dates_disabled', [options[:dates_disabled]].flatten) if options[:dates_disabled]
130
+ add_html_data('dates_disabled', value: [options[:dates_disabled]].flatten) if options[:dates_disabled]
134
131
  end
135
132
 
136
133
  def toggle_active
137
- add_html_data('date_toggle_active', true)
134
+ add_html_data('date_toggle_active')
138
135
  end
139
136
 
140
137
  def display_mode
141
- add_html_data('date_start_view', views[options[:display_mode]]) if options[:display_mode]
138
+ add_html_data('date_start_view', value: views[options[:display_mode]]) if options[:display_mode]
142
139
  end
143
140
 
144
141
  def display_mode_min
145
- add_html_data('date_min_view_mode', views[options[:display_mode_min]]) if options[:display_mode_min]
142
+ add_html_data('date_min_view_mode', value: views[options[:display_mode_min]]) if options[:display_mode_min]
146
143
  end
147
144
 
148
145
  def display_mode_max
149
- add_html_data('date_max_view_mode', views[options[:display_mode_max]]) if options[:display_mode_max]
146
+ add_html_data('date_max_view_mode', value: views[options[:display_mode_max]]) if options[:display_mode_max]
150
147
  end
151
148
 
152
149
  def days_of_week_disabled
153
- add_html_data('date_days_of_week_disabled', [options[:days_of_week_disabled]].flatten) if options[:days_of_week_disabled]
150
+ add_html_data('date_days_of_week_disabled', value: [options[:days_of_week_disabled]].flatten) if options[:days_of_week_disabled]
154
151
  end
155
152
 
156
153
  def days_of_week_highlighted
157
- add_html_data('date_days_of_week_highlighted', [options[:days_of_week_highlighted]].flatten) if options[:days_of_week_highlighted]
154
+ add_html_data('date_days_of_week_highlighted', value: [options[:days_of_week_highlighted]].flatten) if options[:days_of_week_highlighted]
158
155
  end
159
156
 
160
157
  def multiple
161
- add_html_data('date_multidate', options[:multiple]) if options[:multiple]
158
+ add_html_data('date_multidate', value: options[:multiple]) if options[:multiple]
162
159
  end
163
160
 
164
161
  # :lg, :sm or :xs
@@ -5,7 +5,6 @@ module UiBibz::Ui::Core::Forms::Dropdowns::Components
5
5
  #
6
6
  class DropdownDivider < UiBibz::Ui::Base
7
7
  # See UiBibz::Ui::Core::Component.initialize
8
- def initialize; end
9
8
 
10
9
  # Render html tag
11
10
  def render
@@ -34,9 +34,6 @@ module UiBibz::Ui::Core::Forms::Dropdowns::Components
34
34
  #
35
35
  class DropdownHeader < UiBibz::Ui::Core::Component
36
36
  # See UiBibz::Ui::Core::Component.initialize
37
- def initialize(content = nil, options = nil, html_options = nil, &block)
38
- super
39
- end
40
37
 
41
38
  # Render html tag
42
39
  def pre_render
@@ -7,7 +7,6 @@ module UiBibz::Ui::Core::Forms::Dropdowns
7
7
  # Create a dropdown
8
8
  #
9
9
  # This element is an extend of UiBibz::Ui::Core::Component.
10
- # You can use tap method to add list items.
11
10
  #
12
11
  # ==== Attributes
13
12
  #
@@ -50,7 +49,7 @@ module UiBibz::Ui::Core::Forms::Dropdowns
50
49
  #
51
50
  # ==== Helper
52
51
  #
53
- # dropdown(name, options = { tap: true }, html_options = {}) do |d|
52
+ # dropdown(name, options = {}, html_options = {}) do |d|
54
53
  # d.link(content, options = {}, html_options = {})
55
54
  # d.link(options = {}, html_options = {}) do
56
55
  # content
@@ -63,6 +62,8 @@ module UiBibz::Ui::Core::Forms::Dropdowns
63
62
  # end
64
63
  #
65
64
  class Dropdown < UiBibz::Ui::Core::Component
65
+ include UiBibz::Ui::Concerns::HtmlConcern
66
+
66
67
  def initialize(content, options = nil, html_options = nil, &block)
67
68
  super
68
69
  @items = []
@@ -95,16 +96,6 @@ module UiBibz::Ui::Core::Forms::Dropdowns
95
96
  @items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(content, options, html_options, &block).render
96
97
  end
97
98
 
98
- # Add html component
99
- def html(content = nil, &block)
100
- if !block.nil?
101
- context = eval('self', block.binding) # rubocop:disable Style/EvalWithLocation
102
- @items << context.capture(&block)
103
- else
104
- @items << content
105
- end
106
- end
107
-
108
99
  def id
109
100
  @id ||= html_options[:id] || generate_id('dropdown')
110
101
  end
@@ -129,7 +120,7 @@ module UiBibz::Ui::Core::Forms::Dropdowns
129
120
  end
130
121
 
131
122
  def ul_html
132
- content_tag :div, @items.join.html_safe, class: join_classes('dropdown-menu', position, open), 'arial-labelledby' => id
123
+ content_tag :div, @items.join.html_safe, class: join_classes('dropdown-menu', theme, position, open), 'arial-labelledby' => id
133
124
  end
134
125
 
135
126
  def dropdown_tag
@@ -172,5 +163,9 @@ module UiBibz::Ui::Core::Forms::Dropdowns
172
163
  def size
173
164
  "btn-#{@options[:size]}" if @options[:size]
174
165
  end
166
+
167
+ def theme
168
+ 'dropdown-menu-dark' if @options[:theme]
169
+ end
175
170
  end
176
171
  end
@@ -56,9 +56,6 @@ module UiBibz::Ui::Core::Forms::Dropdowns
56
56
  #
57
57
  class SplitDropdown < UiBibz::Ui::Core::Forms::Dropdowns::Dropdown
58
58
  # See UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.initialize
59
- def initialize(name, options = nil, html_options = nil, &block)
60
- super
61
- end
62
59
 
63
60
  # Render html tag
64
61
  def pre_render
@@ -42,30 +42,40 @@ module UiBibz::Ui::Core::Forms::Files
42
42
  #
43
43
  class FileField < UiBibz::Ui::Core::Component
44
44
  # See UiBibz::Ui::Core::Component.initialize
45
- def initialize(content = nil, options = nil, html_options = nil, &block)
46
- super
47
- end
48
45
 
49
46
  # Render html tag
50
47
  def pre_render
51
48
  content_tag :div, html_options do
52
- concat file_field_tag content, class: 'custom-file-input', multiple: options[:multiple], disabled: disabled?
53
- concat label_tag label_name, label_content, class: 'custom-file-label'
49
+ concat file_field_tag content, class: 'form-file-input', multiple: options[:multiple], disabled: disabled?
50
+ concat label_text_and_button
54
51
  end
55
52
  end
56
53
 
57
54
  private
58
55
 
59
- def label_name
60
- html_options[:id] || content
56
+ def label_text_and_button
57
+ label_tag label_name, class: 'form-file-label' do
58
+ concat content_tag(:span, format_value(options[:input_text] || options[:value]), class: 'form-file-text')
59
+ concat content_tag(:span, options[:button_text] || 'Browse', class: 'form-file-button')
60
+ end
61
61
  end
62
62
 
63
- def label_content
64
- options[:value] || ''
63
+ def format_value(value)
64
+ if value.is_a? ActiveStorage::Attached::One
65
+ return '' unless value.attached?
66
+
67
+ return value.attachment.blob.filename
68
+ end
69
+
70
+ value.to_s
71
+ end
72
+
73
+ def label_name
74
+ html_options[:id] || content
65
75
  end
66
76
 
67
77
  def component_html_classes
68
- super << 'custom-file'
78
+ super << 'form-file'
69
79
  end
70
80
  end
71
81
  end
@@ -39,9 +39,6 @@ module UiBibz::Ui::Core::Forms::Numbers
39
39
  #
40
40
  class FormulaField < UiBibz::Ui::Core::Component
41
41
  # See UiBibz::Ui::Core::Component.initialize
42
- def initialize(content = nil, options = nil, html_options = nil, &block)
43
- super
44
- end
45
42
 
46
43
  # Render html tag
47
44
  def pre_render
@@ -51,7 +48,7 @@ module UiBibz::Ui::Core::Forms::Numbers
51
48
  private
52
49
 
53
50
  def formula_field_html_tag
54
- UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new(class: join_classes('formula_field', status, size)).tap do |sf|
51
+ UiBibz::Ui::Core::Forms::Surrounds::SurroundField.new(class: join_classes('formula_field', state, size)).tap do |sf|
55
52
  sf.text_field formula_field_name, nil, text_field_formula_html_options
56
53
  sf.addon '=', class: 'formula-field-sign'
57
54
  sf.text_field content, nil, text_field_input_html_options
@@ -75,7 +72,7 @@ module UiBibz::Ui::Core::Forms::Numbers
75
72
  end
76
73
 
77
74
  def component_html_options
78
- options[:state] == :disabled ? { disabled: 'disabled' } : {}
75
+ disabled? ? { disabled: 'disabled' } : {}
79
76
  end
80
77
 
81
78
  def formula_field_alert_glyph
@@ -87,16 +84,27 @@ module UiBibz::Ui::Core::Forms::Numbers
87
84
  end
88
85
 
89
86
  def content_formula_name
90
- content.to_s.split('').select { |i| i == ']' }.count.positive? ? content.to_s.gsub(/]$/, '_formula]') : "#{content}_formula"
87
+ content.to_s.split('').count { |i| i == ']' }.positive? ? content.to_s.gsub(/]$/, '_formula]') : "#{content}_formula"
91
88
  end
92
89
 
93
- def status
94
- "has-#{options[:status]}" if options[:status]
90
+ def state
91
+ states_matching[@options[:status] || @options[:state]] if @options[:status] || @options[:state]
95
92
  end
96
93
 
97
94
  # :lg, :sm or :xs
98
95
  def size
99
96
  "input-group-#{options[:size]}" if options[:size]
100
97
  end
98
+
99
+ def states_matching
100
+ {
101
+ success: 'is-valid',
102
+ danger: 'is-invalid',
103
+ valid: 'is-valid',
104
+ invalid: 'is-invalid',
105
+ active: 'active',
106
+ disabled: 'disabled'
107
+ }
108
+ end
101
109
  end
102
110
  end