blacklight 7.34.0 → 8.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (393) hide show
  1. checksums.yaml +4 -4
  2. data/.env +2 -3
  3. data/.github/workflows/ruby.yml +32 -127
  4. data/.rubocop.yml +241 -2
  5. data/.rubocop_todo.yml +214 -270
  6. data/Gemfile +7 -10
  7. data/README.md +11 -3
  8. data/VERSION +1 -1
  9. data/app/assets/javascripts/blacklight/blacklight.esm.js +384 -0
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
  11. data/app/assets/javascripts/blacklight/blacklight.js +374 -489
  12. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
  13. data/app/assets/stylesheets/blacklight/_autocomplete.scss +25 -0
  14. data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -1
  15. data/app/assets/stylesheets/blacklight/_bookmark.scss +16 -0
  16. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +8 -0
  17. data/app/assets/stylesheets/blacklight/_facets.scss +72 -44
  18. data/app/assets/stylesheets/blacklight/_header.scss +0 -15
  19. data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
  20. data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
  21. data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
  22. data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
  23. data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
  24. data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
  25. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
  26. data/app/builders/blacklight/action_builder.rb +18 -9
  27. data/app/components/blacklight/advanced_search_form_component.html.erb +2 -2
  28. data/app/components/blacklight/advanced_search_form_component.rb +8 -10
  29. data/app/components/blacklight/constraints_component.rb +27 -37
  30. data/app/components/blacklight/document/action_component.rb +9 -9
  31. data/app/components/blacklight/document/actions_component.rb +2 -2
  32. data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
  33. data/app/components/blacklight/document/bookmark_component.rb +4 -2
  34. data/app/components/blacklight/document/citation_component.rb +5 -3
  35. data/app/components/blacklight/document/group_component.rb +7 -3
  36. data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
  37. data/app/components/blacklight/document/sidebar_component.rb +16 -0
  38. data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
  39. data/app/components/blacklight/document/thumbnail_component.rb +1 -9
  40. data/app/components/blacklight/document_component.html.erb +4 -0
  41. data/app/components/blacklight/document_component.rb +14 -53
  42. data/app/components/blacklight/document_metadata_component.html.erb +2 -4
  43. data/app/components/blacklight/document_metadata_component.rb +5 -10
  44. data/app/components/blacklight/document_title_component.rb +4 -1
  45. data/app/components/blacklight/facet_component.rb +1 -1
  46. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +3 -3
  47. data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
  48. data/app/components/blacklight/facet_field_component.html.erb +5 -5
  49. data/app/components/blacklight/facet_field_component.rb +9 -2
  50. data/app/components/blacklight/facet_field_list_component.html.erb +3 -3
  51. data/app/components/blacklight/facet_field_list_component.rb +37 -5
  52. data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
  53. data/app/components/blacklight/facet_item_component.rb +1 -43
  54. data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
  55. data/app/components/blacklight/header_component.rb +1 -1
  56. data/app/components/blacklight/hidden_search_state_component.rb +1 -2
  57. data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
  58. data/app/components/blacklight/icons/list_component.rb +16 -0
  59. data/app/components/blacklight/icons/search_component.rb +16 -0
  60. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  61. data/app/components/blacklight/metadata_field_component.rb +24 -8
  62. data/app/components/blacklight/metadata_field_layout_component.rb +4 -25
  63. data/app/components/blacklight/response/facet_group_component.html.erb +3 -5
  64. data/app/components/blacklight/response/facet_group_component.rb +29 -8
  65. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  66. data/app/components/blacklight/response/pagination_component.rb +1 -5
  67. data/app/components/blacklight/response/sort_component.rb +1 -1
  68. data/app/components/blacklight/response/spellcheck_component.rb +17 -6
  69. data/app/components/blacklight/response/view_type_button_component.rb +2 -6
  70. data/app/components/blacklight/response/view_type_component.rb +3 -5
  71. data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
  72. data/app/components/blacklight/search/sidebar_component.rb +17 -0
  73. data/app/components/blacklight/search_bar_component.html.erb +20 -15
  74. data/app/components/blacklight/search_bar_component.rb +2 -16
  75. data/app/components/blacklight/search_button_component.rb +3 -3
  76. data/app/components/blacklight/search_context_component.rb +43 -9
  77. data/app/components/blacklight/search_header_component.html.erb +2 -0
  78. data/app/components/blacklight/search_header_component.rb +6 -0
  79. data/app/components/blacklight/start_over_button_component.rb +5 -3
  80. data/app/components/blacklight/system/dropdown_component.rb +2 -2
  81. data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
  82. data/app/components/blacklight/system/flash_message_component.rb +11 -2
  83. data/app/components/blacklight/system/modal_component.html.erb +1 -1
  84. data/app/components/blacklight/system/modal_component.rb +0 -2
  85. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  86. data/app/components/blacklight/top_navbar_component.rb +0 -4
  87. data/app/controllers/bookmarks_controller.rb +1 -0
  88. data/app/controllers/catalog_controller.rb +1 -0
  89. data/app/controllers/concerns/blacklight/bookmarks.rb +10 -5
  90. data/app/controllers/concerns/blacklight/catalog.rb +21 -75
  91. data/app/controllers/concerns/blacklight/controller.rb +3 -41
  92. data/app/controllers/concerns/blacklight/search_context.rb +25 -7
  93. data/app/controllers/concerns/blacklight/search_history.rb +2 -0
  94. data/app/controllers/concerns/blacklight/searchable.rb +12 -1
  95. data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
  96. data/app/controllers/search_history_controller.rb +1 -0
  97. data/app/helpers/blacklight/blacklight_helper_behavior.rb +12 -310
  98. data/app/helpers/blacklight/catalog_helper_behavior.rb +22 -137
  99. data/app/helpers/blacklight/component_helper_behavior.rb +2 -53
  100. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
  101. data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
  102. data/app/helpers/blacklight/icon_helper_behavior.rb +5 -4
  103. data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
  104. data/app/helpers/blacklight/render_partials_helper_behavior.rb +11 -31
  105. data/app/helpers/blacklight/url_helper_behavior.rb +13 -97
  106. data/app/helpers/blacklight_helper.rb +1 -0
  107. data/app/helpers/catalog_helper.rb +1 -0
  108. data/app/javascript/blacklight/bookmark_toggle.js +13 -19
  109. data/app/javascript/blacklight/button_focus.js +12 -10
  110. data/app/javascript/blacklight/checkbox_submit.js +68 -122
  111. data/app/javascript/blacklight/core.js +6 -5
  112. data/app/javascript/blacklight/index.js +13 -0
  113. data/app/javascript/blacklight/modal.js +99 -164
  114. data/app/javascript/blacklight/modalForm.js +60 -0
  115. data/app/javascript/blacklight/search_context.js +45 -55
  116. data/app/models/blacklight/facet_paginator.rb +3 -2
  117. data/app/models/blacklight/icon.rb +4 -2
  118. data/app/models/bookmark.rb +0 -2
  119. data/app/models/concerns/blacklight/configurable.rb +5 -4
  120. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
  121. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  122. data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
  123. data/app/models/concerns/blacklight/document/email.rb +1 -0
  124. data/app/models/concerns/blacklight/document/export.rb +2 -1
  125. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  126. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  127. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  128. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  129. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  130. data/app/models/concerns/blacklight/user.rb +17 -8
  131. data/app/models/record_mailer.rb +13 -12
  132. data/app/models/search.rb +0 -1
  133. data/app/models/solr_document.rb +1 -0
  134. data/app/presenters/blacklight/clause_presenter.rb +1 -1
  135. data/app/presenters/blacklight/document_presenter.rb +13 -21
  136. data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
  137. data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
  138. data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
  139. data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
  140. data/app/presenters/blacklight/field_presenter.rb +1 -0
  141. data/app/presenters/blacklight/index_presenter.rb +2 -40
  142. data/app/presenters/blacklight/json_presenter.rb +7 -5
  143. data/app/presenters/blacklight/rendering/link_to_facet.rb +2 -5
  144. data/app/presenters/blacklight/show_presenter.rb +1 -9
  145. data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
  146. data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
  147. data/app/services/blacklight/field_retriever.rb +1 -8
  148. data/app/services/blacklight/search_service.rb +8 -7
  149. data/app/values/blacklight/types.rb +0 -4
  150. data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
  151. data/app/views/bookmarks/_tools.html.erb +7 -12
  152. data/app/views/catalog/_advanced_search_form.html.erb +0 -1
  153. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  154. data/app/views/catalog/_constraints.html.erb +1 -14
  155. data/app/views/catalog/_document.atom.builder +12 -14
  156. data/app/views/catalog/_document.html.erb +5 -3
  157. data/app/views/catalog/_document.rss.builder +2 -4
  158. data/app/views/catalog/_facet_layout.html.erb +2 -2
  159. data/app/views/catalog/_facets.html.erb +5 -4
  160. data/app/views/catalog/_home_text.html.erb +2 -14
  161. data/app/views/catalog/_search_form.html.erb +2 -2
  162. data/app/views/catalog/_search_header.html.erb +1 -2
  163. data/app/views/catalog/_search_results.html.erb +2 -2
  164. data/app/views/catalog/_search_sidebar.html.erb +5 -1
  165. data/app/views/catalog/_show_main_content.html.erb +11 -16
  166. data/app/views/catalog/_show_sidebar.html.erb +2 -2
  167. data/app/views/catalog/_show_tools.html.erb +8 -14
  168. data/app/views/catalog/_view_type_group.html.erb +1 -1
  169. data/app/views/catalog/email_success.html.erb +5 -6
  170. data/app/views/catalog/facet.html.erb +7 -5
  171. data/app/views/catalog/index.atom.builder +12 -14
  172. data/app/views/catalog/index.html.erb +4 -1
  173. data/app/views/catalog/index.json.jbuilder +19 -19
  174. data/app/views/catalog/index.rss.builder +1 -1
  175. data/app/views/catalog/opensearch.xml.builder +1 -1
  176. data/app/views/catalog/sms_success.html.erb +5 -6
  177. data/app/views/catalog/suggest.html.erb +3 -0
  178. data/app/views/layouts/blacklight/base.html.erb +13 -2
  179. data/app/views/search_history/index.html.erb +6 -2
  180. data/app/views/shared/_modal.html.erb +3 -3
  181. data/blacklight.gemspec +8 -9
  182. data/config/importmap.rb +3 -0
  183. data/config/locales/blacklight.ar.yml +0 -1
  184. data/config/locales/blacklight.ca.yml +0 -1
  185. data/config/locales/blacklight.de.yml +0 -1
  186. data/config/locales/blacklight.en.yml +0 -2
  187. data/config/locales/blacklight.es.yml +0 -1
  188. data/config/locales/blacklight.fr.yml +0 -1
  189. data/config/locales/blacklight.hu.yml +0 -1
  190. data/config/locales/blacklight.it.yml +0 -1
  191. data/config/locales/blacklight.nl.yml +0 -1
  192. data/config/locales/blacklight.pt-BR.yml +0 -1
  193. data/config/locales/blacklight.sq.yml +0 -1
  194. data/config/locales/blacklight.zh.yml +0 -1
  195. data/config/routes.rb +3 -2
  196. data/db/migrate/20140202020201_create_searches.rb +1 -0
  197. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  198. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  199. data/docker-compose.yml +0 -1
  200. data/lib/blacklight/abstract_repository.rb +1 -0
  201. data/lib/blacklight/configuration/context.rb +4 -4
  202. data/lib/blacklight/configuration/display_field.rb +7 -9
  203. data/lib/blacklight/configuration/facet_field.rb +17 -11
  204. data/lib/blacklight/configuration/field.rb +1 -0
  205. data/lib/blacklight/configuration/fields.rb +12 -15
  206. data/lib/blacklight/configuration/index_field.rb +1 -0
  207. data/lib/blacklight/configuration/null_display_field.rb +17 -0
  208. data/lib/blacklight/configuration/search_field.rb +1 -0
  209. data/lib/blacklight/configuration/show_field.rb +1 -0
  210. data/lib/blacklight/configuration/sort_field.rb +1 -0
  211. data/lib/blacklight/configuration/tool_config.rb +1 -0
  212. data/lib/blacklight/configuration/view_config.rb +16 -6
  213. data/lib/blacklight/configuration.rb +294 -358
  214. data/lib/blacklight/engine.rb +8 -13
  215. data/lib/blacklight/exceptions.rb +2 -2
  216. data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
  217. data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
  218. data/lib/blacklight/parameters.rb +7 -21
  219. data/lib/blacklight/routes/exportable.rb +1 -0
  220. data/lib/blacklight/routes/searchable.rb +2 -1
  221. data/lib/blacklight/routes.rb +1 -0
  222. data/lib/blacklight/search_builder.rb +10 -10
  223. data/lib/blacklight/search_state/filter_field.rb +8 -25
  224. data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
  225. data/lib/blacklight/search_state.rb +23 -79
  226. data/lib/blacklight/solr/document.rb +1 -0
  227. data/lib/blacklight/solr/facet_paginator.rb +1 -0
  228. data/lib/blacklight/solr/repository.rb +3 -14
  229. data/lib/blacklight/solr/request.rb +1 -0
  230. data/lib/blacklight/solr/response/facets.rb +21 -5
  231. data/lib/blacklight/solr/response/group.rb +1 -0
  232. data/lib/blacklight/solr/response/group_response.rb +1 -0
  233. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  234. data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
  235. data/lib/blacklight/solr/response/params.rb +5 -4
  236. data/lib/blacklight/solr/response/response.rb +1 -0
  237. data/lib/blacklight/solr/response/spelling.rb +1 -0
  238. data/lib/blacklight/solr/response.rb +4 -3
  239. data/lib/blacklight/solr/search_builder_behavior.rb +17 -34
  240. data/lib/blacklight/solr.rb +1 -0
  241. data/lib/blacklight/version.rb +1 -0
  242. data/lib/blacklight.rb +7 -10
  243. data/lib/generators/blacklight/assets/importmap_generator.rb +55 -0
  244. data/lib/generators/blacklight/assets/propshaft_generator.rb +25 -0
  245. data/lib/generators/blacklight/assets/sprockets_generator.rb +66 -0
  246. data/lib/generators/blacklight/assets_generator.rb +13 -89
  247. data/lib/generators/blacklight/controller_generator.rb +3 -2
  248. data/lib/generators/blacklight/document_generator.rb +1 -0
  249. data/lib/generators/blacklight/install_generator.rb +4 -3
  250. data/lib/generators/blacklight/models_generator.rb +1 -0
  251. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  252. data/lib/generators/blacklight/solr_generator.rb +1 -1
  253. data/lib/generators/blacklight/templates/catalog_controller.rb +34 -8
  254. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +0 -69
  255. data/lib/generators/blacklight/test_support_generator.rb +4 -2
  256. data/lib/generators/blacklight/user_generator.rb +7 -9
  257. data/lib/railties/blacklight.rake +6 -7
  258. data/package.json +10 -13
  259. data/rollup.config.js +27 -0
  260. data/spec/components/blacklight/constraints_component_spec.rb +17 -13
  261. data/spec/components/blacklight/document_component_spec.rb +23 -82
  262. data/spec/components/blacklight/facet_component_spec.rb +2 -7
  263. data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
  264. data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
  265. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +10 -9
  266. data/spec/components/blacklight/response/view_type_component_spec.rb +66 -0
  267. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  268. data/spec/components/blacklight/search_context_component_spec.rb +40 -0
  269. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
  270. data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
  271. data/spec/controllers/bookmarks_controller_spec.rb +2 -3
  272. data/spec/controllers/catalog_controller_spec.rb +13 -135
  273. data/spec/features/advanced_search_spec.rb +0 -56
  274. data/spec/features/autocomplete_spec.rb +1 -1
  275. data/spec/features/axe_spec.rb +1 -6
  276. data/spec/features/bookmarks_spec.rb +1 -1
  277. data/spec/features/facets_spec.rb +1 -1
  278. data/spec/features/search_context_spec.rb +4 -10
  279. data/spec/features/search_results_spec.rb +0 -33
  280. data/spec/features/sitelinks_search_box.rb +13 -0
  281. data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
  282. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
  283. data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
  284. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
  285. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +9 -131
  286. data/spec/helpers/blacklight_helper_spec.rb +3 -242
  287. data/spec/helpers/catalog_helper_spec.rb +7 -118
  288. data/spec/i18n_spec.rb +1 -0
  289. data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
  290. data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
  291. data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
  292. data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
  293. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +2 -2
  294. data/spec/lib/blacklight/parameters_spec.rb +1 -4
  295. data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
  296. data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
  297. data/spec/lib/blacklight/search_state_spec.rb +80 -198
  298. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  299. data/spec/models/blacklight/configuration_spec.rb +17 -51
  300. data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
  301. data/spec/models/blacklight/icon_spec.rb +31 -15
  302. data/spec/models/blacklight/search_builder_spec.rb +9 -9
  303. data/spec/models/blacklight/solr/document_spec.rb +3 -3
  304. data/spec/models/blacklight/solr/repository_spec.rb +0 -27
  305. data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
  306. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  307. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  308. data/spec/models/blacklight/solr/response_spec.rb +9 -2
  309. data/spec/models/blacklight/solr/search_builder_spec.rb +24 -31
  310. data/spec/models/blacklight/user_spec.rb +22 -0
  311. data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
  312. data/spec/presenters/blacklight/document_presenter_spec.rb +2 -2
  313. data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
  314. data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
  315. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
  316. data/spec/presenters/blacklight/field_presenter_spec.rb +0 -14
  317. data/spec/presenters/blacklight/index_presenter_spec.rb +2 -4
  318. data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
  319. data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
  320. data/spec/presenters/blacklight/show_presenter_spec.rb +20 -29
  321. data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
  322. data/spec/requests/load_suggestions_spec.rb +16 -0
  323. data/spec/routing/catalog_routing_spec.rb +2 -1
  324. data/spec/services/blacklight/search_service_spec.rb +31 -68
  325. data/spec/spec_helper.rb +6 -4
  326. data/spec/support/controller_level_helpers.rb +1 -2
  327. data/spec/support/features/search_helpers.rb +39 -0
  328. data/spec/support/features/session_helpers.rb +1 -0
  329. data/spec/support/features.rb +3 -0
  330. data/spec/support/view_component_capybara_test_helpers.rb +8 -0
  331. data/spec/test_app_templates/lib/generators/test_app_generator.rb +9 -2
  332. data/spec/views/catalog/_document.html.erb_spec.rb +3 -34
  333. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
  334. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  335. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  336. data/spec/views/catalog/_show_tools.html.erb_spec.rb +5 -66
  337. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
  338. data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
  339. data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
  340. data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
  341. data/spec/views/catalog/index.html.erb_spec.rb +5 -6
  342. data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
  343. data/spec/views/catalog/show.html.erb_spec.rb +3 -25
  344. data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
  345. data/tasks/blacklight.rake +6 -4
  346. metadata +79 -126
  347. data/.babelrc +0 -11
  348. data/app/assets/images/blacklight/list.svg +0 -1
  349. data/app/assets/images/blacklight/search.svg +0 -1
  350. data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
  351. data/app/components/blacklight/content_areas_shim.rb +0 -13
  352. data/app/controllers/concerns/blacklight/base.rb +0 -12
  353. data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
  354. data/app/controllers/concerns/blacklight/facet.rb +0 -69
  355. data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
  356. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
  357. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
  358. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
  359. data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
  360. data/app/javascript/blacklight/autocomplete.js +0 -36
  361. data/app/javascript/blacklight/facet_load.js +0 -22
  362. data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
  363. data/app/views/catalog/_constraints_element.html.erb +0 -14
  364. data/app/views/catalog/_document_action.html.erb +0 -5
  365. data/app/views/catalog/_facet_group.html.erb +0 -5
  366. data/app/views/catalog/_facet_limit.html.erb +0 -3
  367. data/app/views/catalog/_index.html.erb +0 -1
  368. data/app/views/catalog/_index_header.html.erb +0 -22
  369. data/app/views/catalog/_previous_next_doc.html.erb +0 -2
  370. data/app/views/catalog/_show.html.erb +0 -6
  371. data/app/views/catalog/_show_header.html.erb +0 -2
  372. data/app/views/catalog/_thumbnail.html.erb +0 -1
  373. data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
  374. data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
  375. data/spec/components/blacklight/header_component_spec.rb +0 -20
  376. data/spec/controllers/blacklight/facet_spec.rb +0 -33
  377. data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
  378. data/spec/features/sitelinks_search_box_spec.rb +0 -13
  379. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
  380. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
  381. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -101
  382. data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
  383. data/spec/lib/blacklight/engine_spec.rb +0 -41
  384. data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
  385. data/spec/support/view_component_test_helpers.rb +0 -35
  386. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  387. data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
  388. data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
  389. data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
  390. data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
  391. data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
  392. data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
  393. data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
@@ -2,8 +2,6 @@
2
2
 
3
3
  module Blacklight
4
4
  class ConstraintsComponent < Blacklight::Component
5
- include Blacklight::ContentAreasShim
6
-
7
5
  renders_many :query_constraints_area
8
6
  renders_many :facet_constraints_area
9
7
  renders_many :additional_constraints
@@ -42,60 +40,52 @@ module Blacklight
42
40
  # rubocop:enable Metrics/ParameterLists
43
41
 
44
42
  def query_constraints
45
- Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
46
- if @search_state.query_param.present?
47
- helpers.render(
48
- @query_constraint_component.new(
49
- search_state: @search_state,
50
- value: @search_state.query_param,
51
- label: label,
52
- remove_path: helpers.remove_constraint_url(@search_state),
53
- classes: 'query',
54
- **@query_constraint_component_options
55
- )
43
+ if @search_state.query_param.present?
44
+ helpers.render(
45
+ @query_constraint_component.new(
46
+ search_state: @search_state,
47
+ value: @search_state.query_param,
48
+ label: label,
49
+ remove_path: remove_path,
50
+ classes: 'query',
51
+ **@query_constraint_component_options
56
52
  )
57
- else
58
- ''.html_safe
59
- end
53
+ )
54
+ else
55
+ ''.html_safe
60
56
  end + helpers.render(@facet_constraint_component.with_collection(clause_presenters.to_a, **@facet_constraint_component_options))
61
57
  end
62
58
 
59
+ def remove_path
60
+ helpers.search_action_path(@search_state.remove_query_params)
61
+ end
62
+
63
63
  def facet_constraints
64
64
  helpers.render(@facet_constraint_component.with_collection(facet_item_presenters.to_a, **@facet_constraint_component_options))
65
65
  end
66
66
 
67
67
  def render?
68
- Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) { helpers.query_has_constraints?(@search_state.params) }
68
+ @search_state.has_constraints?
69
69
  end
70
70
 
71
71
  private
72
72
 
73
- # @deprecated
74
- def start_over_path
75
- Deprecation.silence(Blacklight::UrlHelperBehavior) do
76
- helpers.start_over_path
77
- end
78
- end
79
-
80
73
  def label
81
- Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
82
- helpers.constraint_query_label(@search_state.params)
83
- end
74
+ search_field = @search_state.params[:search_field]
75
+ helpers.label_for_search_field(search_field) unless helpers.default_search_field?(search_field)
84
76
  end
85
77
 
86
78
  def facet_item_presenters
87
79
  return to_enum(:facet_item_presenters) unless block_given?
88
80
 
89
- Deprecation.silence(Blacklight::SearchState) do
90
- @search_state.filters.map do |facet|
91
- facet.values.map do |val|
92
- next if val.blank?
81
+ @search_state.filters.map do |facet|
82
+ facet.each_value do |val|
83
+ next if val.blank?
93
84
 
94
- if val.is_a?(Array)
95
- yield inclusive_facet_item_presenter(facet.config, val, facet.key) if val.any?(&:present?)
96
- else
97
- yield facet_item_presenter(facet.config, val, facet.key)
98
- end
85
+ if val.is_a?(Array)
86
+ yield inclusive_facet_item_presenter(facet.config, val, facet.key) if val.any?(&:present?)
87
+ else
88
+ yield facet_item_presenter(facet.config, val, facet.key)
99
89
  end
100
90
  end
101
91
  end
@@ -111,7 +101,7 @@ module Blacklight
111
101
  end
112
102
 
113
103
  def facet_item_presenter(facet_config, facet_item, facet_field)
114
- (facet_config.item_presenter || Blacklight::FacetItemPresenter).new(facet_item, facet_config, helpers, facet_field)
104
+ facet_config.item_presenter.new(facet_item, facet_config, helpers, facet_field)
115
105
  end
116
106
 
117
107
  def inclusive_facet_item_presenter(facet_config, facet_item, facet_field)
@@ -23,10 +23,7 @@ module Blacklight
23
23
  end
24
24
 
25
25
  def using_default_document_action?
26
- return true if @action.component
27
- return false unless @action.partial == 'document_action'
28
-
29
- helpers.partial_from_blacklight?(@action.partial)
26
+ @action.component || @action.partial == 'document_action'
30
27
  end
31
28
 
32
29
  def link_to_modal_control
@@ -42,9 +39,7 @@ module Blacklight
42
39
  end
43
40
 
44
41
  def label
45
- Deprecation.silence(Blacklight::ComponentHelperBehavior) do
46
- helpers.document_action_label(@action.name, @action)
47
- end
42
+ t("blacklight.tools.#{@action.name}", default: @action.label || @action.name.to_s.humanize)
48
43
  end
49
44
 
50
45
  # Action buttons get their URLs in one of three ways:
@@ -55,8 +50,13 @@ module Blacklight
55
50
  # default Rails routing behavior)
56
51
  # - calling out to an implicit helper method with a conventional name (unlikely)
57
52
  def url
58
- Deprecation.silence(Blacklight::ComponentHelperBehavior) do
59
- helpers.document_action_path(@action, @url_opts.merge(({ id: @document } if @document) || {}))
53
+ url_opts = @url_opts.merge(({ id: @document } if @document) || {})
54
+ if @action.path
55
+ helpers.public_send(@action.path, url_opts)
56
+ elsif url_opts[:id].class.respond_to?(:model_name)
57
+ helpers.url_for([@action.key.to_sym, url_opts[:id]])
58
+ else
59
+ helpers.public_send("#{@action.key}_#{helpers.controller_name}_path", url_opts)
60
60
  end
61
61
  end
62
62
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Blacklight
4
4
  module Document
5
- # Render a bookmark widget to bookmark / unbookmark a document
5
+ # Render a the set of actions for a document. One of the default actions is the bookmark control.
6
6
  class ActionsComponent < Blacklight::Component
7
7
  renders_many :actions, (lambda do |action:, component: nil, **kwargs|
8
8
  component ||= action.component || Blacklight::Document::ActionComponent
@@ -28,7 +28,7 @@ module Blacklight
28
28
  return if actions.present?
29
29
 
30
30
  @actions.each do |a|
31
- with_action(component: a.component, action: a)
31
+ action(component: a.component, action: a)
32
32
  end
33
33
  end
34
34
 
@@ -1,7 +1,9 @@
1
1
  <%-
2
2
  # the data-doc-id attribute is used by our JS that converts to a checkbox/label.
3
+ # we don't use the per-form csrf token
3
4
  -%>
4
5
  <%= form_tag(bookmark_path,
6
+ authenticity_token: false,
5
7
  method: bookmarked? ? :delete : :put,
6
8
  class: "bookmark-toggle",
7
9
  data: {
@@ -10,6 +12,13 @@
10
12
  absent: t('blacklight.search.bookmarks.absent'),
11
13
  inprogress: t('blacklight.search.bookmarks.inprogress')
12
14
  }) do %>
15
+ <div class="checkbox toggle-bookmark">
16
+ <label class="toggle-bookmark" data-checkboxsubmit-target="label">
17
+ <input type="checkbox" class="toggle-bookmark" data-checkboxsubmit-target="checkbox" <%= 'checked="checked"' if bookmarked? %>>
18
+ <span data-checkboxsubmit-target="span"><%= bookmarked? ? t('blacklight.search.bookmarks.present') : t('blacklight.search.bookmarks.absent') %></span>
19
+ </label>
20
+ </div>
21
+
13
22
  <%= submit_tag(t(bookmarked? ? 'remove.button' : 'add.button', scope: 'blacklight.bookmarks'),
14
23
  id: "bookmark_toggle_#{@document.id.to_s.parameterize}",
15
24
  class: "bookmark-#{bookmarked? ? 'remove' : 'add'} btn btn-outline-secondary") %>
@@ -3,14 +3,16 @@
3
3
  module Blacklight
4
4
  module Document
5
5
  # Render a bookmark widget to bookmark / unbookmark a document
6
- class BookmarkComponent < Blacklight::Component
6
+ class BookmarkComponent < Blacklight::Document::ActionComponent
7
7
  # @param [Blacklight::Document] document
8
+ # @param [Blacklight::Configuration::ToolConfig] action
8
9
  # @param [Boolean] checked
9
10
  # @param [Object] bookmark_path the rails route to use for bookmarks
10
- def initialize(document:, checked: nil, bookmark_path: nil)
11
+ def initialize(document:, action: nil, checked: nil, bookmark_path: nil, **kwargs)
11
12
  @document = document
12
13
  @checked = checked
13
14
  @bookmark_path = bookmark_path
15
+ super(document: document, action: action, **kwargs)
14
16
  end
15
17
 
16
18
  def bookmarked?
@@ -22,9 +22,11 @@ module Blacklight
22
22
 
23
23
  # @return [String]
24
24
  def title
25
- Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
26
- helpers.document_heading(@document)
27
- end
25
+ presenter.heading
26
+ end
27
+
28
+ def presenter
29
+ helpers.document_presenter(@document)
28
30
  end
29
31
  end
30
32
  end
@@ -17,10 +17,14 @@ module Blacklight
17
17
  helpers.render_document_index @group.docs
18
18
  end
19
19
 
20
+ # Get path to a search within a grouped result set
21
+ #
22
+ # @param [Blacklight::Solr::Response::Group] group
23
+ # @return [Hash]
20
24
  def add_group_facet_params_and_redirect(group)
21
- Deprecation.silence(Blacklight::UrlHelperBehavior) do
22
- helpers.search_action_path(helpers.add_group_facet_params_and_redirect(group))
23
- end
25
+ helpers.search_action_path(
26
+ helpers.search_state.add_facet_params_and_redirect(group.field, group.key)
27
+ )
24
28
  end
25
29
  end
26
30
  end
@@ -0,0 +1,2 @@
1
+ <%= render 'show_tools', document: document %>
2
+ <%= render(Blacklight::Document::MoreLikeThisComponent.new(document: document)) %>
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ module Document
5
+ # Render the sidebar on the show view
6
+ class SidebarComponent < Blacklight::Component
7
+ # @param [Blacklight::DocumentPresenter] presenter
8
+ def initialize(presenter:)
9
+ @presenter = presenter
10
+ @document = presenter.document
11
+ end
12
+
13
+ attr_reader :document
14
+ end
15
+ end
16
+ end
@@ -1,12 +1,7 @@
1
- <% value = use_thumbnail_tag_behavior? ? presenter.thumbnail.thumbnail_tag(@image_options, 'aria-hidden': true, tabindex: -1, counter: @counter) : presenter.thumbnail.render(@image_options) %>
1
+ <% value = presenter.thumbnail.render(@image_options) %>
2
2
 
3
3
  <% if value %>
4
4
  <div class="document-thumbnail">
5
- <% if use_thumbnail_tag_behavior? %>
6
- <% warn_about_deprecated_behavior %>
7
- <%= value %>
8
- <% else %>
9
- <%= helpers.link_to_document(presenter.document, value, 'aria-hidden': true, tabindex: -1, counter: @counter) %>
10
- <% end %>
5
+ <%= helpers.link_to_document(presenter.document, value, 'aria-hidden': true, tabindex: -1, counter: @counter) %>
11
6
  </div>
12
7
  <% end %>
@@ -9,7 +9,7 @@ module Blacklight
9
9
  # @param [Blacklight::DocumentPresenter] presenter
10
10
  # @param [Integer] counter
11
11
  # @param [Hash] image_options options for the thumbnail presenter's image tag
12
- def initialize(presenter: nil, document: nil, counter:, image_options: {})
12
+ def initialize(counter:, presenter: nil, document: nil, image_options: {})
13
13
  @presenter = presenter
14
14
  @document = presenter&.document || document
15
15
  @counter = counter
@@ -20,14 +20,6 @@ module Blacklight
20
20
  presenter.thumbnail.exists?
21
21
  end
22
22
 
23
- def use_thumbnail_tag_behavior?
24
- !presenter.thumbnail.instance_of?(Blacklight::ThumbnailPresenter)
25
- end
26
-
27
- def warn_about_deprecated_behavior
28
- Deprecation.warn(Blacklight::Document::ThumbnailComponent, 'Detected as custom thumbnail presenter; make sure it has a #render method that returns just the thumbnail image tag')
29
- end
30
-
31
23
  def presenter
32
24
  @presenter ||= helpers.document_presenter(@document)
33
25
  end
@@ -19,6 +19,10 @@
19
19
  <% metadata_sections.each do |section| %>
20
20
  <%= section %>
21
21
  <% end %>
22
+
23
+ <% partials.each do |partial| %>
24
+ <%= partial %>
25
+ <% end %>
22
26
  </div>
23
27
 
24
28
  <%= thumbnail %>
@@ -1,32 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'view_component/version'
4
-
5
3
  module Blacklight
6
- ##
7
- # A component for rendering a single document
8
- #
9
- # @note when subclassing this component, if you override the initializer,
10
- # you must explicitly specify the counter variable `document_counter` even if you don't use it.
11
- # Otherwise view_component will not provide the count value when calling the component.
12
- #
13
- # @see https://viewcomponent.org/guide/collections.html#collection-counter
14
- #
15
- # @example
16
- # class MyDocumentComponent < Blacklight::DocumentComponent
17
- # def initialize(document_counter: nil, **kwargs)
18
- # super
19
- # ... custom code ...
20
- # end
21
- # end
22
4
  class DocumentComponent < Blacklight::Component
23
- include Blacklight::ContentAreasShim
24
-
25
- with_collection_parameter :document
26
-
27
- # ViewComponent 3 changes iteration counters to begin at 0 rather than 1
28
- COLLECTION_INDEX_OFFSET = ViewComponent::VERSION::MAJOR < 3 ? 0 : 1
29
-
30
5
  # Content appearing before the document
31
6
  renders_one :header
32
7
 
@@ -39,16 +14,17 @@ module Blacklight
39
14
 
40
15
  # The document title with some reasonable default behavior
41
16
  renders_one :title, (lambda do |*args, component: nil, **kwargs|
42
- component ||= @presenter&.view_config&.title_component || Blacklight::DocumentTitleComponent
17
+ component ||= Blacklight::DocumentTitleComponent
43
18
 
44
- component.new(*args, counter: @counter, document: @document, presenter: @presenter, as: @title_component, link_to_document: !@show, document_component: self, **kwargs)
19
+ component.new(*args, counter: @counter, document: @document, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs)
45
20
  end)
46
21
 
47
22
  renders_one :embed, (lambda do |static_content = nil, *args, component: nil, **kwargs|
48
23
  next static_content if static_content.present?
49
- next unless component
50
24
 
51
- Deprecation.warn(Blacklight::DocumentComponent, 'Pass the presenter to the DocumentComponent') if @presenter.nil?
25
+ component ||= @presenter.view_config&.embed_component
26
+
27
+ next unless component
52
28
 
53
29
  component.new(*args, document: @document, presenter: @presenter, document_counter: @document_counter, **kwargs)
54
30
  end)
@@ -57,9 +33,7 @@ module Blacklight
57
33
  renders_one :metadata, (lambda do |static_content = nil, *args, component: nil, fields: nil, **kwargs|
58
34
  next static_content if static_content.present?
59
35
 
60
- Deprecation.warn(Blacklight::DocumentComponent, 'Pass the presenter to the DocumentComponent') if !fields && @presenter.nil?
61
-
62
- component ||= presenter&.view_config&.metadata_component || Blacklight::DocumentMetadataComponent
36
+ component ||= Blacklight::DocumentMetadataComponent
63
37
 
64
38
  component.new(*args, fields: fields || @presenter&.field_presenters || [], **kwargs)
65
39
  end)
@@ -70,8 +44,7 @@ module Blacklight
70
44
  renders_one :thumbnail, (lambda do |image_options_or_static_content = {}, *args, component: nil, **kwargs|
71
45
  next image_options_or_static_content if image_options_or_static_content.is_a? String
72
46
 
73
- component ||= presenter&.view_config&.thumbnail_component || Blacklight::Document::ThumbnailComponent
74
- Deprecation.warn(Blacklight::DocumentComponent, 'Pass the presenter to the DocumentComponent') if !component && @presenter.nil?
47
+ component ||= @presenter&.view_config&.thumbnail_component || Blacklight::Document::ThumbnailComponent
75
48
 
76
49
  component.new(*args, document: @document, presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
77
50
  end)
@@ -98,16 +71,13 @@ module Blacklight
98
71
  # @param show [Boolean] are we showing only a single document (vs a list of search results); used for backwards-compatibility
99
72
  def initialize(document: nil, presenter: nil,
100
73
  id: nil, classes: [], component: :article, title_component: nil,
101
- metadata_component: nil,
102
- embed_component: nil,
103
- thumbnail_component: nil,
104
74
  counter: nil, document_counter: nil, counter_offset: 0,
105
- show: false, **args)
75
+ show: false)
106
76
  if presenter.nil? && document.nil?
107
77
  raise ArgumentError, 'missing keyword: :document or :presenter'
108
78
  end
109
79
 
110
- @document = document || presenter&.document || args[self.class.collection_parameter]
80
+ @document = document || presenter&.document
111
81
  @presenter = presenter
112
82
 
113
83
  @component = component
@@ -115,18 +85,9 @@ module Blacklight
115
85
  @id = id || ('document' if show)
116
86
  @classes = classes
117
87
 
118
- Deprecation.warn(Blacklight::DocumentComponent, 'Passing embed_component is deprecated') if @embed_component.present?
119
- @embed_component = embed_component
120
-
121
- Deprecation.warn(Blacklight::DocumentComponent, 'Passing metadata_component is deprecated') if @metadata_component.present?
122
- @metadata_component = metadata_component
123
-
124
- Deprecation.warn(Blacklight::DocumentComponent, 'Passing thumbnail_component is deprecated') if @thumbnail_component.present?
125
- @thumbnail_component = thumbnail_component
126
-
88
+ @document_counter = document_counter
127
89
  @counter = counter
128
- @document_counter = document_counter || args.fetch(self.class.collection_counter_parameter, nil)
129
- @counter ||= @document_counter + COLLECTION_INDEX_OFFSET + counter_offset if @document_counter.present?
90
+ @counter ||= document_counter + 1 + counter_offset if document_counter.present?
130
91
 
131
92
  @show = show
132
93
  end
@@ -144,9 +105,9 @@ module Blacklight
144
105
 
145
106
  def before_render
146
107
  set_slot(:title, nil) unless title
147
- set_slot(:thumbnail, nil, component: @thumbnail_component || presenter.view_config&.thumbnail_component) unless thumbnail || show?
148
- set_slot(:metadata, nil, component: @metadata_component || presenter&.view_config&.metadata_component, fields: presenter.field_presenters) unless metadata
149
- set_slot(:embed, nil, component: @embed_component || presenter.view_config&.embed_component) unless embed
108
+ set_slot(:thumbnail, nil) unless thumbnail || show?
109
+ set_slot(:metadata, nil, fields: presenter.field_presenters) unless metadata
110
+ set_slot(:embed, nil) unless embed
150
111
  end
151
112
 
152
113
  private
@@ -1,7 +1,5 @@
1
- <% content = capture do %>
1
+ <dl class="document-metadata dl-invert row">
2
2
  <% fields.each do |field| -%>
3
3
  <%= field %>
4
4
  <% end -%>
5
- <% end %>
6
-
7
- <%= @tag.nil? ? content : tag.public_send(@tag, content, class: @classes, **@component_args) %>
5
+ </dl>
@@ -3,25 +3,22 @@
3
3
  module Blacklight
4
4
  class DocumentMetadataComponent < Blacklight::Component
5
5
  renders_many :fields, (lambda do |component: nil, **kwargs|
6
- (component || Blacklight::MetadataFieldComponent).new(**kwargs)
6
+ component.new(**kwargs)
7
7
  end)
8
8
  with_collection_parameter :fields
9
9
 
10
10
  # @param fields [Enumerable<Blacklight::FieldPresenter>] Document field presenters
11
- def initialize(fields: [], tag: 'dl', classes: %w[document-metadata dl-invert row], show: false, field_layout: nil, **component_args)
11
+ def initialize(fields: [], show: false, view_type: nil)
12
12
  @fields = fields
13
- @tag = tag
14
- @classes = classes
15
13
  @show = show
16
- @field_layout = field_layout
17
- @component_args = component_args
14
+ @view_type = view_type
18
15
  end
19
16
 
20
17
  def before_render
21
18
  return unless fields
22
19
 
23
20
  @fields.each do |field|
24
- with_field(component: field_component(field), field: field, show: @show, layout: @field_layout)
21
+ field(component: field.component, field: field, show: @show, view_type: @view_type)
25
22
  end
26
23
  end
27
24
 
@@ -29,8 +26,6 @@ module Blacklight
29
26
  fields.present?
30
27
  end
31
28
 
32
- def field_component(field)
33
- field&.component || Blacklight::MetadataFieldComponent
34
- end
29
+ attr_reader :view_type
35
30
  end
36
31
  end
@@ -7,7 +7,7 @@ module Blacklight
7
7
  renders_many :actions
8
8
 
9
9
  # rubocop:disable Metrics/ParameterLists
10
- def initialize(title = nil, document: nil, presenter: nil, as: :h3, counter: nil, classes: 'index_title document-title-heading col', link_to_document: true, document_component: nil)
10
+ def initialize(title = nil, document: nil, presenter: nil, as: :h3, counter: nil, classes: 'index_title document-title-heading col', link_to_document: true, document_component: nil, actions: true)
11
11
  raise ArgumentError, 'missing keyword: :document or :presenter' if presenter.nil? && document.nil?
12
12
 
13
13
  @title = title
@@ -18,6 +18,7 @@ module Blacklight
18
18
  @classes = classes
19
19
  @link_to_document = link_to_document
20
20
  @document_component = document_component
21
+ @actions = actions
21
22
  end
22
23
  # rubocop:enable Metrics/ParameterLists
23
24
 
@@ -32,6 +33,8 @@ module Blacklight
32
33
 
33
34
  # Content for the document actions area
34
35
  def actions
36
+ return [] unless @actions
37
+
35
38
  if block_given?
36
39
  @has_actions_slot = true
37
40
  return super
@@ -30,7 +30,7 @@ module Blacklight
30
30
  raise ArgumentError, 'You must provide one of display_facet or field_config' unless @field_config
31
31
  end
32
32
 
33
- @component = component || (@field_config.component == true ? Blacklight::FacetFieldListComponent : @field_config.component)
33
+ @component = component || @field_config.component
34
34
  @component_args = component_args
35
35
  end
36
36
  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/ParameterLists
@@ -1,9 +1,9 @@
1
1
  <%= render(@layout.new(facet_field: @facet_field)) do |component| %>
2
- <% component.with_label do %>
2
+ <% component.label do %>
3
3
  <%= @facet_field.label %>
4
4
  <% end %>
5
5
 
6
- <% component.with_body do %>
6
+ <% component.body do %>
7
7
  <ul class="facet-values list-unstyled blacklight-facet-checkboxes">
8
8
  <% presenters.each_with_index do |presenter, idx| -%>
9
9
  <li>
@@ -11,7 +11,7 @@
11
11
  <%= check_box_tag "f_inclusive[#{@facet_field.key}][]", presenter.value, presenter.selected?, id: "f_inclusive_#{@facet_field.key}_#{idx}"%>
12
12
  </span>
13
13
 
14
- <span class="label-and-count">
14
+ <span>
15
15
  <%= label_tag "f_inclusive_#{@facet_field.key}_#{idx}" do %>
16
16
  <span class="facet-label"><%= presenter.label %></span>
17
17
  <span class="facet-count"><%= t('blacklight.search.facets.count', number: number_with_delimiter(presenter.hits)) %></span>
@@ -17,7 +17,7 @@ module Blacklight
17
17
  return to_enum(:presenters) unless block_given?
18
18
 
19
19
  @facet_field.paginator.items.each do |item|
20
- yield (@facet_field.facet_field.item_presenter || Blacklight::FacetItemPresenter).new(item, @facet_field.facet_field, helpers, @facet_field.key, @facet_field.search_state)
20
+ yield @facet_field.facet_field.item_presenter.new(item, @facet_field.facet_field, helpers, @facet_field.key, @facet_field.search_state)
21
21
  end
22
22
  end
23
23
  end
@@ -1,18 +1,18 @@
1
1
  <div class="card facet-limit blacklight-<%= @facet_field.key %> <%= 'facet-limit-active' if @facet_field.active? %>">
2
- <h3 class="card-header p-0 facet-field-heading" id="<%= @facet_field.html_id %>-header">
2
+ <h3 class="card-header p-0 facet-field-heading" id="<%= header_html_id %>">
3
3
  <button
4
4
  type="button"
5
5
  class="btn w-100 d-block btn-block p-2 text-start text-left collapse-toggle <%= "collapsed" if @facet_field.collapsed? %>"
6
6
  data-toggle="collapse"
7
7
  data-bs-toggle="collapse"
8
- data-target="#<%= @facet_field.html_id %>"
9
- data-bs-target="#<%= @facet_field.html_id %>"
8
+ data-target="#<%= html_id %>"
9
+ data-bs-target="#<%= html_id %>"
10
10
  aria-expanded="<%= @facet_field.collapsed? ? 'false' : 'true' %>"
11
11
  >
12
12
  <%= label %>
13
13
  </button>
14
14
  </h3>
15
- <div id="<%= @facet_field.html_id %>" aria-labelledby="<%= @facet_field.html_id %>-header" class="panel-collapse facet-content collapse <%= "show" unless @facet_field.collapsed? %>">
15
+ <div id="<%= html_id %>" aria-labelledby="<%= header_html_id %>" class="panel-collapse facet-content collapse <%= "show" unless @facet_field.collapsed? %>">
16
16
  <div class="card-body">
17
17
  <%= body %>
18
18
 
@@ -20,7 +20,7 @@
20
20
  <div class="more_facets">
21
21
  <%= link_to t("more_#{@facet_field.key}_html", scope: 'blacklight.search.facets', default: :more_html, field_name: @facet_field.label),
22
22
  @facet_field.modal_path,
23
- data: { blacklight_modal: 'trigger' } %>
23
+ data: { blacklight_modal: 'trigger', turbo: false } %>
24
24
  </div>
25
25
  <% end %>
26
26
  </div>
@@ -2,13 +2,20 @@
2
2
 
3
3
  module Blacklight
4
4
  class FacetFieldComponent < Blacklight::Component
5
- include Blacklight::ContentAreasShim
6
-
7
5
  renders_one :label
8
6
  renders_one :body
9
7
 
8
+ # @param [Blacklight::FacetFieldPresenter] facet_field
10
9
  def initialize(facet_field:)
11
10
  @facet_field = facet_field
12
11
  end
12
+
13
+ def html_id
14
+ "facet-#{@facet_field.key.parameterize}"
15
+ end
16
+
17
+ def header_html_id
18
+ "#{html_id}-header"
19
+ end
13
20
  end
14
21
  end
@@ -1,11 +1,11 @@
1
1
  <%= render(@layout.new(facet_field: @facet_field)) do |component| %>
2
- <% component.with_label do %>
2
+ <% component.label do %>
3
3
  <%= @facet_field.label %>
4
4
  <% end %>
5
- <% component.with_body do %>
5
+ <% component.body do %>
6
6
  <%= helpers.render(Blacklight::FacetFieldInclusiveConstraintComponent.new(facet_field: @facet_field)) %>
7
7
  <ul class="facet-values list-unstyled">
8
- <%= render_facet_limit_list @facet_field.paginator, @facet_field.key %>
8
+ <%= render facet_items %>
9
9
  </ul>
10
10
  <%# backwards compatibility, ugh %>
11
11
  <% if @layout == Blacklight::FacetFieldNoLayoutComponent && !@facet_field.in_modal? && @facet_field.modal_path %>