blacklight 7.33.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env +3 -2
- data/.github/workflows/ruby.yml +38 -107
- data/.gitignore +1 -0
- data/.rubocop.yml +243 -2
- data/.rubocop_todo.yml +216 -270
- data/Gemfile +7 -6
- data/README.md +12 -4
- data/Rakefile +18 -0
- data/VERSION +1 -1
- data/app/assets/config/blacklight/manifest.js +3 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js +376 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -0
- data/app/assets/javascripts/blacklight/blacklight.js +332 -485
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -0
- data/app/assets/stylesheets/blacklight/_autocomplete.scss +25 -0
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -1
- data/app/assets/stylesheets/blacklight/_bookmark.scss +16 -0
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +8 -0
- data/app/assets/stylesheets/blacklight/_facets.scss +104 -49
- data/app/assets/stylesheets/blacklight/_header.scss +0 -15
- data/app/assets/stylesheets/blacklight/_icons.scss +0 -14
- data/app/assets/stylesheets/blacklight/_mixins.scss +20 -0
- data/app/assets/stylesheets/blacklight/_modal.scss +8 -2
- data/app/assets/stylesheets/blacklight/_search_form.scss +30 -3
- data/app/assets/stylesheets/blacklight/_search_history.scss +10 -1
- data/app/assets/stylesheets/blacklight/_search_results.scss +6 -2
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +4 -1
- data/app/builders/blacklight/action_builder.rb +18 -9
- data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +7 -9
- data/app/components/blacklight/constraints_component.rb +27 -37
- data/app/components/blacklight/document/action_component.html.erb +2 -9
- data/app/components/blacklight/document/action_component.rb +26 -8
- data/app/components/blacklight/document/actions_component.rb +2 -2
- data/app/components/blacklight/document/bookmark_component.html.erb +9 -0
- data/app/components/blacklight/document/bookmark_component.rb +4 -2
- data/app/components/blacklight/document/citation_component.rb +5 -3
- data/app/components/blacklight/document/group_component.rb +7 -3
- data/app/components/blacklight/document/show_tools_component.html.erb +12 -0
- data/app/components/blacklight/document/show_tools_component.rb +23 -0
- data/app/components/blacklight/document/sidebar_component.html.erb +2 -0
- data/app/components/blacklight/document/sidebar_component.rb +16 -0
- data/app/components/blacklight/document/thumbnail_component.html.erb +2 -7
- data/app/components/blacklight/document/thumbnail_component.rb +1 -9
- data/app/components/blacklight/document_component.html.erb +4 -0
- data/app/components/blacklight/document_component.rb +54 -42
- data/app/components/blacklight/document_metadata_component.html.erb +4 -2
- data/app/components/blacklight/document_metadata_component.rb +11 -6
- data/app/components/blacklight/document_title_component.rb +4 -1
- data/app/components/blacklight/facet_component.rb +1 -1
- data/app/components/blacklight/facet_field_checkboxes_component.html.erb +3 -3
- data/app/components/blacklight/facet_field_checkboxes_component.rb +1 -1
- data/app/components/blacklight/facet_field_component.html.erb +5 -5
- data/app/components/blacklight/facet_field_component.rb +9 -2
- data/app/components/blacklight/facet_field_list_component.html.erb +3 -3
- data/app/components/blacklight/facet_field_list_component.rb +37 -5
- data/app/components/blacklight/facet_field_no_layout_component.rb +0 -2
- data/app/components/blacklight/facet_item_component.rb +1 -43
- data/app/components/blacklight/facet_item_pivot_component.rb +21 -23
- data/app/components/blacklight/header_component.html.erb +2 -0
- data/app/components/blacklight/header_component.rb +26 -0
- data/app/components/blacklight/hidden_search_state_component.rb +1 -2
- data/app/components/blacklight/icons/legacy_icon_component.rb +30 -0
- data/app/components/blacklight/icons/list_component.rb +16 -0
- data/app/components/blacklight/icons/search_component.rb +16 -0
- data/app/components/blacklight/metadata_field_component.html.erb +2 -2
- data/app/components/blacklight/metadata_field_component.rb +24 -8
- data/app/components/blacklight/metadata_field_layout_component.rb +7 -22
- data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +17 -0
- data/app/components/blacklight/response/facet_group_component.html.erb +5 -6
- data/app/components/blacklight/response/facet_group_component.rb +29 -8
- data/app/components/blacklight/response/sort_component.rb +2 -2
- data/app/components/blacklight/response/spellcheck_component.rb +18 -7
- data/app/components/blacklight/response/view_type_button_component.rb +3 -7
- data/app/components/blacklight/response/view_type_component.rb +4 -6
- data/app/components/blacklight/search/sidebar_component.html.erb +8 -0
- data/app/components/blacklight/search/sidebar_component.rb +17 -0
- data/app/components/blacklight/search_bar_component.html.erb +20 -15
- data/app/components/blacklight/search_bar_component.rb +2 -16
- data/app/components/blacklight/search_button_component.rb +3 -3
- data/app/components/blacklight/search_context/server_applied_params_component.html.erb +4 -0
- data/app/components/blacklight/search_context/server_applied_params_component.rb +13 -0
- data/app/components/blacklight/search_context/server_item_pagination_component.rb +71 -0
- data/app/components/blacklight/search_header_component.html.erb +2 -0
- data/app/components/blacklight/search_header_component.rb +6 -0
- data/app/components/blacklight/search_navbar_component.html.erb +5 -0
- data/app/components/blacklight/search_navbar_component.rb +34 -0
- data/app/components/blacklight/start_over_button_component.rb +5 -3
- data/app/components/blacklight/system/dropdown_component.rb +3 -3
- data/app/components/blacklight/system/flash_message_component.html.erb +3 -1
- data/app/components/blacklight/system/flash_message_component.rb +12 -3
- data/app/components/blacklight/system/modal_component.html.erb +1 -1
- data/app/components/blacklight/system/modal_component.rb +1 -3
- data/app/components/blacklight/top_navbar_component.html.erb +12 -0
- data/app/components/blacklight/top_navbar_component.rb +17 -0
- data/app/controllers/bookmarks_controller.rb +1 -0
- data/app/controllers/catalog_controller.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +11 -6
- data/app/controllers/concerns/blacklight/catalog.rb +21 -72
- data/app/controllers/concerns/blacklight/controller.rb +6 -43
- data/app/controllers/concerns/blacklight/search_context.rb +71 -13
- data/app/controllers/concerns/blacklight/search_history.rb +2 -0
- data/app/controllers/concerns/blacklight/searchable.rb +12 -1
- data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
- data/app/controllers/search_history_controller.rb +1 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -400
- data/app/helpers/blacklight/catalog_helper_behavior.rb +40 -182
- data/app/helpers/blacklight/component_helper_behavior.rb +1 -63
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -117
- data/app/helpers/blacklight/document_helper_behavior.rb +76 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +4 -321
- data/app/helpers/blacklight/icon_helper_behavior.rb +5 -4
- data/app/helpers/blacklight/layout_helper_behavior.rb +60 -0
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +12 -30
- data/app/helpers/blacklight/url_helper_behavior.rb +21 -97
- data/app/helpers/blacklight_helper.rb +1 -0
- data/app/helpers/catalog_helper.rb +1 -0
- data/app/javascript/blacklight/bookmark_toggle.js +9 -22
- data/app/javascript/blacklight/button_focus.js +9 -7
- data/app/javascript/blacklight/checkbox_submit.js +68 -122
- data/app/javascript/blacklight/core.js +6 -5
- data/app/javascript/blacklight/index.js +14 -0
- data/app/javascript/blacklight/modal.js +100 -165
- data/app/javascript/blacklight/modalForm.js +60 -0
- data/app/javascript/blacklight/search_context.js +13 -29
- data/app/models/blacklight/facet_paginator.rb +3 -2
- data/app/models/blacklight/icon.rb +4 -2
- data/app/models/bookmark.rb +0 -2
- data/app/models/concerns/blacklight/configurable.rb +5 -4
- data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
- data/app/models/concerns/blacklight/document/attributes.rb +50 -0
- data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
- data/app/models/concerns/blacklight/document/dublin_core.rb +2 -1
- data/app/models/concerns/blacklight/document/export.rb +2 -1
- data/app/models/concerns/blacklight/document/extensions.rb +1 -0
- data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
- data/app/models/concerns/blacklight/document.rb +23 -20
- data/app/models/concerns/blacklight/suggest/response.rb +1 -0
- data/app/models/concerns/blacklight/user.rb +17 -8
- data/app/models/record_mailer.rb +23 -18
- data/app/models/search.rb +0 -1
- data/app/models/solr_document.rb +1 -0
- data/app/presenters/blacklight/clause_presenter.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +24 -30
- data/app/presenters/blacklight/facet_field_presenter.rb +39 -14
- data/app/presenters/blacklight/facet_grouped_item_presenter.rb +1 -5
- data/app/presenters/blacklight/facet_item_pivot_presenter.rb +60 -0
- data/app/presenters/blacklight/facet_item_presenter.rb +3 -9
- data/app/presenters/blacklight/field_presenter.rb +1 -0
- data/app/presenters/blacklight/index_presenter.rb +2 -40
- data/app/presenters/blacklight/json_presenter.rb +7 -5
- data/app/presenters/blacklight/rendering/abstract_step.rb +4 -0
- data/app/presenters/blacklight/rendering/join.rb +7 -1
- data/app/presenters/blacklight/rendering/link_to_facet.rb +3 -6
- data/app/presenters/blacklight/rendering/microdata.rb +1 -1
- data/app/presenters/blacklight/show_presenter.rb +1 -9
- data/app/presenters/blacklight/thumbnail_presenter.rb +1 -1
- data/app/services/blacklight/bookmarks_search_builder.rb +22 -0
- data/app/services/blacklight/field_retriever.rb +1 -8
- data/app/services/blacklight/search_service.rb +9 -7
- data/app/values/blacklight/types.rb +95 -11
- data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +8 -1
- data/app/views/bookmarks/_tools.html.erb +7 -12
- data/app/views/catalog/_advanced_search_form.html.erb +0 -1
- data/app/views/catalog/_bookmark_control.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +1 -14
- data/app/views/catalog/_document.atom.builder +12 -14
- data/app/views/catalog/_document.html.erb +3 -6
- data/app/views/catalog/_document.rss.builder +2 -4
- data/app/views/catalog/_document_list.html.erb +2 -1
- data/app/views/catalog/_facet_layout.html.erb +2 -2
- data/app/views/catalog/_facets.html.erb +5 -4
- data/app/views/catalog/_home_text.html.erb +2 -14
- data/app/views/catalog/_search_form.html.erb +3 -3
- data/app/views/catalog/_search_header.html.erb +1 -2
- data/app/views/catalog/_search_results.html.erb +2 -2
- data/app/views/catalog/_search_sidebar.html.erb +5 -1
- data/app/views/catalog/_show_main_content.html.erb +8 -19
- data/app/views/catalog/_show_sidebar.html.erb +2 -2
- data/app/views/catalog/_show_tools.html.erb +1 -19
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/app/views/catalog/email_success.html.erb +5 -6
- data/app/views/catalog/facet.html.erb +7 -5
- data/app/views/catalog/index.atom.builder +12 -14
- data/app/views/catalog/index.html.erb +7 -1
- data/app/views/catalog/index.json.jbuilder +19 -19
- data/app/views/catalog/index.rss.builder +1 -1
- data/app/views/catalog/opensearch.xml.builder +1 -1
- data/app/views/catalog/show.html.erb +1 -6
- data/app/views/catalog/sms_success.html.erb +5 -6
- data/app/views/catalog/suggest.html.erb +3 -0
- data/app/views/layouts/blacklight/base.html.erb +19 -9
- data/app/views/record_mailer/email_record.text.erb +4 -3
- data/app/views/record_mailer/sms_record.text.erb +4 -4
- data/app/views/search_history/index.html.erb +6 -2
- data/app/views/shared/_header_navbar.html.erb +1 -22
- data/app/views/shared/_modal.html.erb +3 -3
- data/blacklight.gemspec +8 -10
- data/config/importmap.rb +3 -0
- data/config/locales/blacklight.ar.yml +209 -233
- data/config/locales/blacklight.ca.yml +0 -7
- data/config/locales/blacklight.de.yml +197 -216
- data/config/locales/blacklight.en.yml +2 -7
- data/config/locales/blacklight.es.yml +196 -216
- data/config/locales/blacklight.fr.yml +196 -220
- data/config/locales/blacklight.hu.yml +193 -213
- data/config/locales/blacklight.it.yml +197 -216
- data/config/locales/blacklight.nl.yml +193 -213
- data/config/locales/blacklight.pt-BR.yml +195 -216
- data/config/locales/blacklight.sq.yml +193 -213
- data/config/locales/blacklight.zh.yml +194 -214
- data/config/routes.rb +3 -2
- data/db/migrate/20140202020201_create_searches.rb +1 -0
- data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
- data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
- data/docker-compose.yml +1 -0
- data/lib/blacklight/abstract_repository.rb +1 -0
- data/lib/blacklight/configuration/context.rb +4 -4
- data/lib/blacklight/configuration/display_field.rb +7 -9
- data/lib/blacklight/configuration/facet_field.rb +17 -11
- data/lib/blacklight/configuration/field.rb +1 -0
- data/lib/blacklight/configuration/fields.rb +12 -15
- data/lib/blacklight/configuration/index_field.rb +1 -0
- data/lib/blacklight/configuration/null_display_field.rb +17 -0
- data/lib/blacklight/configuration/search_field.rb +1 -0
- data/lib/blacklight/configuration/session_tracking_config.rb +45 -0
- data/lib/blacklight/configuration/show_field.rb +1 -0
- data/lib/blacklight/configuration/sort_field.rb +1 -0
- data/lib/blacklight/configuration/tool_config.rb +1 -0
- data/lib/blacklight/configuration/view_config.rb +16 -10
- data/lib/blacklight/configuration.rb +322 -341
- data/lib/blacklight/engine.rb +13 -15
- data/lib/blacklight/exceptions.rb +2 -2
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +6 -12
- data/lib/blacklight/open_struct_with_hash_access.rb +19 -17
- data/lib/blacklight/parameters.rb +7 -21
- data/lib/blacklight/routes/exportable.rb +1 -0
- data/lib/blacklight/routes/searchable.rb +3 -1
- data/lib/blacklight/routes.rb +1 -0
- data/lib/blacklight/search_builder.rb +10 -10
- data/lib/blacklight/search_state/filter_field.rb +8 -25
- data/lib/blacklight/search_state/pivot_filter_field.rb +144 -0
- data/lib/blacklight/search_state.rb +23 -79
- data/lib/blacklight/solr/document.rb +1 -0
- data/lib/blacklight/solr/facet_paginator.rb +1 -0
- data/lib/blacklight/solr/repository.rb +1 -0
- data/lib/blacklight/solr/request.rb +3 -0
- data/lib/blacklight/solr/response/facets.rb +21 -5
- data/lib/blacklight/solr/response/group.rb +1 -0
- data/lib/blacklight/solr/response/group_response.rb +1 -0
- data/lib/blacklight/solr/response/more_like_this.rb +1 -0
- data/lib/blacklight/solr/response/pagination_methods.rb +4 -3
- data/lib/blacklight/solr/response/params.rb +5 -4
- data/lib/blacklight/solr/response/response.rb +1 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/blacklight/solr/response.rb +4 -3
- data/lib/blacklight/solr/search_builder_behavior.rb +16 -32
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/blacklight.rb +8 -11
- data/lib/generators/blacklight/assets/importmap_generator.rb +56 -0
- data/lib/generators/blacklight/assets/propshaft_generator.rb +34 -0
- data/lib/generators/blacklight/assets/sprockets_generator.rb +68 -0
- data/lib/generators/blacklight/assets_generator.rb +14 -88
- data/lib/generators/blacklight/controller_generator.rb +3 -2
- data/lib/generators/blacklight/document_generator.rb +1 -0
- data/lib/generators/blacklight/install_generator.rb +7 -4
- data/lib/generators/blacklight/models_generator.rb +1 -0
- data/lib/generators/blacklight/search_builder_generator.rb +1 -0
- data/lib/generators/blacklight/solr_generator.rb +1 -1
- data/lib/generators/blacklight/templates/catalog_controller.rb +37 -7
- data/lib/generators/blacklight/templates/solr_document.rb +1 -7
- data/lib/generators/blacklight/test_support_generator.rb +4 -2
- data/lib/generators/blacklight/user_generator.rb +7 -9
- data/lib/railties/blacklight.rake +2 -3
- data/package.json +10 -10
- data/rollup.config.js +37 -0
- data/spec/components/blacklight/constraints_component_spec.rb +17 -13
- data/spec/components/blacklight/document_component_spec.rb +74 -33
- data/spec/components/blacklight/facet_component_spec.rb +2 -7
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +1 -2
- data/spec/components/blacklight/facet_field_list_component_spec.rb +7 -6
- data/spec/components/blacklight/facet_item_pivot_component_spec.rb +9 -7
- data/spec/components/blacklight/header_component_spec.rb +20 -0
- data/spec/components/blacklight/response/view_type_component_spec.rb +83 -0
- data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
- data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +29 -0
- data/spec/components/blacklight/search_context/server_item_pagination_component_spec.rb +51 -0
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -6
- data/spec/controllers/blacklight/{base_spec.rb → catalog_spec.rb} +2 -2
- data/spec/controllers/bookmarks_controller_spec.rb +2 -3
- data/spec/controllers/catalog_controller_spec.rb +24 -126
- data/spec/features/autocomplete_spec.rb +1 -1
- data/spec/features/axe_spec.rb +1 -1
- data/spec/features/bookmarks_spec.rb +1 -1
- data/spec/features/component_template_override_spec.rb +8 -0
- data/spec/features/facets_spec.rb +1 -1
- data/spec/features/modal_spec.rb +12 -0
- data/spec/features/search_context_spec.rb +4 -10
- data/spec/features/search_results_spec.rb +0 -33
- data/spec/features/sitelinks_search_box_spec.rb +13 -0
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +2 -138
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +0 -387
- data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +8 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +5 -7
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +10 -132
- data/spec/helpers/blacklight_helper_spec.rb +3 -298
- data/spec/helpers/catalog_helper_spec.rb +60 -115
- data/spec/i18n_spec.rb +1 -0
- data/spec/integration/generators/blacklight/solr_generator_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +27 -16
- data/spec/lib/blacklight/configuration/field_spec.rb +1 -1
- data/spec/lib/blacklight/configuration/session_tracking_config_spec.rb +38 -0
- data/spec/lib/blacklight/configuration/view_config_spec.rb +1 -1
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +4 -4
- data/spec/lib/blacklight/parameters_spec.rb +1 -4
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +4 -4
- data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +117 -0
- data/spec/lib/blacklight/search_state_spec.rb +80 -198
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
- data/spec/models/blacklight/configuration_spec.rb +41 -53
- data/spec/models/blacklight/document/active_model_shim_spec.rb +2 -2
- data/spec/models/blacklight/icon_spec.rb +29 -15
- data/spec/models/blacklight/search_builder_spec.rb +12 -12
- data/spec/models/blacklight/solr/document_spec.rb +3 -3
- data/spec/models/blacklight/solr/request_spec.rb +2 -2
- data/spec/models/blacklight/solr/response/facets_spec.rb +27 -27
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
- data/spec/models/blacklight/solr/response_spec.rb +9 -2
- data/spec/models/blacklight/solr/search_builder_spec.rb +32 -23
- data/spec/models/blacklight/user_spec.rb +22 -0
- data/spec/models/record_mailer_spec.rb +36 -23
- data/spec/models/solr_document_spec.rb +21 -3
- data/spec/presenters/blacklight/clause_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/document_presenter_spec.rb +3 -2
- data/spec/presenters/blacklight/facet_field_presenter_spec.rb +85 -12
- data/spec/presenters/blacklight/facet_grouped_item_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/facet_item_presenter_spec.rb +14 -13
- data/spec/presenters/blacklight/field_presenter_spec.rb +2 -16
- data/spec/presenters/blacklight/index_presenter_spec.rb +3 -4
- data/spec/presenters/blacklight/json_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -2
- data/spec/presenters/blacklight/show_presenter_spec.rb +11 -25
- data/spec/presenters/pipeline_spec.rb +13 -2
- data/spec/presenters/thumbnail_presenter_spec.rb +1 -1
- data/spec/requests/load_suggestions_spec.rb +16 -0
- data/spec/routing/catalog_routing_spec.rb +6 -1
- data/spec/services/blacklight/search_service_spec.rb +31 -68
- data/spec/spec_helper.rb +4 -3
- data/spec/support/controller_level_helpers.rb +1 -2
- data/spec/support/features/search_helpers.rb +39 -0
- data/spec/support/features/session_helpers.rb +1 -0
- data/spec/support/features.rb +3 -0
- data/spec/support/view_component_test_helpers.rb +21 -0
- data/spec/test_app_templates/Gemfile.extra +4 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +17 -2
- data/spec/views/catalog/_document.html.erb_spec.rb +23 -33
- data/spec/views/catalog/_document_list.html.erb_spec.rb +7 -2
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +7 -54
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +17 -9
- data/spec/views/catalog/email_success.html.erb_spec.rb +2 -2
- data/spec/views/catalog/facet.html.erb_spec.rb +6 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +18 -11
- data/spec/views/catalog/index.html.erb_spec.rb +5 -6
- data/spec/views/catalog/index.json.jbuilder_spec.rb +3 -3
- data/spec/views/catalog/show.html.erb_spec.rb +3 -25
- data/spec/views/catalog/sms_success.html.erb_spec.rb +2 -2
- data/tasks/blacklight.rake +7 -5
- metadata +95 -123
- data/.babelrc +0 -11
- data/app/assets/images/blacklight/list.svg +0 -1
- data/app/assets/images/blacklight/search.svg +0 -1
- data/app/assets/stylesheets/blacklight/_twitter_typeahead.scss +0 -37
- data/app/components/blacklight/content_areas_shim.rb +0 -13
- data/app/components/blacklight/search_context_component.rb +0 -34
- data/app/controllers/concerns/blacklight/base.rb +0 -7
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +0 -64
- data/app/controllers/concerns/blacklight/facet.rb +0 -69
- data/app/controllers/concerns/blacklight/search_fields.rb +0 -46
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -27
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -188
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -97
- data/app/helpers/blacklight/suggest_helper_behavior.rb +0 -13
- data/app/javascript/blacklight/autocomplete.js +0 -36
- data/app/javascript/blacklight/facet_load.js +0 -22
- data/app/models/concerns/blacklight/document/email.rb +0 -26
- data/app/models/concerns/blacklight/document/sms.rb +0 -24
- data/app/presenters/blacklight/search_bar_presenter.rb +0 -47
- data/app/views/catalog/_constraints_element.html.erb +0 -14
- data/app/views/catalog/_document_action.html.erb +0 -5
- data/app/views/catalog/_facet_group.html.erb +0 -5
- data/app/views/catalog/_facet_limit.html.erb +0 -3
- data/app/views/catalog/_index.html.erb +0 -1
- data/app/views/catalog/_index_header.html.erb +0 -22
- data/app/views/catalog/_previous_next_doc.html.erb +0 -2
- data/app/views/catalog/_show.html.erb +0 -6
- data/app/views/catalog/_show_header.html.erb +0 -2
- data/app/views/catalog/_thumbnail.html.erb +0 -1
- data/lib/blacklight/deprecations/engine_configuration.rb +0 -66
- data/lib/blacklight/deprecations/search_state_normalization.rb +0 -52
- data/spec/controllers/blacklight/facet_spec.rb +0 -33
- data/spec/controllers/blacklight/search_fields_spec.rb +0 -62
- data/spec/features/sitelinks_search_box.rb +0 -13
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +0 -26
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +0 -92
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +0 -108
- data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +0 -48
- data/spec/lib/blacklight/engine_spec.rb +0 -41
- data/spec/models/blacklight/document/email_spec.rb +0 -57
- data/spec/models/blacklight/document/sms_spec.rb +0 -58
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +0 -94
- data/spec/support/view_component_capybara_test_helpers.rb +0 -8
- data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
- data/spec/views/catalog/_facet_group.html.erb_spec.rb +0 -84
- data/spec/views/catalog/_facets.html.erb_spec.rb +0 -15
- data/spec/views/catalog/_index.html.erb_spec.rb +0 -62
- data/spec/views/catalog/_index_header.html.erb_spec.rb +0 -35
- data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +0 -22
- data/spec/views/catalog/_show.html.erb_spec.rb +0 -62
- data/spec/views/catalog/_thumbnail.html.erb_spec.rb +0 -38
- /data/app/components/blacklight/{search_context_component.html.erb → search_context/server_item_pagination_component.html.erb} +0 -0
|
@@ -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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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)
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
url,
|
|
4
|
-
id: @id,
|
|
5
|
-
class: @link_classes,
|
|
6
|
-
data: {}.merge(({ blacklight_modal: "trigger", turbo: false } if @action.modal != false) || {}) %>
|
|
7
|
-
<% else %>
|
|
8
|
-
<%= helpers.render(partial: @action.partial || @action.name.to_s, locals: { document: @document, document_action_config: @action }.merge(@options)) %>
|
|
9
|
-
<% end %>
|
|
1
|
+
<%# We keep this template around so that downstream applications can override the template if desired %>
|
|
2
|
+
<%= render_control %>
|
|
@@ -16,17 +16,30 @@ module Blacklight
|
|
|
16
16
|
@link_classes = link_classes
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def render_control
|
|
20
|
+
return link_to_modal_control if using_default_document_action?
|
|
21
|
+
|
|
22
|
+
render_partial
|
|
23
|
+
end
|
|
24
|
+
|
|
19
25
|
def using_default_document_action?
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
@action.component || @action.partial == 'document_action'
|
|
27
|
+
end
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
def link_to_modal_control
|
|
30
|
+
link_to label,
|
|
31
|
+
url,
|
|
32
|
+
id: @id,
|
|
33
|
+
class: @link_classes,
|
|
34
|
+
data: {}.merge(({ blacklight_modal: "trigger", turbo: false } if @action.modal != false) || {})
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def render_partial
|
|
38
|
+
helpers.render(partial: @action.partial || @action.name.to_s, locals: { document: @document, document_action_config: @action }.merge(@options))
|
|
24
39
|
end
|
|
25
40
|
|
|
26
41
|
def label
|
|
27
|
-
|
|
28
|
-
helpers.document_action_label(@action.name, @action)
|
|
29
|
-
end
|
|
42
|
+
t("blacklight.tools.#{@action.name}", default: @action.label || @action.name.to_s.humanize)
|
|
30
43
|
end
|
|
31
44
|
|
|
32
45
|
# Action buttons get their URLs in one of three ways:
|
|
@@ -37,8 +50,13 @@ module Blacklight
|
|
|
37
50
|
# default Rails routing behavior)
|
|
38
51
|
# - calling out to an implicit helper method with a conventional name (unlikely)
|
|
39
52
|
def url
|
|
40
|
-
|
|
41
|
-
|
|
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)
|
|
42
60
|
end
|
|
43
61
|
end
|
|
44
62
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Blacklight
|
|
4
4
|
module Document
|
|
5
|
-
# Render a
|
|
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
|
-
|
|
31
|
+
with_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::
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
22
|
-
helpers.
|
|
23
|
-
|
|
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,12 @@
|
|
|
1
|
+
<div class="card show-tools">
|
|
2
|
+
<div class="card-header">
|
|
3
|
+
<h2 class="mb-0 h6"><%= t('blacklight.tools.title') %></h2>
|
|
4
|
+
</div>
|
|
5
|
+
<%= render Blacklight::Document::ActionsComponent.new(document: document,
|
|
6
|
+
tag: 'ul',
|
|
7
|
+
classes: 'list-group list-group-flush',
|
|
8
|
+
wrapping_tag: 'li',
|
|
9
|
+
wrapping_classes: 'list-group-item list-group-item-action',
|
|
10
|
+
actions: actions,
|
|
11
|
+
url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h)) %>
|
|
12
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Document
|
|
5
|
+
# Render the tools that display on the sidebar of the show page
|
|
6
|
+
class ShowToolsComponent < Blacklight::Component
|
|
7
|
+
# @param [Blacklight::Document] document
|
|
8
|
+
def initialize(document:)
|
|
9
|
+
@document = document
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
attr_reader :document
|
|
13
|
+
|
|
14
|
+
def render?
|
|
15
|
+
helpers.show_doc_actions?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def actions
|
|
19
|
+
helpers.document_actions(document)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -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 =
|
|
1
|
+
<% value = presenter.thumbnail.render(@image_options) %>
|
|
2
2
|
|
|
3
3
|
<% if value %>
|
|
4
4
|
<div class="document-thumbnail">
|
|
5
|
-
|
|
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,
|
|
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
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'view_component/version'
|
|
4
|
+
|
|
3
5
|
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
|
|
4
22
|
class DocumentComponent < Blacklight::Component
|
|
5
|
-
|
|
23
|
+
with_collection_parameter :document
|
|
24
|
+
|
|
25
|
+
# ViewComponent 3 changes iteration counters to begin at 0 rather than 1
|
|
26
|
+
COLLECTION_INDEX_OFFSET = ViewComponent::VERSION::MAJOR < 3 ? 0 : 1
|
|
6
27
|
|
|
7
28
|
# Content appearing before the document
|
|
8
29
|
renders_one :header
|
|
@@ -16,16 +37,17 @@ module Blacklight
|
|
|
16
37
|
|
|
17
38
|
# The document title with some reasonable default behavior
|
|
18
39
|
renders_one :title, (lambda do |*args, component: nil, **kwargs|
|
|
19
|
-
component ||= Blacklight::DocumentTitleComponent
|
|
40
|
+
component ||= @presenter&.view_config&.title_component || Blacklight::DocumentTitleComponent
|
|
20
41
|
|
|
21
|
-
component.new(*args, counter: @counter, document: @document, presenter: @presenter, as: @title_component, link_to_document: !@show, document_component: self, **kwargs)
|
|
42
|
+
component.new(*args, counter: @counter, document: @document, presenter: @presenter, as: @title_component, actions: !@show, link_to_document: !@show, document_component: self, **kwargs)
|
|
22
43
|
end)
|
|
23
44
|
|
|
24
45
|
renders_one :embed, (lambda do |static_content = nil, *args, component: nil, **kwargs|
|
|
25
46
|
next static_content if static_content.present?
|
|
26
|
-
next unless component
|
|
27
47
|
|
|
28
|
-
|
|
48
|
+
component ||= @presenter.view_config&.embed_component
|
|
49
|
+
|
|
50
|
+
next unless component
|
|
29
51
|
|
|
30
52
|
component.new(*args, document: @document, presenter: @presenter, document_counter: @document_counter, **kwargs)
|
|
31
53
|
end)
|
|
@@ -34,9 +56,7 @@ module Blacklight
|
|
|
34
56
|
renders_one :metadata, (lambda do |static_content = nil, *args, component: nil, fields: nil, **kwargs|
|
|
35
57
|
next static_content if static_content.present?
|
|
36
58
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
component ||= Blacklight::DocumentMetadataComponent
|
|
59
|
+
component ||= @presenter&.view_config&.metadata_component || Blacklight::DocumentMetadataComponent
|
|
40
60
|
|
|
41
61
|
component.new(*args, fields: fields || @presenter&.field_presenters || [], **kwargs)
|
|
42
62
|
end)
|
|
@@ -48,7 +68,6 @@ module Blacklight
|
|
|
48
68
|
next image_options_or_static_content if image_options_or_static_content.is_a? String
|
|
49
69
|
|
|
50
70
|
component ||= @presenter&.view_config&.thumbnail_component || Blacklight::Document::ThumbnailComponent
|
|
51
|
-
Deprecation.warn(Blacklight::DocumentComponent, 'Pass the presenter to the DocumentComponent') if !component && @presenter.nil?
|
|
52
71
|
|
|
53
72
|
component.new(*args, document: @document, presenter: @presenter, counter: @counter, image_options: image_options_or_static_content, **kwargs)
|
|
54
73
|
end)
|
|
@@ -60,50 +79,36 @@ module Blacklight
|
|
|
60
79
|
# Backwards compatibility
|
|
61
80
|
renders_one :actions
|
|
62
81
|
|
|
63
|
-
with_collection_parameter :document
|
|
64
|
-
|
|
65
82
|
# rubocop:disable Metrics/ParameterLists
|
|
66
|
-
# @param document [Blacklight::
|
|
67
|
-
# @param presenter [Blacklight::DocumentPresenter]
|
|
83
|
+
# @param document [Blacklight::DocumentPresenter]
|
|
84
|
+
# @param presenter [Blacklight::DocumentPresenter] alias for document
|
|
85
|
+
# @param partials [Array, nil] view partial names that should be used to provide content for the `partials` slot
|
|
68
86
|
# @param id [String] HTML id for the root element
|
|
69
87
|
# @param classes [Array, String] additional HTML classes for the root element
|
|
70
88
|
# @param component [Symbol, String] HTML tag type to use for the root element
|
|
71
89
|
# @param title_component [Symbol, String] HTML tag type to use for the title element
|
|
72
90
|
# @param counter [Number, nil] a pre-computed counter for the position of this document in a search result set
|
|
73
|
-
# @param document_counter [Number, nil]
|
|
74
|
-
# @param counter_offset [Number]
|
|
91
|
+
# @param document_counter [Number, nil] provided by ViewComponent collection iteration
|
|
92
|
+
# @param counter_offset [Number] the offset of the start of the collection counter parameter for the component to the overall result set
|
|
75
93
|
# @param show [Boolean] are we showing only a single document (vs a list of search results); used for backwards-compatibility
|
|
76
|
-
def initialize(document: nil, presenter: nil,
|
|
94
|
+
def initialize(document: nil, presenter: nil, partials: nil,
|
|
77
95
|
id: nil, classes: [], component: :article, title_component: nil,
|
|
78
|
-
metadata_component: nil,
|
|
79
|
-
embed_component: nil,
|
|
80
|
-
thumbnail_component: nil,
|
|
81
96
|
counter: nil, document_counter: nil, counter_offset: 0,
|
|
82
|
-
show: false)
|
|
83
|
-
|
|
84
|
-
raise ArgumentError, 'missing keyword: :document or :presenter'
|
|
85
|
-
end
|
|
97
|
+
show: false, **args)
|
|
98
|
+
Blacklight.deprecation.warn('the `presenter` argument to DocumentComponent#initialize is deprecated; pass the `presenter` in as document instead') if presenter
|
|
86
99
|
|
|
87
|
-
@
|
|
88
|
-
@
|
|
100
|
+
@presenter = presenter || document || args[self.class.collection_parameter]
|
|
101
|
+
@document = @presenter.document
|
|
102
|
+
@view_partials = partials || []
|
|
89
103
|
|
|
90
104
|
@component = component
|
|
91
105
|
@title_component = title_component
|
|
92
106
|
@id = id || ('document' if show)
|
|
93
107
|
@classes = classes
|
|
94
108
|
|
|
95
|
-
Deprecation.warn(Blacklight::DocumentComponent, 'Passing embed_component is deprecated') if @embed_component.present?
|
|
96
|
-
@embed_component = embed_component
|
|
97
|
-
|
|
98
|
-
Deprecation.warn(Blacklight::DocumentComponent, 'Passing metadata_component is deprecated') if @metadata_component.present?
|
|
99
|
-
@metadata_component = metadata_component || Blacklight::DocumentMetadataComponent
|
|
100
|
-
|
|
101
|
-
Deprecation.warn(Blacklight::DocumentComponent, 'Passing thumbnail_component is deprecated') if @thumbnail_component.present?
|
|
102
|
-
@thumbnail_component = thumbnail_component || Blacklight::Document::ThumbnailComponent
|
|
103
|
-
|
|
104
|
-
@document_counter = document_counter
|
|
105
109
|
@counter = counter
|
|
106
|
-
@
|
|
110
|
+
@document_counter = document_counter || args.fetch(self.class.collection_counter_parameter, nil)
|
|
111
|
+
@counter ||= @document_counter + COLLECTION_INDEX_OFFSET + counter_offset if @document_counter.present?
|
|
107
112
|
|
|
108
113
|
@show = show
|
|
109
114
|
end
|
|
@@ -121,16 +126,23 @@ module Blacklight
|
|
|
121
126
|
|
|
122
127
|
def before_render
|
|
123
128
|
set_slot(:title, nil) unless title
|
|
124
|
-
set_slot(:thumbnail, nil
|
|
125
|
-
set_slot(:metadata, nil,
|
|
126
|
-
set_slot(:embed, nil
|
|
129
|
+
set_slot(:thumbnail, nil) unless thumbnail || show?
|
|
130
|
+
set_slot(:metadata, nil, fields: presenter.field_presenters) unless metadata
|
|
131
|
+
set_slot(:embed, nil) unless embed
|
|
132
|
+
if view_partials.present?
|
|
133
|
+
view_partials.each do |view_partial|
|
|
134
|
+
with_partial(view_partial) do
|
|
135
|
+
helpers.render_document_partial @document, view_partial, component: self, document_counter: @counter
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
else
|
|
139
|
+
set_slot(:partials, nil)
|
|
140
|
+
end
|
|
127
141
|
end
|
|
128
142
|
|
|
129
143
|
private
|
|
130
144
|
|
|
131
|
-
|
|
132
|
-
@presenter ||= helpers.document_presenter(@document)
|
|
133
|
-
end
|
|
145
|
+
attr_reader :document_counter, :presenter, :view_partials
|
|
134
146
|
|
|
135
147
|
def show?
|
|
136
148
|
@show
|
|
@@ -3,21 +3,28 @@
|
|
|
3
3
|
module Blacklight
|
|
4
4
|
class DocumentMetadataComponent < Blacklight::Component
|
|
5
5
|
renders_many :fields, (lambda do |component: nil, **kwargs|
|
|
6
|
-
|
|
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
|
-
|
|
11
|
+
# rubocop:disable Metrics/ParameterLists
|
|
12
|
+
def initialize(fields: [], tag: 'dl', classes: %w[document-metadata dl-invert row], show: false, view_type: nil, field_layout: nil, **component_args)
|
|
12
13
|
@fields = fields
|
|
14
|
+
@tag = tag
|
|
15
|
+
@classes = classes
|
|
13
16
|
@show = show
|
|
17
|
+
@view_type = view_type
|
|
18
|
+
@field_layout = field_layout
|
|
19
|
+
@component_args = component_args
|
|
14
20
|
end
|
|
21
|
+
# rubocop:enable Metrics/ParameterLists
|
|
15
22
|
|
|
16
23
|
def before_render
|
|
17
24
|
return unless fields
|
|
18
25
|
|
|
19
26
|
@fields.each do |field|
|
|
20
|
-
|
|
27
|
+
with_field(component: field.component, field: field, show: @show, view_type: @view_type, layout: @field_layout)
|
|
21
28
|
end
|
|
22
29
|
end
|
|
23
30
|
|
|
@@ -25,8 +32,6 @@ module Blacklight
|
|
|
25
32
|
fields.present?
|
|
26
33
|
end
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
field&.component || Blacklight::MetadataFieldComponent
|
|
30
|
-
end
|
|
35
|
+
attr_reader :view_type
|
|
31
36
|
end
|
|
32
37
|
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 ||
|
|
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.
|
|
2
|
+
<% component.with_label do %>
|
|
3
3
|
<%= @facet_field.label %>
|
|
4
4
|
<% end %>
|
|
5
5
|
|
|
6
|
-
<% component.
|
|
6
|
+
<% component.with_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
|
|
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>
|