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
@@ -1,309 +1,11 @@
1
1
  # frozen_string_literal: true
2
- module Blacklight::FacetsHelperBehavior
3
- extend Deprecation
4
- self.deprecation_horizon = 'blacklight 8.0'
5
-
6
- include Blacklight::Facet
7
-
8
- ##
9
- # Check if any of the given fields have values
10
- #
11
- # @deprecated
12
- # @param [Array<String>] fields
13
- # @return [Boolean]
14
- def has_facet_values? fields = facet_field_names, response = nil
15
- deprecated_method(:has_facet_values?)
16
- unless response
17
- Deprecation.warn(self, 'Calling has_facet_values? without passing the ' \
18
- 'second argument (response) is deprecated and will be removed in Blacklight ' \
19
- '8.0.0')
20
- response = @response
21
- end
22
- Deprecation.silence(Blacklight::FacetsHelperBehavior) do
23
- Deprecation.silence(Blacklight::Facet) do
24
- facets_from_request(fields, response).any? { |display_facet| should_render_facet?(display_facet) }
25
- end
26
- end
27
- end
28
-
29
- ##
30
- # Render a collection of facet fields.
31
- # @see #render_facet_limit
32
- #
33
- # @deprecated
34
- # @param [Array<String>] fields
35
- # @param [Hash] options
36
- # @option options [Blacklight::Solr::Response] :response the Solr response object
37
- # @return String
38
- def render_facet_partials fields = nil, options = {}
39
- deprecated_method(:render_facet_partials)
40
-
41
- unless fields
42
- Deprecation.warn(self.class, 'Calling render_facet_partials without passing the ' \
43
- 'first argument (fields) is deprecated and will be removed in Blacklight ' \
44
- '8.0.0')
45
- fields = facet_field_names
46
- end
47
-
48
- response = options.delete(:response)
49
- unless response
50
- Deprecation.warn(self.class, 'Calling render_facet_partials without passing the ' \
51
- 'response keyword is deprecated and will be removed in Blacklight ' \
52
- '8.0.0')
53
- response = @response
54
- end
55
- Deprecation.silence(Blacklight::FacetsHelperBehavior) do
56
- Deprecation.silence(Blacklight::Facet) do
57
- safe_join(facets_from_request(fields, response).map do |display_facet|
58
- render_facet_limit(display_facet, options)
59
- end.compact, "\n")
60
- end
61
- end
62
- end
63
-
64
- ##
65
- # Renders a single section for facet limit with a specified
66
- # solr field used for faceting. Can be over-ridden for custom
67
- # display on a per-facet basis.
68
- #
69
- # @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
70
- # @param [Hash] options parameters to use for rendering the facet limit partial
71
- # @option options [String] :partial partial to render
72
- # @option options [String] :layout partial layout to render
73
- # @option options [Hash] :locals locals to pass to the partial
74
- # @return [String]
75
- def render_facet_limit(display_facet, options = {})
76
- field_config = facet_configuration_for_field(display_facet.name)
77
-
78
- if field_config.component
79
- return render(
80
- Blacklight::FacetComponent.new(
81
- display_facet: display_facet,
82
- field_config: field_config,
83
- layout: (params[:action] == 'facet' ? false : options[:layout])
84
- )
85
- )
86
- end
87
-
88
- Deprecation.warn(Blacklight::FacetsHelperBehavior, 'Calling #render_facet_limit on a non-componentized'\
89
- ' facet is deprecated and will be removed in Blacklight 8')
90
-
91
- Deprecation.silence(Blacklight::FacetsHelperBehavior) do
92
- return unless should_render_facet?(display_facet, field_config)
93
- end
94
- options = options.dup
95
-
96
- Deprecation.silence(Blacklight::FacetsHelperBehavior) do
97
- options[:partial] ||= facet_partial_name(display_facet)
98
- end
99
-
100
- options[:layout] ||= "facet_layout" unless options.key?(:layout)
101
- options[:locals] ||= {}
102
- options[:locals][:field_name] ||= display_facet.name
103
- options[:locals][:facet_field] ||= field_config
104
- options[:locals][:display_facet] ||= display_facet
105
-
106
- render(options)
107
- end
108
-
109
- ##
110
- # Renders the list of values
111
- # removes any elements where render_facet_item returns a nil value. This enables an application
112
- # to filter undesireable facet items so they don't appear in the UI
113
- # @deprecated
114
- def render_facet_limit_list(paginator, facet_field, wrapping_element = :li)
115
- facet_config ||= facet_configuration_for_field(facet_field)
116
-
117
- collection = paginator.items.map do |item|
118
- facet_item_presenter(facet_config, item, facet_field)
119
- end
120
-
121
- render(facet_item_component_class(facet_config).with_collection(collection, wrapping_element: wrapping_element))
122
- end
123
- deprecation_deprecate :render_facet_limit_list
124
-
125
- ##
126
- # Renders a single facet item
127
- # @deprecated
128
- def render_facet_item(facet_field, item)
129
- deprecated_method(:render_facet_item)
130
- if facet_in_params?(facet_field, item.value)
131
- render_selected_facet_value(facet_field, item)
132
- else
133
- render_facet_value(facet_field, item)
134
- end
135
- end
136
-
137
- ##
138
- # Determine if Blacklight should render the display_facet or not
139
- #
140
- # By default, only render facets with items.
141
- #
142
- # @deprecated
143
- # @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
144
- # @param [Blacklight::Configuration::FacetField] facet_config
145
- # @return [Boolean]
146
- def should_render_facet? display_facet, facet_config = nil
147
- return false if display_facet.items.blank?
148
-
149
- # display when show is nil or true
150
- facet_config ||= facet_configuration_for_field(display_facet.name)
151
- should_render_field?(facet_config, display_facet)
152
- end
153
- deprecation_deprecate :should_render_facet?
154
2
 
155
- ##
156
- # Determine whether a facet should be rendered as collapsed or not.
157
- # - if the facet is 'active', don't collapse
158
- # - if the facet is configured to collapse (the default), collapse
159
- # - if the facet is configured not to collapse, don't collapse
160
- #
161
- # @deprecated
162
- # @param [Blacklight::Configuration::FacetField] facet_field
163
- # @return [Boolean]
164
- def should_collapse_facet? facet_field
165
- Deprecation.silence(Blacklight::FacetsHelperBehavior) do
166
- !facet_field_in_params?(facet_field.key) && facet_field.collapse
167
- end
168
- end
169
- deprecation_deprecate :should_collapse_facet?
170
-
171
- ##
172
- # The name of the partial to use to render a facet field.
173
- # uses the value of the "partial" field if set in the facet configuration
174
- # otherwise uses "facet_pivot" if this facet is a pivot facet
175
- # defaults to 'facet_limit'
176
- #
177
- # @return [String]
178
- def facet_partial_name(display_facet = nil)
179
- config = facet_configuration_for_field(display_facet.name)
180
- name = config.partial
181
- name ||= "facet_pivot" if config.pivot
182
- name || "facet_limit"
183
- end
184
- deprecation_deprecate :facet_partial_name
3
+ module Blacklight::FacetsHelperBehavior
4
+ delegate :facet_configuration_for_field, to: :blacklight_config
185
5
 
186
6
  def facet_field_presenter(facet_config, display_facet)
187
- (facet_config.presenter || Blacklight::FacetFieldPresenter).new(facet_config, display_facet, self)
188
- end
189
-
190
- ##
191
- # Standard display of a facet value in a list. Used in both _facets sidebar
192
- # partial and catalog/facet expanded list. Will output facet value name as
193
- # a link to add that to your restrictions, with count in parens.
194
- #
195
- # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
196
- # @param [Blacklight::Solr::Response::Facets::FacetItem] item
197
- # @param [Hash] options
198
- # @option options [Boolean] :suppress_link display the facet, but don't link to it
199
- # @return [String]
200
- def render_facet_value(facet_field, item, options = {})
201
- deprecated_method(:render_facet_value)
202
- facet_config = facet_configuration_for_field(facet_field)
203
- facet_item_component(facet_config, item, facet_field, **options).render_facet_value
204
- end
205
-
206
- ##
207
- # Where should this facet link to?
208
- #
209
- # @deprecated
210
- # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
211
- # @param [String] item
212
- # @return [String]
213
- def path_for_facet(facet_field, item, path_options = {})
214
- facet_config = facet_configuration_for_field(facet_field)
215
- facet_item_presenter(facet_config, item, facet_field).href(path_options)
216
- end
217
- deprecation_deprecate :path_for_facet
218
-
219
- ##
220
- # Standard display of a SELECTED facet value (e.g. without a link and with a remove button)
221
- #
222
- # @deprecated
223
- # @see #render_facet_value
224
- # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
225
- # @param [String] item
226
- def render_selected_facet_value(facet_field, item)
227
- deprecated_method(:render_selected_facet_value)
228
- facet_config = facet_configuration_for_field(facet_field)
229
- facet_item_component(facet_config, item, facet_field).render_selected_facet_value
230
- end
231
-
232
- ##
233
- # Renders a count value for facet limits. Can be over-ridden locally
234
- # to change style. And can be called by plugins to get consistent display.
235
- #
236
- # @deprecated
237
- # @param [Integer] num number of facet results
238
- # @param [Hash] options
239
- # @option options [Array<String>] an array of classes to add to count span.
240
- # @return [String]
241
- def render_facet_count(num, options = {})
242
- deprecated_method(:render_facet_count)
243
- classes = (options[:classes] || []) << "facet-count"
244
- tag.span(t('blacklight.search.facets.count', number: number_with_delimiter(num)), class: classes)
245
- end
246
-
247
- ##
248
- # Are any facet restrictions for a field in the query parameters?
249
- # @private
250
- # @param [String] field
251
- # @return [Boolean]
252
- def facet_field_in_params? field
253
- config = facet_configuration_for_field(field)
254
-
255
- Deprecation.silence(Blacklight::SearchState) do
256
- search_state.has_facet? config
257
- end
7
+ facet_config.presenter.new(facet_config, display_facet, self)
258
8
  end
259
- # Left undeprecated for the sake of temporary backwards compatibility
260
- # deprecation_deprecate :facet_field_in_params?
261
-
262
- ##
263
- # Check if the query parameters have the given facet field with the
264
- # given value.
265
- #
266
- # @deprecated
267
- # @param [String] field
268
- # @param [String] item facet value
269
- # @return [Boolean]
270
- def facet_in_params?(field, item)
271
- config = facet_configuration_for_field(field)
272
-
273
- Deprecation.silence(Blacklight::SearchState) do
274
- search_state.has_facet? config, value: facet_value_for_facet_item(item)
275
- end
276
- end
277
- deprecation_deprecate :facet_in_params?
278
-
279
- ##
280
- # Get the values of the facet set in the blacklight query string
281
- # @deprecated
282
- def facet_params field
283
- config = facet_configuration_for_field(field)
284
-
285
- search_state.params.dig(:f, config.key)
286
- end
287
- deprecation_deprecate :facet_params
288
-
289
- ##
290
- # Get the displayable version of a facet's value
291
- #
292
- # @param [Object] field
293
- # @param [String] item value
294
- # @return [String]
295
- # @deprecated
296
- def facet_display_value field, item
297
- deprecated_method(:facet_display_value)
298
- facet_config = facet_configuration_for_field(field)
299
- facet_item_presenter(facet_config, item, field).label
300
- end
301
-
302
- # @deprecated
303
- def facet_field_id facet_field
304
- "facet-#{facet_field.key.parameterize}"
305
- end
306
- deprecation_deprecate :facet_field_id
307
9
 
308
10
  private
309
11
 
@@ -316,25 +18,6 @@ module Blacklight::FacetsHelperBehavior
316
18
  end
317
19
 
318
20
  def facet_item_presenter(facet_config, facet_item, facet_field)
319
- (facet_config.item_presenter || Blacklight::FacetItemPresenter).new(facet_item, facet_config, self, facet_field)
320
- end
321
-
322
- def facet_item_component(facet_config, facet_item, facet_field, **args)
323
- facet_item_component_class(facet_config).new(facet_item: facet_item_presenter(facet_config, facet_item, facet_field), **args).with_view_context(self)
324
- end
325
-
326
- def facet_item_component_class(facet_config)
327
- default_component = facet_config.pivot ? Blacklight::FacetItemPivotComponent : Blacklight::FacetItemComponent
328
- facet_config.fetch(:item_component, default_component)
329
- end
330
-
331
- # We can't use .deprecation_deprecate here, because the new components need to
332
- # see the originally defined location for these methods in order to properly
333
- # call back into the helpers for backwards compatibility
334
- def deprecated_method(method_name)
335
- Deprecation.warn(Blacklight::FacetsHelperBehavior,
336
- Deprecation.deprecated_method_warning(Blacklight::FacetsHelperBehavior,
337
- method_name, {}),
338
- caller)
21
+ facet_config.item_presenter.new(facet_item, facet_config, self, facet_field)
339
22
  end
340
23
  end
@@ -12,9 +12,10 @@ module Blacklight::IconHelperBehavior
12
12
  def blacklight_icon(icon_name, **kwargs)
13
13
  render "Blacklight::Icons::#{icon_name.to_s.camelize}Component".constantize.new(**kwargs)
14
14
  rescue NameError
15
- Rails.cache.fetch([:blacklight_icons, icon_name, kwargs]) do
16
- icon = Blacklight::Icon.new(icon_name, **kwargs)
17
- tag.span(icon.svg.html_safe, **icon.options)
18
- end
15
+ Blacklight.deprecation.warn(
16
+ "Falling back on the LegacyIconComponent with \"#{icon_name}\" is deprecated. Instead create the component `Blacklight::Icons::#{icon_name.to_s.camelize}Component` for this icon."
17
+ )
18
+
19
+ render Blacklight::Icons::LegacyIconComponent.new(name: icon_name, **kwargs)
19
20
  end
20
21
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Methods added to this helper will be available to all templates in the hosting
3
4
  # application
4
5
  module Blacklight
@@ -1,28 +1,16 @@
1
1
  # frozen_string_literal: true
2
- module Blacklight::RenderPartialsHelperBehavior
3
- extend Deprecation
4
2
 
3
+ module Blacklight::RenderPartialsHelperBehavior
5
4
  ##
6
5
  # Render the document index view
7
6
  #
8
7
  # @param [Array<SolrDocument>] documents list of documents to render
9
8
  # @param [Hash] locals to pass to the render call
10
9
  # @return [String]
11
- def render_document_index documents = nil, locals = {}
12
- unless documents
13
- Deprecation.warn(self, "Calling render_document_index without documents is deprecated and will be removed in version 8")
14
- documents = @response.documents
15
- end
10
+ def render_document_index documents, locals = {}
16
11
  render_document_index_with_view(document_index_view_type, documents, locals)
17
12
  end
18
13
 
19
- ##
20
- # Render the document index for a grouped response
21
- def render_grouped_document_index
22
- render 'catalog/group'
23
- end
24
- deprecation_deprecate render_grouped_document_index: 'Removed without replacement'
25
-
26
14
  ##
27
15
  # Return the list of partials for a given solr document
28
16
  # @param [SolrDocument] doc solr document to render partials for
@@ -34,6 +22,8 @@ module Blacklight::RenderPartialsHelperBehavior
34
22
  render_document_partial(doc, action_name, locals)
35
23
  end, "\n")
36
24
  end
25
+ Blacklight.deprecation.deprecate_methods(self, render_document_partials: 'Replace this call with: "document_component = blacklight_config.view_config(:atom).summary_component
26
+ render document_component.new(presenter: document_presenter(document), component: :div, show: true)"')
37
27
 
38
28
  ##
39
29
  # Return the list of xml for a given solr document. Doesn't safely escape for HTML.
@@ -60,7 +50,7 @@ module Blacklight::RenderPartialsHelperBehavior
60
50
  # @param [String] base_name base name for the partial
61
51
  # @param [Hash] locals local variables to pass through to the partials
62
52
  def render_document_partial(doc, base_name, locals = {})
63
- format = Deprecation.silence(Blacklight::RenderPartialsHelperBehavior) { document_partial_name(doc, base_name) }
53
+ format = document_partial_name(doc, base_name)
64
54
 
65
55
  view_type = document_index_view_type
66
56
  template = cached_view ['show', view_type, base_name, format].join('_') do
@@ -69,7 +59,6 @@ module Blacklight::RenderPartialsHelperBehavior
69
59
  if template
70
60
  template.render(self, locals.merge(document: doc))
71
61
  else
72
- logger.warn("No template was found for base_name: '#{base_name}', view_type: '#{view_type}' in render_document_partial")
73
62
  ''
74
63
  end
75
64
  end
@@ -119,6 +108,8 @@ module Blacklight::RenderPartialsHelperBehavior
119
108
  ]
120
109
  end
121
110
 
111
+ private
112
+
122
113
  ##
123
114
  # Return a normalized partial name for rendering a single document
124
115
  #
@@ -131,9 +122,6 @@ module Blacklight::RenderPartialsHelperBehavior
131
122
 
132
123
  type_field_to_partial_name(document, display_type)
133
124
  end
134
- deprecation_deprecate document_partial_name: 'Moving to a private method'
135
-
136
- private
137
125
 
138
126
  ##
139
127
  # Return a partial name for rendering a document
@@ -191,21 +179,13 @@ module Blacklight::RenderPartialsHelperBehavior
191
179
  def find_document_index_template_with_view view_type, locals
192
180
  document_index_path_templates.each do |str|
193
181
  partial = format(str, index_view_type: view_type)
182
+ name = partial.split('/').last
183
+ prefix = partial.split('/').first if partial.include?('/')
194
184
  logger&.debug "Looking for document index partial #{partial}"
195
-
196
- template = if Rails::VERSION::MAJOR >= 6
197
- name = partial.split('/').last
198
- prefix = partial.split('/').first if partial.include?('/')
199
-
200
- prefixes = lookup_context.prefixes + [prefix, ""].compact
201
- lookup_context.find_all(name, prefixes, true, locals.keys + [:documents], {}).first
202
- else
203
- lookup_context.find_all(partial, lookup_context.prefixes + [""], true, locals.keys + [:documents], {}).first
204
- end
205
-
185
+ prefixes = lookup_context.prefixes + [prefix, ""].compact
186
+ template = lookup_context.find_all(name, prefixes, true, locals.keys + [:documents], {}).first
206
187
  return template if template
207
188
  end
208
-
209
189
  nil
210
190
  end
211
191
 
@@ -1,15 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  ##
3
4
  # URL helper methods
4
5
  module Blacklight::UrlHelperBehavior
5
- extend Deprecation
6
-
7
- # @deprecated
8
- def url_for_document(doc, options = {})
9
- search_state.url_for_document(doc, options)
10
- end
11
- deprecation_deprecate url_for_document: 'Use SearchState#url_for_document directly'
12
-
13
6
  # Uses the catalog_path route to create a link to the show page for an item.
14
7
  # catalog_path accepts a hash. The solr query params are stored in the session,
15
8
  # so we only need the +counter+ param here. We also need to know if we are viewing to document as part of search results.
@@ -19,9 +12,9 @@ module Blacklight::UrlHelperBehavior
19
12
  # @param opts [Hash] the options to create the link with
20
13
  # @option opts [Number] :counter (nil) the count to set in the session (for paging through a query result)
21
14
  # @example Passing in an image
22
- # link_to_document(doc, '<img src="thumbnail.png">', counter: 3) #=> "<a href=\"catalog/123\" data-tracker-href=\"/catalog/123/track?counter=3&search_id=999\"><img src="thumbnail.png"></a>
15
+ # link_to_document(doc, '<img src="thumbnail.png">', counter: 3) #=> "<a href=\"catalog/123\" data-context-href=\"/catalog/123/track?counter=3&search_id=999\"><img src="thumbnail.png"></a>
23
16
  # @example With the default document link field
24
- # link_to_document(doc, counter: 3) #=> "<a href=\"catalog/123\" data-tracker-href=\"/catalog/123/track?counter=3&search_id=999\">My Title</a>
17
+ # link_to_document(doc, counter: 3) #=> "<a href=\"catalog/123\" data-context-href=\"/catalog/123/track?counter=3&search_id=999\">My Title</a>
25
18
  def link_to_document(doc, field_or_opts = nil, opts = { counter: nil })
26
19
  label = case field_or_opts
27
20
  when NilClass
@@ -29,18 +22,11 @@ module Blacklight::UrlHelperBehavior
29
22
  when Hash
30
23
  opts = field_or_opts
31
24
  document_presenter(doc).heading
32
- when Proc, Symbol
33
- Deprecation.warn(self, "passing a #{field_or_opts.class} to link_to_document is deprecated and will be removed in Blacklight 8")
34
- Deprecation.silence(Blacklight::IndexPresenter) do
35
- index_presenter(doc).label field_or_opts, opts
36
- end
37
25
  else # String
38
26
  field_or_opts
39
27
  end
40
28
 
41
- Deprecation.silence(Blacklight::UrlHelperBehavior) do
42
- link_to label, url_for_document(doc), document_link_params(doc, opts)
43
- end
29
+ link_to label, search_state.url_for_document(doc), document_link_params(doc, opts)
44
30
  end
45
31
 
46
32
  # @private
@@ -49,46 +35,19 @@ module Blacklight::UrlHelperBehavior
49
35
  end
50
36
  private :document_link_params
51
37
 
52
- ##
53
- # Link to the previous document in the current search context
54
- # @deprecated
55
- def link_to_previous_document(previous_document, classes: 'previous', **addl_link_opts)
56
- link_opts = session_tracking_params(previous_document, search_session['counter'].to_i - 1).merge(class: classes, rel: 'prev').merge(addl_link_opts)
57
- link_to_unless previous_document.nil?, raw(t('views.pagination.previous')), url_for_document(previous_document), link_opts do
58
- tag.span raw(t('views.pagination.previous')), class: 'previous'
59
- end
60
- end
61
- deprecation_deprecate link_to_previous_document: 'Moving to Blacklight::SearchContextComponent'
62
-
63
- ##
64
- # Link to the next document in the current search context
65
- # @deprecated
66
- def link_to_next_document(next_document, classes: 'next', **addl_link_opts)
67
- link_opts = session_tracking_params(next_document, search_session['counter'].to_i + 1).merge(class: classes, rel: 'next').merge(addl_link_opts)
68
- link_to_unless next_document.nil?, raw(t('views.pagination.next')), url_for_document(next_document), link_opts do
69
- tag.span raw(t('views.pagination.next')), class: 'next'
70
- end
71
- end
72
- deprecation_deprecate link_to_previous_document: 'Moving to Blacklight::SearchContextComponent'
73
-
74
38
  ##
75
39
  # Attributes for a link that gives a URL we can use to track clicks for the current search session
76
- # @private
77
40
  # @param [SolrDocument] document
78
41
  # @param [Integer] counter
79
42
  # @example
80
43
  # session_tracking_params(SolrDocument.new(id: 123), 7)
81
- # => { data: { :'context-href' => '/catalog/123/track?counter=7&search_id=999' } }
82
- def session_tracking_params document, counter
83
- path = session_tracking_path(document, per_page: params.fetch(:per_page, search_session['per_page']), counter: counter, search_id: current_search_session.try(:id), document_id: document&.id)
84
-
85
- if path.nil?
86
- return {}
87
- end
44
+ # => { data: { context_href: '/catalog/123/track?counter=7&search_id=999' } }
45
+ def session_tracking_params document, counter, per_page: search_session['per_page'], search_id: current_search_session&.id
46
+ path = session_tracking_path(document, per_page: params.fetch(:per_page, per_page), counter: counter, search_id: search_id, document_id: document&.id)
47
+ return {} if path.nil?
88
48
 
89
- { data: { 'context-href': path } }
49
+ { data: { context_href: path } }
90
50
  end
91
- private :session_tracking_params
92
51
 
93
52
  ##
94
53
  # Get the URL for tracking search sessions across pages using polymorphic routing
@@ -100,7 +59,7 @@ module Blacklight::UrlHelperBehavior
100
59
  end
101
60
 
102
61
  raise "Unable to find #{controller_tracking_method} route helper. " \
103
- "Did you add `concerns :searchable` routing mixin to your `config/routes.rb`?"
62
+ "Did you add `concerns :searchable` routing mixin to your `config/routes.rb`?"
104
63
  end
105
64
 
106
65
  def controller_tracking_method
@@ -111,28 +70,6 @@ module Blacklight::UrlHelperBehavior
111
70
  # link based helpers ->
112
71
  #
113
72
 
114
- # create link to query (e.g. spelling suggestion)
115
- # @deprecated
116
- def link_to_query(query)
117
- p = search_state.to_h.except(:page, :action)
118
- p[:q] = query
119
- link_to(query, search_action_path(p))
120
- end
121
- deprecation_deprecate link_to_query: 'Removed without replacement'
122
-
123
- ##
124
- # Get the path to the search action with any parameters (e.g. view type)
125
- # that should be persisted across search sessions.
126
- # @deprecated
127
- def start_over_path query_params = params
128
- h = {}
129
- current_index_view_type = document_index_view_type(query_params)
130
- h[:view] = current_index_view_type unless current_index_view_type == default_document_index_view_type
131
-
132
- search_action_path(h)
133
- end
134
- deprecation_deprecate start_over_path: 'Removed without replacement'
135
-
136
73
  # Create a link back to the index screen, keeping the user's facet, query and paging choices intact by using session.
137
74
  # @example
138
75
  # link_back_to_catalog(label: 'Back to Search')
@@ -165,30 +102,9 @@ module Blacklight::UrlHelperBehavior
165
102
  link_to label, link_url, opts
166
103
  end
167
104
 
168
- # Search History and Saved Searches display
105
+ # Use in e.g. the search history display, where we want something more like text instead of the normal constraints
169
106
  def link_to_previous_search(params)
170
- Deprecation.silence(Blacklight::SearchHistoryConstraintsHelperBehavior) do
171
- link_to(render_search_to_s(params), search_action_path(params))
172
- end
173
- end
174
-
175
- # Get url parameters to a search within a grouped result set
176
- #
177
- # @deprecated
178
- # @param [Blacklight::Solr::Response::Group] group
179
- # @return [Hash]
180
- def add_group_facet_params_and_redirect group
181
- search_state.add_facet_params_and_redirect(group.field, group.key)
182
- end
183
- deprecation_deprecate add_group_facet_params_and_redirect: 'Removed without replacement'
184
-
185
- # A URL to refworks export, with an embedded callback URL to this app.
186
- # the callback URL is to bookmarks#export, which delivers a list of
187
- # user's bookmarks in 'refworks marc txt' format -- we tell refworks
188
- # to expect that format.
189
- # @deprecated
190
- def bookmarks_export_url(format, params = {})
191
- bookmarks_url(params.merge(format: format, encrypted_user_id: encrypt_user_id(current_or_guest_user.id)))
107
+ search_state = controller.search_state_class.new(params, blacklight_config, self)
108
+ link_to(render(Blacklight::ConstraintsComponent.for_search_history(search_state: search_state)), search_action_path(params))
192
109
  end
193
- deprecation_deprecate bookmarks_export_url: 'Removed without replacement'
194
110
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module BlacklightHelper
3
4
  include Blacklight::BlacklightHelperBehavior
4
5
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module CatalogHelper
3
4
  include Blacklight::CatalogHelperBehavior
4
5
  end
@@ -1,25 +1,19 @@
1
- (function($) {
2
- //change form submit toggle to checkbox
1
+ import Blacklight from './core'
2
+ import CheckboxSubmit from './checkbox_submit'
3
+
4
+ const BookmarkToggle = (() => {
5
+ // change form submit toggle to checkbox
3
6
  Blacklight.doBookmarkToggleBehavior = function() {
4
- if (typeof Blacklight.do_bookmark_toggle_behavior == 'function') {
5
- console.warn("do_bookmark_toggle_behavior is deprecated. Use doBookmarkToggleBehavior instead.");
6
- return Blacklight.do_bookmark_toggle_behavior();
7
- }
8
- $(Blacklight.doBookmarkToggleBehavior.selector).blCheckboxSubmit({
9
- // cssClass is added to elements added, plus used for id base
10
- cssClass: 'toggle-bookmark',
11
- success: function(checked, response) {
12
- if (response.bookmarks) {
13
- $('[data-role=bookmark-counter]').text(response.bookmarks.count);
14
- }
15
- }
7
+ document.addEventListener('click', (e) => {
8
+ if (e.target.matches('[data-checkboxsubmit-target="checkbox"]')) {
9
+ const form = e.target.closest('form')
10
+ if (form) new CheckboxSubmit(form).clicked(e);
11
+ }
16
12
  });
17
13
  };
18
14
  Blacklight.doBookmarkToggleBehavior.selector = 'form.bookmark-toggle';
19
15
 
20
- Blacklight.onLoad(function() {
21
- Blacklight.doBookmarkToggleBehavior();
22
- });
23
-
16
+ Blacklight.doBookmarkToggleBehavior();
17
+ })()
24
18
 
25
- })(jQuery);
19
+ export default BookmarkToggle