ui_bibz 2.4.0 → 2.5.0

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 (273) hide show
  1. checksums.yaml +4 -4
  2. data/.overcommit.yml +5 -0
  3. data/.rubocop.yml +52 -0
  4. data/.rubocop_todo.yml +25 -0
  5. data/Gemfile +5 -3
  6. data/Gemfile.lock +25 -1
  7. data/Rakefile +8 -6
  8. data/config/initializers/simple_form_init.rb +3 -1
  9. data/config/initializers/will_paginate.rb +11 -6
  10. data/lib/generators/ui_bibz/install_generator.rb +6 -5
  11. data/lib/generators/ui_bibz/templates/ui_bibz_initializer.rb +1 -1
  12. data/lib/tasks/ui_bibz_tasks.rake +2 -0
  13. data/lib/ui_bibz.rb +91 -100
  14. data/lib/ui_bibz/concerns/models/searchable.rb +56 -61
  15. data/lib/ui_bibz/helpers/ui/core/boxes_helper.rb +9 -9
  16. data/lib/ui_bibz/helpers/ui/core/forms_helper.rb +26 -26
  17. data/lib/ui_bibz/helpers/ui/core/icons_helper.rb +6 -6
  18. data/lib/ui_bibz/helpers/ui/core/layouts_helper.rb +5 -5
  19. data/lib/ui_bibz/helpers/ui/core/lists_helper.rb +5 -4
  20. data/lib/ui_bibz/helpers/ui/core/navigations_helper.rb +9 -9
  21. data/lib/ui_bibz/helpers/ui/core/notifications_helper.rb +11 -11
  22. data/lib/ui_bibz/helpers/ui/core/windows_helper.rb +3 -3
  23. data/lib/ui_bibz/helpers/ui/core_helper.rb +2 -0
  24. data/lib/ui_bibz/helpers/ui/ux_helper.rb +12 -12
  25. data/lib/ui_bibz/helpers/utils_helper.rb +8 -11
  26. data/lib/ui_bibz/infos.rb +9 -7
  27. data/lib/ui_bibz/inputs/ui_bibz_form/ui_bibz_form_builder.rb +40 -39
  28. data/lib/ui_bibz/inputs/ui_bibz_inputs/base_input.rb +6 -5
  29. data/lib/ui_bibz/inputs/ui_bibz_inputs/collection_input.rb +8 -6
  30. data/lib/ui_bibz/inputs/ui_bibz_inputs/string_input.rb +18 -18
  31. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_auto_complete_field_input.rb +3 -2
  32. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_box_switch_field_input.rb +3 -2
  33. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_checkbox_field_input.rb +3 -2
  34. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_choice_group_input.rb +6 -5
  35. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_date_picker_field_input.rb +3 -2
  36. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_dropdown_select_field_input.rb +3 -3
  37. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_file_field_input.rb +3 -2
  38. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_formula_field_input.rb +5 -4
  39. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_markdown_editor_field_input.rb +3 -2
  40. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_multi_column_field_input.rb +3 -2
  41. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_multi_select_field_input.rb +3 -3
  42. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_number_field_input.rb +3 -2
  43. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_radio_field_input.rb +7 -7
  44. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_range_field_input.rb +3 -2
  45. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_select_field_input.rb +3 -2
  46. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_switch_field_input.rb +3 -2
  47. data/lib/ui_bibz/inputs/ui_bibz_inputs/ui_text_field_input.rb +3 -2
  48. data/lib/ui_bibz/rails/engine.rb +11 -15
  49. data/lib/ui_bibz/ui/base.rb +10 -6
  50. data/lib/ui_bibz/ui/core/boxes/card.rb +31 -32
  51. data/lib/ui_bibz/ui/core/boxes/card_accordion.rb +7 -8
  52. data/lib/ui_bibz/ui/core/boxes/card_column.rb +11 -12
  53. data/lib/ui_bibz/ui/core/boxes/card_deck.rb +11 -12
  54. data/lib/ui_bibz/ui/core/boxes/card_group.rb +11 -12
  55. data/lib/ui_bibz/ui/core/boxes/components/body/card_body_link.rb +5 -6
  56. data/lib/ui_bibz/ui/core/boxes/components/body/card_body_text.rb +5 -6
  57. data/lib/ui_bibz/ui/core/boxes/components/body/card_body_title.rb +5 -6
  58. data/lib/ui_bibz/ui/core/boxes/components/card_body.rb +11 -12
  59. data/lib/ui_bibz/ui/core/boxes/components/card_footer.rb +7 -8
  60. data/lib/ui_bibz/ui/core/boxes/components/card_header.rb +12 -13
  61. data/lib/ui_bibz/ui/core/boxes/components/card_image.rb +6 -7
  62. data/lib/ui_bibz/ui/core/boxes/components/card_list_group.rb +4 -5
  63. data/lib/ui_bibz/ui/core/boxes/components/card_tab_group.rb +5 -6
  64. data/lib/ui_bibz/ui/core/boxes/jumbotron.rb +5 -6
  65. data/lib/ui_bibz/ui/core/component.rb +22 -20
  66. data/lib/ui_bibz/ui/core/forms/buttons/button.rb +14 -15
  67. data/lib/ui_bibz/ui/core/forms/buttons/button_group.rb +14 -15
  68. data/lib/ui_bibz/ui/core/forms/buttons/button_link.rb +5 -6
  69. data/lib/ui_bibz/ui/core/forms/buttons/button_refresh.rb +11 -11
  70. data/lib/ui_bibz/ui/core/forms/buttons/components/button_group_dropdown.rb +5 -6
  71. data/lib/ui_bibz/ui/core/forms/buttons/components/button_group_split_dropdown.rb +5 -6
  72. data/lib/ui_bibz/ui/core/forms/choices/box_switch_field.rb +5 -6
  73. data/lib/ui_bibz/ui/core/forms/choices/checkbox_field.rb +10 -11
  74. data/lib/ui_bibz/ui/core/forms/choices/choice_group.rb +8 -9
  75. data/lib/ui_bibz/ui/core/forms/choices/components/choice.rb +5 -6
  76. data/lib/ui_bibz/ui/core/forms/choices/radio_field.rb +6 -7
  77. data/lib/ui_bibz/ui/core/forms/choices/switch_field.rb +4 -5
  78. data/lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb +22 -23
  79. data/lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_divider.rb +3 -5
  80. data/lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_header.rb +4 -5
  81. data/lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb +6 -7
  82. data/lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb +21 -22
  83. data/lib/ui_bibz/ui/core/forms/dropdowns/split_dropdown.rb +8 -9
  84. data/lib/ui_bibz/ui/core/forms/files/file_field.rb +5 -6
  85. data/lib/ui_bibz/ui/core/forms/numbers/formula_field.rb +10 -11
  86. data/lib/ui_bibz/ui/core/forms/numbers/number_field.rb +3 -4
  87. data/lib/ui_bibz/ui/core/forms/numbers/range_field.rb +3 -4
  88. data/lib/ui_bibz/ui/core/forms/selects/abstract_select.rb +9 -9
  89. data/lib/ui_bibz/ui/core/forms/selects/dropdown_select_field.rb +6 -7
  90. data/lib/ui_bibz/ui/core/forms/selects/multi_column_field.rb +9 -10
  91. data/lib/ui_bibz/ui/core/forms/selects/multi_select_field.rb +13 -14
  92. data/lib/ui_bibz/ui/core/forms/selects/select_field.rb +6 -7
  93. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_addon.rb +4 -4
  94. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button.rb +3 -3
  95. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_group.rb +3 -3
  96. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_link.rb +3 -3
  97. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_button_refresh.rb +3 -3
  98. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_checkbox_field.rb +4 -4
  99. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_dropdown.rb +3 -3
  100. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_radio_field.rb +3 -3
  101. data/lib/ui_bibz/ui/core/forms/surrounds/components/surround_switch_field.rb +3 -3
  102. data/lib/ui_bibz/ui/core/forms/surrounds/surround_field.rb +24 -25
  103. data/lib/ui_bibz/ui/core/forms/textareas/markdown_editor_field.rb +4 -5
  104. data/lib/ui_bibz/ui/core/forms/texts/auto_complete_field.rb +6 -7
  105. data/lib/ui_bibz/ui/core/forms/texts/text_field.rb +6 -6
  106. data/lib/ui_bibz/ui/core/icons/components/glyph_counter.rb +5 -6
  107. data/lib/ui_bibz/ui/core/icons/components/glyph_text.rb +5 -6
  108. data/lib/ui_bibz/ui/core/icons/glyph.rb +13 -14
  109. data/lib/ui_bibz/ui/core/icons/glyph_group.rb +16 -17
  110. data/lib/ui_bibz/ui/core/icons/star.rb +7 -9
  111. data/lib/ui_bibz/ui/core/layouts/col.rb +20 -21
  112. data/lib/ui_bibz/ui/core/layouts/container.rb +5 -6
  113. data/lib/ui_bibz/ui/core/layouts/row.rb +4 -5
  114. data/lib/ui_bibz/ui/core/lists/components/list.rb +19 -20
  115. data/lib/ui_bibz/ui/core/lists/components/list/list_body.rb +4 -5
  116. data/lib/ui_bibz/ui/core/lists/components/list/list_header.rb +5 -6
  117. data/lib/ui_bibz/ui/core/lists/list_group.rb +15 -16
  118. data/lib/ui_bibz/ui/core/navigations/breadcrumb.rb +5 -6
  119. data/lib/ui_bibz/ui/core/navigations/components/breadcrumb_link.rb +7 -8
  120. data/lib/ui_bibz/ui/core/navigations/components/nav_dropdown.rb +6 -7
  121. data/lib/ui_bibz/ui/core/navigations/components/nav_link.rb +12 -13
  122. data/lib/ui_bibz/ui/core/navigations/components/nav_link_link.rb +7 -8
  123. data/lib/ui_bibz/ui/core/navigations/components/nav_link_list.rb +4 -5
  124. data/lib/ui_bibz/ui/core/navigations/components/nav_link_span.rb +8 -9
  125. data/lib/ui_bibz/ui/core/navigations/components/nav_text.rb +8 -9
  126. data/lib/ui_bibz/ui/core/navigations/components/navbar_brand.rb +5 -6
  127. data/lib/ui_bibz/ui/core/navigations/components/navbar_form.rb +8 -8
  128. data/lib/ui_bibz/ui/core/navigations/components/navbar_nav.rb +6 -7
  129. data/lib/ui_bibz/ui/core/navigations/components/navbar_text.rb +6 -7
  130. data/lib/ui_bibz/ui/core/navigations/components/pagination_link.rb +5 -6
  131. data/lib/ui_bibz/ui/core/navigations/components/toolbar_form.rb +7 -7
  132. data/lib/ui_bibz/ui/core/navigations/link.rb +6 -7
  133. data/lib/ui_bibz/ui/core/navigations/nav.rb +20 -27
  134. data/lib/ui_bibz/ui/core/navigations/navbar.rb +23 -24
  135. data/lib/ui_bibz/ui/core/navigations/pagination.rb +9 -12
  136. data/lib/ui_bibz/ui/core/navigations/tab_group.rb +7 -8
  137. data/lib/ui_bibz/ui/core/navigations/toolbar.rb +14 -15
  138. data/lib/ui_bibz/ui/core/notifications/alert.rb +11 -12
  139. data/lib/ui_bibz/ui/core/notifications/badge.rb +7 -8
  140. data/lib/ui_bibz/ui/core/notifications/components/alert_body.rb +5 -6
  141. data/lib/ui_bibz/ui/core/notifications/components/alert_header.rb +8 -9
  142. data/lib/ui_bibz/ui/core/notifications/components/bar.rb +11 -12
  143. data/lib/ui_bibz/ui/core/notifications/components/toast_body.rb +5 -6
  144. data/lib/ui_bibz/ui/core/notifications/components/toast_header.rb +7 -8
  145. data/lib/ui_bibz/ui/core/notifications/progress_bar.rb +12 -13
  146. data/lib/ui_bibz/ui/core/notifications/spinner.rb +11 -12
  147. data/lib/ui_bibz/ui/core/notifications/toast.rb +9 -10
  148. data/lib/ui_bibz/ui/core/windows/components/modal_body.rb +4 -5
  149. data/lib/ui_bibz/ui/core/windows/components/modal_footer.rb +4 -5
  150. data/lib/ui_bibz/ui/core/windows/components/modal_header.rb +6 -7
  151. data/lib/ui_bibz/ui/core/windows/modal.rb +8 -9
  152. data/lib/ui_bibz/ui/extensions/core/component/glyph_extension.rb +13 -15
  153. data/lib/ui_bibz/ui/extensions/core/component/klass_extension.rb +9 -10
  154. data/lib/ui_bibz/ui/extensions/core/component/popover_extension.rb +22 -21
  155. data/lib/ui_bibz/ui/extensions/core/forms/connect_extension.rb +9 -9
  156. data/lib/ui_bibz/ui/extensions/core/forms/surround_extension.rb +8 -10
  157. data/lib/ui_bibz/ui/ux/containers/components/panel_body.rb +5 -6
  158. data/lib/ui_bibz/ui/ux/containers/components/panel_column.rb +6 -7
  159. data/lib/ui_bibz/ui/ux/containers/components/panel_deck.rb +6 -7
  160. data/lib/ui_bibz/ui/ux/containers/components/panel_footer.rb +5 -6
  161. data/lib/ui_bibz/ui/ux/containers/components/panel_group.rb +6 -7
  162. data/lib/ui_bibz/ui/ux/containers/components/panel_header.rb +12 -12
  163. data/lib/ui_bibz/ui/ux/containers/components/panel_tab_group.rb +5 -6
  164. data/lib/ui_bibz/ui/ux/containers/components/panel_toolbar.rb +5 -6
  165. data/lib/ui_bibz/ui/ux/containers/panel.rb +21 -22
  166. data/lib/ui_bibz/ui/ux/tables/components/actions.rb +14 -16
  167. data/lib/ui_bibz/ui/ux/tables/components/as.rb +8 -9
  168. data/lib/ui_bibz/ui/ux/tables/components/column.rb +4 -4
  169. data/lib/ui_bibz/ui/ux/tables/components/columns.rb +4 -3
  170. data/lib/ui_bibz/ui/ux/tables/components/store.rb +5 -7
  171. data/lib/ui_bibz/ui/ux/tables/components/thead.rb +5 -6
  172. data/lib/ui_bibz/ui/ux/tables/extensions/actionable.rb +24 -23
  173. data/lib/ui_bibz/ui/ux/tables/extensions/paginable.rb +8 -10
  174. data/lib/ui_bibz/ui/ux/tables/extensions/searchable.rb +9 -9
  175. data/lib/ui_bibz/ui/ux/tables/extensions/sortable.rb +26 -26
  176. data/lib/ui_bibz/ui/ux/tables/table.rb +32 -39
  177. data/lib/ui_bibz/ui/ux/tables/table_card.rb +18 -26
  178. data/lib/ui_bibz/ui/ux/tables/table_pagination.rb +15 -18
  179. data/lib/ui_bibz/ui/ux/tables/table_pagination_per_page.rb +15 -18
  180. data/lib/ui_bibz/ui/ux/tables/table_search_field.rb +19 -23
  181. data/lib/ui_bibz/utils/glyph_changer.rb +13 -13
  182. data/lib/ui_bibz/utils/internationalization.rb +10 -7
  183. data/lib/ui_bibz/utils/screwdriver.rb +7 -5
  184. data/test/dummy/Rakefile +3 -1
  185. data/test/dummy/app/controllers/application_controller.rb +2 -0
  186. data/test/dummy/app/controllers/users_controller.rb +15 -14
  187. data/test/dummy/app/helpers/application_helper.rb +2 -0
  188. data/test/dummy/app/models/application_record.rb +2 -0
  189. data/test/dummy/app/models/continent.rb +2 -0
  190. data/test/dummy/app/models/country.rb +2 -0
  191. data/test/dummy/app/models/user.rb +2 -0
  192. data/test/dummy/bin/bundle +3 -1
  193. data/test/dummy/bin/rails +3 -1
  194. data/test/dummy/bin/rake +2 -0
  195. data/test/dummy/bin/setup +10 -8
  196. data/test/dummy/config.ru +2 -0
  197. data/test/dummy/config/application.rb +5 -4
  198. data/test/dummy/config/boot.rb +4 -2
  199. data/test/dummy/config/environment.rb +3 -1
  200. data/test/dummy/config/environments/development.rb +2 -0
  201. data/test/dummy/config/environments/production.rb +2 -0
  202. data/test/dummy/config/environments/test.rb +2 -0
  203. data/test/dummy/config/initializers/assets.rb +2 -0
  204. data/test/dummy/config/initializers/backtrace_silencers.rb +2 -0
  205. data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
  206. data/test/dummy/config/initializers/filter_parameter_logging.rb +2 -0
  207. data/test/dummy/config/initializers/inflections.rb +2 -0
  208. data/test/dummy/config/initializers/mime_types.rb +2 -0
  209. data/test/dummy/config/initializers/session_store.rb +2 -0
  210. data/test/dummy/config/initializers/simple_form_bootstrap.rb +3 -1
  211. data/test/dummy/config/initializers/ui_bibz.rb +1 -1
  212. data/test/dummy/config/initializers/wrap_parameters.rb +2 -0
  213. data/test/dummy/config/routes.rb +2 -0
  214. data/test/dummy/db/migrate/20150123191805_create_users.rb +2 -0
  215. data/test/dummy/db/migrate/20170309084406_continents.rb +2 -0
  216. data/test/dummy/db/migrate/20170309084453_countries.rb +2 -0
  217. data/test/dummy/db/schema.rb +22 -22
  218. data/test/dummy/test/models/user_test.rb +2 -0
  219. data/test/factories/user.rb +6 -4
  220. data/test/simple_form_test.rb +28 -34
  221. data/test/store_test.rb +10 -9
  222. data/test/support/factory_bot.rb +9 -5
  223. data/test/test_helper.rb +8 -8
  224. data/test/ui/core/boxes/card_test.rb +28 -26
  225. data/test/ui/core/boxes/jumbotron_test.rb +4 -3
  226. data/test/ui/core/component_test.rb +4 -4
  227. data/test/ui/core/forms/buttons/button_group_test.rb +8 -7
  228. data/test/ui/core/forms/buttons/button_link_test.rb +16 -14
  229. data/test/ui/core/forms/buttons/button_refresh_test.rb +5 -5
  230. data/test/ui/core/forms/buttons/button_test.rb +25 -23
  231. data/test/ui/core/forms/choices/box_switch_field_test.rb +62 -62
  232. data/test/ui/core/forms/choices/checkbox_field_test.rb +7 -6
  233. data/test/ui/core/forms/choices/choice_group_test.rb +6 -5
  234. data/test/ui/core/forms/choices/radio_field_test.rb +7 -6
  235. data/test/ui/core/forms/dates/date_picker_field_test.rb +12 -11
  236. data/test/ui/core/forms/dropdowns/dropdown_test.rb +12 -11
  237. data/test/ui/core/forms/files/text_field_test.rb +7 -6
  238. data/test/ui/core/forms/numbers/formula_field_test.rb +7 -6
  239. data/test/ui/core/forms/numbers/number_field_test.rb +12 -11
  240. data/test/ui/core/forms/numbers/range_field_test.rb +12 -11
  241. data/test/ui/core/forms/selects/dropdown_select_field_test.rb +61 -60
  242. data/test/ui/core/forms/selects/multi_column_field_test.rb +14 -13
  243. data/test/ui/core/forms/selects/multi_select_field_test.rb +19 -18
  244. data/test/ui/core/forms/selects/select_field_test.rb +13 -13
  245. data/test/ui/core/forms/surrounds/surround_field_test.rb +54 -54
  246. data/test/ui/core/forms/textareas/markdown_editor_field_test.rb +7 -6
  247. data/test/ui/core/forms/texts/auto_complete_field_test.rb +8 -7
  248. data/test/ui/core/forms/texts/text_field_test.rb +17 -16
  249. data/test/ui/core/icons/glyph_group_test.rb +8 -8
  250. data/test/ui/core/icons/glyph_test.rb +4 -4
  251. data/test/ui/core/icons/star_test.rb +37 -36
  252. data/test/ui/core/layouts/col_test.rb +11 -10
  253. data/test/ui/core/layouts/container_test.rb +3 -2
  254. data/test/ui/core/layouts/row_test.rb +4 -3
  255. data/test/ui/core/lists/list_group_test.rb +7 -6
  256. data/test/ui/core/navigations/breadcrumb_test.rb +12 -14
  257. data/test/ui/core/navigations/link_test.rb +9 -8
  258. data/test/ui/core/navigations/nav_test.rb +22 -21
  259. data/test/ui/core/navigations/navbar_test.rb +11 -11
  260. data/test/ui/core/navigations/pagination_test.rb +14 -13
  261. data/test/ui/core/navigations/tab_group_test.rb +22 -21
  262. data/test/ui/core/navigations/toolbar_test.rb +4 -3
  263. data/test/ui/core/notifications/alert_test.rb +5 -4
  264. data/test/ui/core/notifications/badge_test.rb +5 -4
  265. data/test/ui/core/notifications/progress_bar_test.rb +13 -13
  266. data/test/ui/core/notifications/spinner_test.rb +9 -8
  267. data/test/ui/core/notifications/toast_test.rb +3 -2
  268. data/test/ui/core/windows/modal_test.rb +3 -2
  269. data/test/ui/ux/containers/panel_test.rb +7 -6
  270. data/test/ui/ux/tables/table_test.rb +33 -33
  271. data/test/ui_bibz_test.rb +3 -1
  272. data/ui_bibz.gemspec +32 -28
  273. metadata +73 -42
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module UiBibz::Ui::Ux::Tables
2
4
  class Searchable < UiBibz::Ui::Base
3
-
4
- def initialize store, options, html_options = nil
5
+ def initialize(store, options, html_options = nil)
5
6
  @store = store
6
7
  @options = options
7
8
  @html_options = html_options
@@ -20,17 +21,17 @@ module UiBibz::Ui::Ux::Tables
20
21
  @options[:searchable].nil? ? true : @options[:searchable]
21
22
  end
22
23
 
23
- private
24
+ private
24
25
 
25
- def translate_searchable_attributes_by_active_record attr
26
+ def translate_searchable_attributes_by_active_record(attr)
26
27
  @store.model.human_attribute_name(attr)
27
28
  end
28
29
 
29
30
  def table_title
30
- if @options[:title] != false
31
- title = @options[:title] || "#{ @store.controller.humanize } list"
32
- UiBibz::Utils::Internationalization.new("ui_bibz.table.title.#{ model_name }", default: ["ui_bibz.table.title.defaults", title]).translate
33
- end
31
+ return unless @options[:title] != false
32
+
33
+ title = @options[:title] || "#{@store.controller.humanize} list"
34
+ UiBibz::Utils::Internationalization.new("ui_bibz.table.title.#{model_name}", default: ['ui_bibz.table.title.defaults', title]).translate
34
35
  end
35
36
 
36
37
  def model_name
@@ -44,6 +45,5 @@ module UiBibz::Ui::Ux::Tables
44
45
  def table_glyph
45
46
  UiBibz::Ui::Core::Icons::Glyph.new(@options[:glyph]).render unless @options[:glyph].nil?
46
47
  end
47
-
48
48
  end
49
49
  end
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module UiBibz::Ui::Ux::Tables
2
4
  class Sortable < UiBibz::Ui::Base
3
-
4
- def initialize store, options
5
+ def initialize(store, options)
5
6
  @store = store
6
7
  @options = options
7
8
  end
8
9
 
9
10
  # header use i18n
10
- def header column, name = nil
11
+ def header(column, name = nil)
11
12
  @column = column
12
13
  defaults = [
13
14
  header_name(name),
@@ -16,61 +17,61 @@ module UiBibz::Ui::Ux::Tables
16
17
  translate_headers_by_active_record,
17
18
  default_header_name(name)
18
19
  ].compact
19
- @name = UiBibz::Utils::Internationalization.new(translate_headers_by_model, default: defaults).translate
20
+ @name = UiBibz::Utils::Internationalization.new(translate_headers_by_model, default: defaults).translate
20
21
  sortable? ? sortable_link : title
21
22
  end
22
23
 
23
- private
24
+ private
24
25
 
25
26
  def sortable_link
26
27
  link_to title.html_safe, url_for(url_options_o), { class: cls }
27
28
  end
28
29
 
29
- def header_name name
30
+ def header_name(name)
30
31
  name || @column.name
31
32
  end
32
33
 
33
- def default_header_name name
34
+ def default_header_name(name)
34
35
  name || @column.data_index.to_s.try('titleize')
35
36
  end
36
37
 
37
38
  def translate_headers_by_model
38
- "ui_bibz.grid.headers.#{ @store.model.to_s.underscore }.#{ @column.data_index }"
39
+ "ui_bibz.grid.headers.#{@store.model.to_s.underscore}.#{@column.data_index}"
39
40
  end
40
41
 
41
42
  def translate_headers_by_defaults
42
- "ui_bibz.grid.headers.defaults.#{ @column.data_index }"
43
+ "ui_bibz.grid.headers.defaults.#{@column.data_index}"
43
44
  end
44
45
 
45
46
  def translate_headers_by_defaults_active_record
46
- "activerecord.attributes.defaults.#{ @column.data_index }"
47
+ "activerecord.attributes.defaults.#{@column.data_index}"
47
48
  end
48
49
 
49
50
  def translate_headers_by_active_record
50
- "activerecord.attributes.#{ @store.model.to_s.underscore }.#{ @column.data_index }"
51
+ "activerecord.attributes.#{@store.model.to_s.underscore}.#{@column.data_index}"
51
52
  end
52
53
 
53
54
  def url_options_o
54
- args = {
55
- controller: @store.controller,
56
- action: @store.action,
57
- search: @store.search,
58
- sort: sort_name,
59
- column_id: @column.id,
60
- direction: direction,
61
- only_path: true
55
+ args = {
56
+ controller: @store.controller,
57
+ action: @store.action,
58
+ search: @store.search,
59
+ sort: sort_name,
60
+ column_id: @column.id,
61
+ direction: direction,
62
+ only_path: true
62
63
  }
63
64
  args = args.merge({ id: @store.param_id }) if @store.param_id
64
65
  args = args.merge({ custom_sort: true, column_name: @column.data_index }) if @column.custom_sort
65
66
  args = args.merge({ parent: true }) if @column.parent
66
67
  args = args.merge({ store_id: @store.id }) unless @store.id.nil?
67
68
  args = args.merge({ link_type: 'column' })
68
- args = args.merge(@store.parameters.reject{ |k,v| default_parameters.include?(k.to_s) })
69
+ args = args.merge(@store.parameters.reject { |k, _v| default_parameters.include?(k.to_s) })
69
70
  args.with_indifferent_access
70
71
  end
71
72
 
72
73
  def default_parameters
73
- %w(column_id direction search store_id controller sort page per_page)
74
+ %w[column_id direction search store_id controller sort page per_page]
74
75
  end
75
76
 
76
77
  def sortable?
@@ -86,7 +87,7 @@ module UiBibz::Ui::Ux::Tables
86
87
  end
87
88
 
88
89
  def caret
89
- UiBibz::Ui::Core::Icons::Glyph.new("caret-#{ direction == 'desc' ? 'up' : 'down' }").render
90
+ UiBibz::Ui::Core::Icons::Glyph.new("caret-#{direction == 'desc' ? 'up' : 'down'}").render
90
91
  end
91
92
 
92
93
  def cls
@@ -94,7 +95,7 @@ module UiBibz::Ui::Ux::Tables
94
95
  end
95
96
 
96
97
  def direction
97
- sort_name == sort_column && sort_direction == "asc" ? "desc" : "asc"
98
+ sort_name == sort_column && sort_direction == 'asc' ? 'desc' : 'asc'
98
99
  end
99
100
 
100
101
  def column_name
@@ -102,7 +103,7 @@ module UiBibz::Ui::Ux::Tables
102
103
  end
103
104
 
104
105
  def sort_column_name
105
- @column.sort.nil? ? "#{ @store.model.to_s.underscore.pluralize }.#{ @column.data_index}" : @column.sort
106
+ @column.sort.nil? ? "#{@store.model.to_s.underscore.pluralize}.#{@column.data_index}" : @column.sort
106
107
  end
107
108
 
108
109
  def sort_name
@@ -114,8 +115,7 @@ module UiBibz::Ui::Ux::Tables
114
115
  end
115
116
 
116
117
  def sort_direction
117
- %w[asc desc].include?(@store.direction) ? @store.direction : "asc"
118
+ %w[asc desc].include?(@store.direction) ? @store.direction : 'asc'
118
119
  end
119
-
120
120
  end
121
121
  end
@@ -1,16 +1,17 @@
1
- require "ui_bibz/ui/ux/tables/components/store"
2
- require "ui_bibz/ui/ux/tables/components/columns"
3
- require "ui_bibz/ui/ux/tables/components/column"
4
- require "ui_bibz/ui/ux/tables/components/actions"
5
- require "ui_bibz/ui/ux/tables/components/thead"
6
- require "ui_bibz/ui/ux/tables/components/as"
7
- require "ui_bibz/ui/ux/tables/extensions/paginable"
8
- require "ui_bibz/ui/ux/tables/extensions/paginable"
9
- require "ui_bibz/ui/ux/tables/extensions/searchable"
10
- require "ui_bibz/ui/ux/tables/extensions/sortable"
11
- require "ui_bibz/ui/ux/tables/extensions/actionable"
1
+ # frozen_string_literal: true
2
+
3
+ require 'ui_bibz/ui/ux/tables/components/store'
4
+ require 'ui_bibz/ui/ux/tables/components/columns'
5
+ require 'ui_bibz/ui/ux/tables/components/column'
6
+ require 'ui_bibz/ui/ux/tables/components/actions'
7
+ require 'ui_bibz/ui/ux/tables/components/thead'
8
+ require 'ui_bibz/ui/ux/tables/components/as'
9
+ require 'ui_bibz/ui/ux/tables/extensions/paginable'
10
+ require 'ui_bibz/ui/ux/tables/extensions/paginable'
11
+ require 'ui_bibz/ui/ux/tables/extensions/searchable'
12
+ require 'ui_bibz/ui/ux/tables/extensions/sortable'
13
+ require 'ui_bibz/ui/ux/tables/extensions/actionable'
12
14
  module UiBibz::Ui::Ux::Tables
13
-
14
15
  # Create a Table
15
16
  #
16
17
  # This element is an extend of UiBibz::Ui::Core::Component.
@@ -95,23 +96,20 @@ module UiBibz::Ui::Ux::Tables
95
96
  # end
96
97
  # end
97
98
  class Table < UiBibz::Ui::Core::Component
98
-
99
- attr_accessor :columns
100
-
101
99
  # See UiBibz::Ui::Core::Component.initialize
102
- def initialize content = nil, options = nil, html_options = nil, &block
100
+ def initialize(content = nil, options = nil, html_options = nil, &block)
103
101
  super
104
102
  @columns = Columns.new
105
103
  @actions = Actions.new store
106
104
  end
107
105
 
108
106
  # Add table columns items
109
- def columns &block
107
+ def columns(&block)
110
108
  @columns.tap(&block)
111
109
  end
112
110
 
113
111
  # Add table actions items
114
- def actions &block
112
+ def actions(&block)
115
113
  @actions.tap(&block)
116
114
  end
117
115
 
@@ -127,16 +125,13 @@ module UiBibz::Ui::Ux::Tables
127
125
 
128
126
  # Store must be generated by *table_search_pagination* method
129
127
  def store
130
- @store ||= if @options[:store].nil?
131
- raise 'Store is nil!'
132
- elsif @options[:store].try(:records).nil?
133
- raise 'Store can be created only with "table_search_pagination" method!'
134
- else
135
- Store.new @options.delete :store
136
- end
128
+ raise 'Store is nil!' if @options[:store].nil?
129
+ raise 'Store can be created only with "table_search_pagination" method!' if @options[:store].try(:records).nil?
130
+
131
+ @store ||= Store.new @options[:store]
137
132
  end
138
133
 
139
- protected
134
+ protected
140
135
 
141
136
  def sort
142
137
  @sort ||= Sortable.new store, @options
@@ -151,12 +146,11 @@ module UiBibz::Ui::Ux::Tables
151
146
  end
152
147
 
153
148
  def type
154
- "table-#{ @options[:type] }" unless @options[:type].nil?
149
+ "table-#{@options[:type]}" unless @options[:type].nil?
155
150
  end
156
151
 
157
152
  def table_html
158
153
  content_tag(:table, html_options) do
159
-
160
154
  ths = cols.collect do |col|
161
155
  content_tag(:th, sort.header(col), class: col.class) unless col.hidden?
162
156
  end
@@ -178,7 +172,7 @@ module UiBibz::Ui::Ux::Tables
178
172
  end
179
173
 
180
174
  # Maybe create a class for td_content
181
- def td_content record, col
175
+ def td_content(record, col)
182
176
  content = col.count ? record.send(col.data_index).count : record.send(col.data_index)
183
177
  unless content.nil?
184
178
  content = content.strftime(col.date_format) unless col.date_format.nil?
@@ -189,39 +183,38 @@ module UiBibz::Ui::Ux::Tables
189
183
  content
190
184
  end
191
185
 
192
- private
186
+ private
193
187
 
194
188
  def component_html_classes
195
- ["table", striped, bordered, hoverable, size, responsive, reflow]
189
+ ['table', striped, bordered, hoverable, size, responsive, reflow]
196
190
  end
197
191
 
198
192
  def status
199
- "table-#{ @options[:status] }" unless @options[:status].nil?
193
+ "table-#{@options[:status]}" unless @options[:status].nil?
200
194
  end
201
195
 
202
196
  def striped
203
- "table-striped" unless @options[:striped].nil?
197
+ 'table-striped' unless @options[:striped].nil?
204
198
  end
205
199
 
206
200
  def bordered
207
- "table-bordered" unless @options[:bordered].nil?
201
+ 'table-bordered' unless @options[:bordered].nil?
208
202
  end
209
203
 
210
204
  def hoverable
211
- "table-hoverable" unless @options[:hoverable].nil?
205
+ 'table-hoverable' unless @options[:hoverable].nil?
212
206
  end
213
207
 
214
208
  def size
215
- "table-#{ @options[:size] }" unless @options[:size].nil?
209
+ "table-#{@options[:size]}" unless @options[:size].nil?
216
210
  end
217
211
 
218
212
  def responsive
219
- "table-responsive" unless @options[:responsive].nil?
213
+ 'table-responsive' unless @options[:responsive].nil?
220
214
  end
221
215
 
222
216
  def reflow
223
- "table-reflow" unless @options[:reflow].nil?
217
+ 'table-reflow' unless @options[:reflow].nil?
224
218
  end
225
-
226
219
  end
227
220
  end
@@ -1,6 +1,7 @@
1
- require "ui_bibz/ui/ux/tables/components/store"
2
- module UiBibz::Ui::Ux::Tables
1
+ # frozen_string_literal: true
3
2
 
3
+ require 'ui_bibz/ui/ux/tables/components/store'
4
+ module UiBibz::Ui::Ux::Tables
4
5
  # Create a TableCard
5
6
  #
6
7
  # This element is an extend of UiBibz::Ui::Core::Boxes::card.
@@ -104,11 +105,8 @@ module UiBibz::Ui::Ux::Tables
104
105
  # end
105
106
  # end
106
107
  class TableCard < UiBibz::Ui::Core::Boxes::Card
107
-
108
- attr_accessor :columns
109
-
110
108
  # See UiBibz::Ui::Core::Boxes::Card.initialize
111
- def initialize content = nil, options = nil, html_options = nil, &block
109
+ def initialize(content = nil, options = nil, html_options = nil, &block)
112
110
  super
113
111
  table_options = (@options[:table_options] || {}).merge({ store: store })
114
112
  @table = UiBibz::Ui::Ux::Tables::Table.new(table_options, @options[:table_html_options])
@@ -120,7 +118,7 @@ module UiBibz::Ui::Ux::Tables
120
118
 
121
119
  content_tag :div, html_options do
122
120
  form_tag(url_for(url_parameters), method: :get) do
123
- store.parameters.with_indifferent_access.reject{ |k,v| default_parameters?(k) || v.blank? }.each do |k,v|
121
+ store.parameters.with_indifferent_access.reject { |k, v| default_parameters?(k) || v.blank? }.each do |k, v|
124
122
  concat tag(:input, type: 'hidden', name: k, value: v)
125
123
  end
126
124
  concat tag(:input, type: 'hidden', name: 'store_id', value: store.id) unless store.id.nil? # if there is more one table in html page
@@ -130,13 +128,13 @@ module UiBibz::Ui::Ux::Tables
130
128
  end
131
129
 
132
130
  # Add table columns item
133
- def columns &block
134
- @table.columns &block
131
+ def columns(&block)
132
+ @table.columns(&block)
135
133
  end
136
134
 
137
135
  # Add table actions item
138
- def actions &block
139
- @table.actions &block
136
+ def actions(&block)
137
+ @table.actions(&block)
140
138
  end
141
139
 
142
140
  # for test
@@ -144,20 +142,17 @@ module UiBibz::Ui::Ux::Tables
144
142
  @table.actions_list
145
143
  end
146
144
 
147
- private
145
+ private
148
146
 
149
147
  def component_html_classes
150
- %w(card table-card)
148
+ %w[card table-card]
151
149
  end
152
150
 
153
151
  def store
154
- @store ||= if @options[:store].nil?
155
- raise 'Store is nil!'
156
- elsif @options[:store].try(:records).nil?
157
- raise 'Store can be created only with "table_search_pagination" method!'
158
- else
159
- Store.new @options.delete(:store) if @options[:store]
160
- end
152
+ raise 'Store is nil!' if @options[:store].nil?
153
+ raise 'Store can be created only with "table_search_pagination" method!' if @options[:store].try(:records).nil?
154
+
155
+ @store ||= Store.new @options[:store]
161
156
  end
162
157
 
163
158
  def init_components
@@ -166,17 +161,15 @@ module UiBibz::Ui::Ux::Tables
166
161
  @items << pagination.render if pagination.paginable?
167
162
  end
168
163
 
169
- def default_parameters?(k)
170
- %w(store_id per_page page search utf8 search controller action link_type).include?(k)
164
+ def default_parameters?(key)
165
+ %w[store_id per_page page search utf8 search controller action link_type].include?(key)
171
166
  end
172
167
 
173
168
  def url_parameters
174
169
  { controller: store.controller, action: store.action, id: store.param_id }
175
170
  end
176
171
 
177
- def table
178
- @table
179
- end
172
+ attr_reader :table
180
173
 
181
174
  def table_html
182
175
  content_tag :div, @table.render, class: 'card-table'
@@ -189,6 +182,5 @@ module UiBibz::Ui::Ux::Tables
189
182
  def pagination
190
183
  @pagination ||= Paginable.new store, @options.merge({ wrap_form: false }), { class: 'card-footer' }
191
184
  end
192
-
193
185
  end
194
186
  end
@@ -1,8 +1,9 @@
1
- #require 'will_paginate'
2
- require "will_paginate-bootstrap4"
3
- require "ui_bibz/ui/ux/tables/components/store"
4
- module UiBibz::Ui::Ux::Tables
1
+ # frozen_string_literal: true
5
2
 
3
+ # require 'will_paginate'
4
+ require 'will_paginate-bootstrap4'
5
+ require 'ui_bibz/ui/ux/tables/components/store'
6
+ module UiBibz::Ui::Ux::Tables
6
7
  # Create a pagination for table
7
8
  #
8
9
  # ==== Attributes
@@ -27,11 +28,11 @@ module UiBibz::Ui::Ux::Tables
27
28
  class TablePagination < UiBibz::Ui::Base
28
29
  include WillPaginate::ActionView
29
30
  include ActionView
30
- #include WillPaginate::ActionView::BootstrapLinkRenderer
31
+ # include WillPaginate::ActionView::BootstrapLinkRenderer
31
32
 
32
33
  # Initialize pagination with component item
33
34
  # pagination require WillPaginate gem
34
- def initialize options = nil, html_options = nil
35
+ def initialize(options = nil, html_options = nil)
35
36
  @pagination = UiBibz::Ui::Core::Component.new nil, options, html_options
36
37
  end
37
38
 
@@ -41,25 +42,21 @@ module UiBibz::Ui::Ux::Tables
41
42
  paginate_parameters = paginate_parameters.merge({ store_id: store.id }) unless store.id.nil?
42
43
  paginate_parameters = paginate_parameters.merge(store.parameters)
43
44
  paginate_parameters = paginate_parameters.merge({ link_type: 'pagination' })
44
- will_paginate(store.records, params: paginate_parameters.with_indifferent_access.reject{|k,v| default_parameters?(k) || v.blank? }, renderer: WillPaginate::ActionView::BootstrapLinkRenderer)
45
+ will_paginate(store.records, params: paginate_parameters.with_indifferent_access.reject { |k, v| default_parameters?(k) || v.blank? }, renderer: WillPaginate::ActionView::BootstrapLinkRenderer)
45
46
  end
46
47
 
47
- private
48
+ private
48
49
 
49
- def default_parameters?(k)
50
- %w(per_page page link_type).include?(k)
50
+ def default_parameters?(key)
51
+ %w[per_page page link_type].include?(key)
51
52
  end
52
53
 
53
54
  # Store must be generated by *table_search_pagination* method
54
55
  def store
55
- @store ||= if @pagination.options[:store].nil?
56
- raise 'Store is nil!'
57
- elsif @pagination.options[:store].try(:records).nil?
58
- raise 'Store can be created only with "table_search_pagination" method!'
59
- else
60
- Store.new @pagination.options.delete :store
61
- end
62
- end
56
+ raise 'Store is nil!' if @pagination.options[:store].nil?
57
+ raise 'Store can be created only with "table_search_pagination" method!' if @pagination.options[:store].try(:records).nil?
63
58
 
59
+ @store ||= Store.new @pagination.options[:store]
60
+ end
64
61
  end
65
62
  end