blacklight 7.31.0 → 7.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/assets/stylesheets/blacklight/_controls.scss +5 -12
  4. data/app/assets/stylesheets/blacklight/_facets.scss +24 -0
  5. data/app/assets/stylesheets/blacklight/_header.scss +4 -7
  6. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +2 -0
  7. data/app/components/blacklight/constraint_component.html.erb +1 -1
  8. data/app/components/blacklight/search_bar_component.html.erb +6 -7
  9. data/app/components/blacklight/search_bar_component.rb +6 -1
  10. data/app/components/blacklight/search_button_component.rb +17 -0
  11. data/app/controllers/concerns/blacklight/bookmarks.rb +3 -5
  12. data/app/helpers/blacklight/component_helper_behavior.rb +10 -12
  13. data/app/models/concerns/blacklight/document.rb +7 -0
  14. data/app/presenters/blacklight/clause_presenter.rb +4 -0
  15. data/app/presenters/blacklight/document_presenter.rb +5 -0
  16. data/app/presenters/blacklight/facet_item_presenter.rb +8 -0
  17. data/app/views/catalog/index.json.jbuilder +2 -0
  18. data/app/views/catalog/show.json.jbuilder +2 -0
  19. data/app/views/layouts/blacklight/base.html.erb +5 -2
  20. data/blacklight.gemspec +1 -1
  21. data/lib/blacklight/component.rb +20 -0
  22. data/package.json +1 -2
  23. data/spec/components/blacklight/search_bar_component_spec.rb +82 -0
  24. data/spec/controllers/catalog_controller_spec.rb +2 -2
  25. data/spec/features/bookmarks_spec.rb +9 -0
  26. data/spec/helpers/catalog_helper_spec.rb +1 -1
  27. data/spec/models/blacklight/suggest_search_spec.rb +1 -1
  28. data/spec/models/solr_document_spec.rb +11 -0
  29. data/spec/presenters/blacklight/document_presenter_spec.rb +6 -0
  30. data/spec/presenters/blacklight/facet_item_presenter_spec.rb +7 -0
  31. data/spec/views/catalog/index.json.jbuilder_spec.rb +3 -17
  32. data/spec/views/catalog/show.json.jbuilder_spec.rb +2 -9
  33. metadata +8 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7693f7aa372d8e623d9cb996089c4a04bff5ea462b119263efbceec482f0085
4
- data.tar.gz: e2c3b9c56f6158c05b97685cfebbc3dc38fbdee1052cd8b5c3e432900cbec35d
3
+ metadata.gz: cddd27d147401ca52ab08c98094933b5327eff0fb3e160eaa960975a9697246f
4
+ data.tar.gz: f714a77235467a6088f021d4b44e2d1826a407a5cf922eb53d78ac163a470f6a
5
5
  SHA512:
6
- metadata.gz: b0e155b0bf0fa6f5b8c15ef317bb05198b91e871187a8f8fc846894f182e3a2883ae07caa9c3eceaa676a1b45ce94f34bd73e9d9a4b97ce55eb2da15d5c4ab6f
7
- data.tar.gz: 69adc6ec4c6402a555bcf2f970adfb692ea5b9a5422375050f787b494d0f62d371859198db14d45373416d10743ee1759162900c25840994481edebd618527c6
6
+ metadata.gz: ab11dc139997c5398b1c83cc72ddf1142598bf3e50f8bdca34d2e74fb7e9159b209237ad11a60cc23fe8313eab0436f03615e81ae204480a2552173d24b967d8
7
+ data.tar.gz: 7a1b670887503b620af4b36ce44504c155f494b3d1c1e35ed57d8f90471c7e7aeb1be5fb815d383baf98de89d2924ec481a2ba4c3567b9a0ed222f02a47f5596
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.31.0
1
+ 7.33.0
@@ -23,19 +23,12 @@
23
23
  cursor: pointer;
24
24
  }
25
25
 
26
- .no-js .sort-pagination {
27
- & {
28
- @extend .clearfix;
26
+ .no-js {
27
+ .btn-group:focus-within {
28
+ .dropdown-menu {
29
+ @extend .show;
30
+ }
29
31
  }
30
- .dropdown-menu {
31
- background: none;
32
- box-shadow: none;
33
- border: none;
34
- position: relative;
35
- display: block;
36
- float: none;
37
- }
38
-
39
32
  }
40
33
 
41
34
  .view-type {
@@ -37,6 +37,30 @@
37
37
  }
38
38
  }
39
39
 
40
+ .no-js {
41
+ @include media-breakpoint-down(lg) {
42
+ #sidebar {
43
+ order: 6 !important;
44
+ }
45
+ }
46
+
47
+ .facet-content.collapse {
48
+ display: block;
49
+ }
50
+
51
+ .facet-toggle-handle {
52
+ display: none;
53
+ }
54
+
55
+ .pivot-facet.collapse {
56
+ display: block;
57
+ }
58
+
59
+ .facets-collapse.collapse {
60
+ display: block;
61
+ }
62
+ }
63
+
40
64
  .facets-header {
41
65
  display: flex;
42
66
  justify-content: space-between;
@@ -12,19 +12,16 @@
12
12
  .navbar-logo { /* The main logo image for the Blacklight instance */
13
13
  @if $logo-image {
14
14
  background: transparent $logo-image no-repeat top left;
15
+ background-size: $logo-width $logo-height;
15
16
  }
16
-
17
17
  display: inline-block;
18
- flex: 0 0 150px;
19
- height: 50px;
20
- margin-right:20px;
18
+ height: $logo-height;
19
+ margin-right: 20px;
21
20
  margin-top: -0.4rem;
22
21
  overflow: hidden;
23
- padding-left: 0;
24
- padding-right: 0;
25
22
  text-indent: 100%;
26
23
  white-space: nowrap;
27
- width: 150px;
24
+ width: $logo-width;
28
25
  }
29
26
 
30
27
  .navbar-search {
@@ -1,6 +1,8 @@
1
1
  /* Warning! If you want to change these, just copy them into your own theme css. But you want to remove the !default, which only will set them if not already set. */
2
2
 
3
3
  $logo-image: image_url('blacklight/logo.png') !default;
4
+ $logo-width: 150px !default;
5
+ $logo-height: 50px !default;
4
6
 
5
7
  /* label (field names) */
6
8
  $field_name_color: $text-muted !default;
@@ -1,5 +1,5 @@
1
1
  <%= render(@layout.new(
2
2
  classes: (Array(@classes) + ["filter-#{@facet_item_presenter.key.parameterize}"]).join(' '),
3
3
  label: @facet_item_presenter.field_label,
4
- value: @facet_item_presenter.label,
4
+ value: @facet_item_presenter.constraint_label,
5
5
  remove_path: @facet_item_presenter.remove_href)) %>
@@ -1,8 +1,11 @@
1
- <%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => scoped_t('submit') do %>
1
+ <%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', aria: { label: scoped_t('submit') }, **@form_options do %>
2
2
  <%= render_hash_as_hidden_fields(@params) %>
3
3
  <% if search_fields.length > 1 %>
4
4
  <label for="search_field" class="sr-only visually-hidden"><%= scoped_t('search_field.label') %></label>
5
5
  <% end %>
6
+ <% before_input_groups.each do |input_group| %>
7
+ <%= input_group %>
8
+ <% end %>
6
9
  <div class="input-group">
7
10
  <%= prepend %>
8
11
 
@@ -17,15 +20,11 @@
17
20
  <% end %>
18
21
 
19
22
  <label for="<%= @prefix %><%= @query_param %>" class="sr-only visually-hidden"><%= scoped_t('search.label') %></label>
20
- <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: autocomplete_path.present? ? "off" : "", autofocus: @autofocus, data: { autocomplete_enabled: autocomplete_path.present?, autocomplete_path: autocomplete_path } %>
23
+ <%= text_field_tag @query_param, @q, placeholder: scoped_t('search.placeholder'), class: "search-q q form-control rounded-#{search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: autocomplete_path.present? ? "off" : "", autofocus: @autofocus, aria: { label: scoped_t('search.label') }, data: { autocomplete_enabled: autocomplete_path.present?, autocomplete_path: autocomplete_path } %>
21
24
 
22
25
  <span class="input-group-append">
23
26
  <%= append %>
24
-
25
- <button type="submit" class="btn btn-primary search-btn" id="<%= @prefix %>search">
26
- <span class="submit-search-text"><%= scoped_t('submit') %></span>
27
- <%= blacklight_icon :search, aria_hidden: true %>
28
- </button>
27
+ <%= search_button || render(Blacklight::SearchButtonComponent.new(id: "#{@prefix}search", text: scoped_t('submit'))) %>
29
28
  </span>
30
29
  </div>
31
30
  <% end %>
@@ -6,6 +6,8 @@ module Blacklight
6
6
 
7
7
  renders_one :append
8
8
  renders_one :prepend
9
+ renders_one :search_button
10
+ renders_many :before_input_groups
9
11
 
10
12
  # rubocop:disable Metrics/ParameterLists
11
13
  def initialize(
@@ -14,7 +16,8 @@ module Blacklight
14
16
  classes: ['search-query-form'], prefix: nil,
15
17
  method: 'GET', q: nil, query_param: :q,
16
18
  search_field: nil, search_fields: nil, autocomplete_path: nil,
17
- autofocus: nil, i18n: { scope: 'blacklight.search.form' }
19
+ autofocus: nil, i18n: { scope: 'blacklight.search.form' },
20
+ form_options: {}
18
21
  )
19
22
  @url = url
20
23
  @advanced_search_url = advanced_search_url
@@ -29,6 +32,8 @@ module Blacklight
29
32
  @autofocus = autofocus
30
33
  @search_fields = search_fields
31
34
  @i18n = i18n
35
+ @form_options = form_options
36
+
32
37
  return if presenter.nil?
33
38
 
34
39
  Deprecation.warn(self, 'SearchBarComponent no longer uses a SearchBarPresenter, the presenter: param will be removed in 8.0. ' \
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Blacklight
4
+ class SearchButtonComponent < ::ViewComponent::Base
5
+ def initialize(text:, id:)
6
+ @text = text
7
+ @id = id
8
+ end
9
+
10
+ def call
11
+ tag.button(class: 'btn btn-primary search-btn', type: 'submit', id: @id) do
12
+ tag.span(@text, class: "submit-search-text") +
13
+ blacklight_icon(:search, aria_hidden: true)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -58,11 +58,9 @@ module Blacklight::Bookmarks
58
58
  create
59
59
  end
60
60
 
61
- # For adding a single bookmark, suggest use PUT/#update to
62
- # /bookmarks/$docuemnt_id instead.
63
- # But this method, accessed via POST to /bookmarks, can be used for
64
- # creating multiple bookmarks at once, by posting with keys
65
- # such as bookmarks[n][document_id], bookmarks[n][title].
61
+ # For adding a single bookmark, suggest use PUT to /bookmarks/:document_id instead (triggering the #update method).
62
+ # This method, accessed via POST to /bookmarks, can be used for creating multiple bookmarks at once, by posting
63
+ # with keys such as bookmarks[n][document_id], bookmarks[n][title].
66
64
  # It can also be used for creating a single bookmark by including keys
67
65
  # bookmark[title] and bookmark[document_id], but in that case #update
68
66
  # is simpler.
@@ -38,28 +38,26 @@ module Blacklight
38
38
  # (normally renders next to title in the list view)
39
39
  #
40
40
  # @param [SolrDocument] document
41
- # @param [Hash] options
42
- # @option options [String] :wrapping_class
41
+ # @param [String] wrapping_class ("index-document-functions")
42
+ # @param [Class] component (Blacklight::Document::ActionsComponent)
43
43
  # @return [String]
44
- def render_index_doc_actions(document, options = {})
45
- actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge(options)).map { |_k, v| v }
46
- wrapping_class = options.delete(:wrapping_class) || "index-document-functions"
44
+ def render_index_doc_actions(document, wrapping_class: "index-document-functions", component: Blacklight::Document::ActionsComponent)
45
+ actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }).map { |_k, v| v }
47
46
 
48
- render(Blacklight::Document::ActionsComponent.new(document: document, actions: actions, options: options, classes: wrapping_class))
47
+ render(component.new(document: document, actions: actions, classes: wrapping_class))
49
48
  end
50
49
 
51
50
  ##
52
51
  # Render "collection actions" area for search results view
53
52
  # (normally renders next to pagination at the top of the result set)
54
53
  #
55
- # @param [Hash] options
56
- # @option options [String] :wrapping_class
54
+ # @param [String] wrapping_class ("search-widgets")
55
+ # @param [Class] component (Blacklight::Document::ActionsComponent)
57
56
  # @return [String]
58
- def render_results_collection_tools(options = {})
59
- actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, options).map { |_k, v| v }
60
- wrapping_class = options.delete(:wrapping_class) || "search-widgets"
57
+ def render_results_collection_tools(wrapping_class: "search-widgets", component: Blacklight::Document::ActionsComponent)
58
+ actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, {}).map { |_k, v| v }
61
59
 
62
- render(Blacklight::Document::ActionsComponent.new(actions: actions, options: options, classes: wrapping_class))
60
+ render(component.new(actions: actions, classes: wrapping_class))
63
61
  end
64
62
 
65
63
  ##
@@ -26,6 +26,8 @@ module Blacklight::Document
26
26
  extend ActiveModel::Naming
27
27
  include Blacklight::Document::Extensions
28
28
  include GlobalID::Identification
29
+
30
+ class_attribute :inspector_fields, default: [:_source]
29
31
  end
30
32
 
31
33
  attr_reader :response, :_source
@@ -82,6 +84,11 @@ module Blacklight::Document
82
84
  Array(self[key]).first
83
85
  end
84
86
 
87
+ def inspect
88
+ fields = inspector_fields.map { |field| "#{field}: #{public_send(field)}" }.join(", ")
89
+ "#<#{self.class.name}:#{object_id} #{fields}>"
90
+ end
91
+
85
92
  def to_partial_path
86
93
  'catalog/document'
87
94
  end
@@ -24,6 +24,10 @@ module Blacklight
24
24
  user_parameters[:query]
25
25
  end
26
26
 
27
+ def constraint_label
28
+ label
29
+ end
30
+
27
31
  def remove_href(path = search_state)
28
32
  view_context.search_action_path(path.reset_search(clause: path.clause_params.except(key)).to_h)
29
33
  end
@@ -125,6 +125,11 @@ module Blacklight
125
125
  configuration.view_config(:show)
126
126
  end
127
127
 
128
+ def inspect
129
+ fields = "document:#{document.inspect}"
130
+ "#<#{self.class.name}:#{object_id} #{fields}>"
131
+ end
132
+
128
133
  private
129
134
 
130
135
  def render_field?(field_config)
@@ -66,6 +66,14 @@ module Blacklight
66
66
  end
67
67
  end
68
68
 
69
+ # Get the displayable version of the facet's value for use
70
+ # in e.g. the constraints widget
71
+ #
72
+ # @return [String]
73
+ def constraint_label
74
+ label
75
+ end
76
+
69
77
  def value
70
78
  if facet_item.respond_to? :value
71
79
  facet_item.value
@@ -17,6 +17,8 @@ json.data do
17
17
  json.id document.id
18
18
  json.type doc_presenter.display_type.first
19
19
  json.attributes do
20
+ json.title doc_presenter.heading unless doc_presenter.fields_to_render.any? { |field_name, _field, _field_presenter| field_name.to_s == 'title' }
21
+
20
22
  doc_presenter.fields_to_render.each do |field_name, field, field_presenter|
21
23
  json.partial! 'field', field: field,
22
24
  field_name: field_name,
@@ -11,6 +11,8 @@ json.data do
11
11
  json.id @document.id
12
12
  json.type doc_presenter.display_type.first
13
13
  json.attributes do
14
+ json.title doc_presenter.heading unless doc_presenter.fields_to_render.any? { |field_name, _field, _field_presenter| field_name.to_s == 'title' }
15
+
14
16
  doc_presenter.fields_to_render.each do |field_name, field, field_presenter|
15
17
  json.partial! 'field', field: field,
16
18
  field_name: field_name,
@@ -9,10 +9,13 @@
9
9
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
10
10
 
11
11
  <title><%= render_page_title %></title>
12
+ <script>
13
+ document.querySelector('html').classList.remove('no-js');
14
+ </script>
12
15
  <%= opensearch_description_tag application_name, opensearch_catalog_url(format: 'xml') %>
13
16
  <%= favicon_link_tag %>
14
- <%= stylesheet_link_tag "application", media: "all" %>
15
- <%= javascript_include_tag "application" %>
17
+ <%= stylesheet_link_tag "application", media: "all", "data-turbo-track": "reload" %>
18
+ <%= javascript_include_tag "application", "data-turbo-track": "reload" %>
16
19
 
17
20
  <%= csrf_meta_tags %>
18
21
  <%= content_for(:head) %>
data/blacklight.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency "deprecation"
33
33
  s.add_dependency "i18n", '>= 1.7.0' # added named parameters
34
34
  s.add_dependency "ostruct", '>= 0.3.2'
35
- s.add_dependency "view_component", '~> 2.43'
35
+ s.add_dependency "view_component", '~> 2.66'
36
36
  s.add_dependency 'hashdiff'
37
37
 
38
38
  s.add_development_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
@@ -3,6 +3,11 @@
3
3
  module Blacklight
4
4
  class Component < ViewComponent::Base
5
5
  class << self
6
+ # Workaround for https://github.com/ViewComponent/view_component/issues/1565
7
+ def config
8
+ @config ||= ViewComponent::Config.defaults.merge(ViewComponent::Base.config)
9
+ end
10
+
6
11
  # rubocop:disable Naming/MemoizedInstanceVariableName
7
12
  def compiler
8
13
  @__vc_compiler ||= EngineCompiler.new(self)
@@ -12,6 +17,21 @@ module Blacklight
12
17
  alias sidecar_files _sidecar_files unless ViewComponent::Base.respond_to? :sidecar_files
13
18
  end
14
19
 
20
+ EXCLUDE_VARIABLES = [
21
+ :@lookup_context, :@view_renderer, :@view_flow, :@view_context,
22
+ :@tag_builder, :@current_template,
23
+ :@__vc_set_slots, :@__vc_original_view_context,
24
+ :@__vc_variant, :@__vc_content_evaluated,
25
+ :@__vc_render_in_block, :@__vc_content, :@__vc_helpers
26
+ ].freeze
27
+
28
+ def inspect
29
+ # Exclude variables added by render_in
30
+ render_variables = instance_variables - EXCLUDE_VARIABLES
31
+ fields = render_variables.map { |ivar| "#{ivar}:#{instance_variable_get(ivar).inspect}" }.join(', ')
32
+ "#<#{self.class.name}:#{object_id} #{fields}>"
33
+ end
34
+
15
35
  class EngineCompiler < ::ViewComponent::Compiler
16
36
  # ViewComponent::Compiler locates and caches templates from sidecar files to the component source file.
17
37
  # While this is sensible in a Rails application, it prevents component templates defined in an Engine
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "7.25.0",
3
+ "version": "7.32.0",
4
4
  "description": "[![Build Status](https://travis-ci.com/projectblacklight/blacklight.png?branch=main)](https://travis-ci.com/projectblacklight/blacklight) [![Gem Version](https://badge.fury.io/rb/blacklight.png)](http://badge.fury.io/rb/blacklight) [![Coverage Status](https://coveralls.io/repos/github/projectblacklight/blacklight/badge.svg?branch=main)](https://coveralls.io/github/projectblacklight/blacklight?branch=main)",
5
5
  "main": "app/assets/javascripts/blacklight",
6
6
  "scripts": {
@@ -28,7 +28,6 @@
28
28
  },
29
29
  "browserslist": "> 0.25%, not dead",
30
30
  "dependencies": {
31
- "bloodhound-js": "^1.2.3",
32
31
  "bootstrap": ">=4.3.1 <6.0.0",
33
32
  "jquery": "^3.5.1",
34
33
  "typeahead.js": "^0.11.1"
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Blacklight::SearchBarComponent, type: :component do
6
+ let(:instance) { described_class.new(url: search_action_url, params: params_for_search) }
7
+
8
+ let(:search_action_url) { '/catalog' }
9
+ let(:params_for_search) { { q: 'testParamValue' } }
10
+ let(:blacklight_config) do
11
+ Blacklight::Configuration.new.configure do |config|
12
+ config.view = { list: nil, abc: nil }
13
+ end
14
+ end
15
+
16
+ before do
17
+ allow(controller).to receive(:blacklight_config).and_return(blacklight_config)
18
+ end
19
+
20
+ context 'with the default button' do
21
+ subject(:render) { render_inline(instance) }
22
+
23
+ it 'renders the search field and a button' do
24
+ expect(render.css("input[aria-label='#{I18n.t('blacklight.search.form.search.label')}']")).to be_present
25
+ expect(render.css("button#search")).to be_present
26
+ end
27
+ end
28
+
29
+ context 'when a button is passed in' do
30
+ subject(:render) do
31
+ render_inline(instance) do |c|
32
+ c.search_button do
33
+ controller.view_context.tag.button "hello", id: 'custom_search'
34
+ end
35
+ end
36
+ end
37
+
38
+ it 'renders the search field and a button' do
39
+ expect(render.css("input[aria-label='#{I18n.t('blacklight.search.form.search.label')}']")).to be_present
40
+ expect(render.css("button#search")).not_to be_present
41
+ expect(render.css("button#custom_search")).to be_present
42
+ end
43
+ end
44
+
45
+ context 'with prepend' do
46
+ subject(:render) do
47
+ render_inline(instance) do |c|
48
+ c.with_prepend { 'stuff before' }
49
+ end
50
+ end
51
+
52
+ it 'renders the prepended value' do
53
+ expect(render.to_html).to include 'stuff before'
54
+ end
55
+ end
56
+
57
+ context 'with append' do
58
+ subject(:render) do
59
+ render_inline(instance) do |c|
60
+ c.with_append { 'stuff after' }
61
+ end
62
+ end
63
+
64
+ it 'renders the appended value' do
65
+ expect(render.to_html).to include 'stuff after'
66
+ end
67
+ end
68
+
69
+ context 'with extra inputs' do
70
+ subject(:render) do
71
+ render_inline(instance) do |c|
72
+ c.with_before_input_group { controller.view_context.tag.input name: 'foo' }
73
+ c.with_before_input_group { controller.view_context.tag.input name: 'bar' }
74
+ end
75
+ end
76
+
77
+ it 'renders the extra inputs' do
78
+ expect(render.css("input[name='foo']")).to be_present
79
+ expect(render.css("input[name='bar']")).to be_present
80
+ end
81
+ end
82
+ end
@@ -151,7 +151,7 @@ RSpec.describe CatalogController, api: true do
151
151
  it "gets the documents" do
152
152
  expect(docs).to have(10).documents
153
153
  expect(docs.first['attributes'].keys).to match_array(
154
- %w[author_tsim format language_ssim lc_callnum_ssim published_ssim title_tsim]
154
+ %w[author_tsim format language_ssim lc_callnum_ssim published_ssim title title_tsim]
155
155
  )
156
156
  expect(docs.first['links']['self']).to eq solr_document_url(id: docs.first['id'])
157
157
  end
@@ -327,7 +327,7 @@ RSpec.describe CatalogController, api: true do
327
327
  json = JSON.parse response.body
328
328
  expect(json["data"]["attributes"].keys).to match_array(
329
329
  %w[author_tsim format isbn_ssim language_ssim lc_callnum_ssim
330
- published_ssim subtitle_tsim title_tsim url_suppl_ssim]
330
+ published_ssim subtitle_tsim title title_tsim url_suppl_ssim]
331
331
  )
332
332
  end
333
333
  end
@@ -40,6 +40,15 @@ RSpec.describe "Bookmarks" do
40
40
  expect(page).to have_content 'Successfully removed bookmark.'
41
41
  end
42
42
 
43
+ it 'shows bookmarks as checkboxes', js: true do
44
+ visit solr_document_path('2007020969')
45
+ check 'Bookmark'
46
+
47
+ visit solr_document_path('2007020969')
48
+ expect(page).to have_css('input[type="checkbox"]:checked')
49
+ uncheck 'In Bookmarks'
50
+ end
51
+
43
52
  it "adds bookmarks after a user logs in" do
44
53
  visit solr_document_path('2007020969')
45
54
  click_button 'Bookmark'
@@ -243,7 +243,7 @@ RSpec.describe CatalogHelper do
243
243
  end
244
244
 
245
245
  it "calls thumbnail presenter with provided values" do
246
- expect(thumbnail_presenter).to receive(:thumbnail_tag).with({}, suppress_link: true)
246
+ expect(thumbnail_presenter).to receive(:thumbnail_tag).with({}, { suppress_link: true })
247
247
  helper.render_thumbnail_tag document, {}, suppress_link: true
248
248
  end
249
249
  end
@@ -8,7 +8,7 @@ RSpec.describe Blacklight::SuggestSearch, api: true do
8
8
 
9
9
  describe '#suggestions' do
10
10
  it 'delegates to the repository' do
11
- expect(repository).to receive(:suggestions).with(q: 'test').and_return(response)
11
+ expect(repository).to receive(:suggestions).with({ q: 'test' }).and_return(response)
12
12
  expect(suggest_search.suggestions).to eq response
13
13
  end
14
14
  end
@@ -29,6 +29,17 @@ RSpec.describe SolrDocument, api: true do
29
29
  end
30
30
  end
31
31
 
32
+ describe '.inspect' do
33
+ subject(:inspect) { document.inspect }
34
+
35
+ let(:document) do
36
+ described_class.new(id: '123',
37
+ title_tesim: ['Good Omens'])
38
+ end
39
+
40
+ it { is_expected.to end_with "_source: {\"id\"=>\"123\", \"title_tesim\"=>[\"Good Omens\"]}>" }
41
+ end
42
+
32
43
  describe '.attribute' do
33
44
  subject(:title) { document.title }
34
45
 
@@ -60,4 +60,10 @@ RSpec.describe Blacklight::DocumentPresenter do
60
60
  expect(presenter.thumbnail).to be_a_kind_of custom_presenter_class
61
61
  end
62
62
  end
63
+
64
+ describe '#inspect' do
65
+ subject(:inspect) { presenter.inspect }
66
+
67
+ it { is_expected.to start_with '#<Blacklight::DocumentPresenter:' }
68
+ end
63
69
  end
@@ -55,6 +55,13 @@ RSpec.describe Blacklight::FacetItemPresenter, type: :presenter do
55
55
  end
56
56
  end
57
57
 
58
+ describe '#constraint_label' do
59
+ it 'provides the label for the constraint' do
60
+ allow(facet_config).to receive_messages(query: nil, date: nil, helper_method: nil, url_method: nil)
61
+ expect(presenter.constraint_label).to eq presenter.label
62
+ end
63
+ end
64
+
58
65
  describe '#href' do
59
66
  before do
60
67
  allow(search_state).to receive(:has_facet?).and_return(false)
@@ -10,7 +10,7 @@ RSpec.describe "catalog/index.json", api: true do
10
10
  end
11
11
  let(:config) do
12
12
  Blacklight::Configuration.new do |config|
13
- config.add_index_field 'title', label: 'Title', field: 'title_tsim'
13
+ config.index.title_field = 'title_tsim'
14
14
  config.add_facet_field :format
15
15
  end
16
16
  end
@@ -66,14 +66,7 @@ RSpec.describe "catalog/index.json", api: true do
66
66
  id: '123',
67
67
  type: 'Book',
68
68
  attributes: {
69
- 'title': {
70
- id: 'http://test.host/catalog/123#title',
71
- type: 'document_value',
72
- attributes: {
73
- value: 'Book1',
74
- label: 'Title'
75
- }
76
- }
69
+ title: 'Book1'
77
70
  },
78
71
  links: { self: 'http://test.host/catalog/123' }
79
72
  },
@@ -81,14 +74,7 @@ RSpec.describe "catalog/index.json", api: true do
81
74
  id: '456',
82
75
  type: 'Article',
83
76
  attributes: {
84
- 'title': {
85
- id: 'http://test.host/catalog/456#title',
86
- type: 'document_value',
87
- attributes: {
88
- value: 'Article1',
89
- label: 'Title'
90
- }
91
- }
77
+ title: 'Article1'
92
78
  },
93
79
  links: { self: 'http://test.host/catalog/456' }
94
80
  }
@@ -6,7 +6,7 @@ RSpec.describe "catalog/show.json" do
6
6
  end
7
7
  let(:config) do
8
8
  Blacklight::Configuration.new do |config|
9
- config.add_show_field 'title', label: 'Title', field: 'title_tsim'
9
+ config.show.title_field = 'title_tsim'
10
10
  end
11
11
  end
12
12
 
@@ -27,14 +27,7 @@ RSpec.describe "catalog/show.json" do
27
27
  id: '123',
28
28
  type: 'Book',
29
29
  attributes: {
30
- 'title' => {
31
- id: 'http://test.host/catalog/123#title',
32
- type: 'document_value',
33
- attributes: {
34
- value: 'Book1',
35
- label: 'Title'
36
- }
37
- }
30
+ 'title' => 'Book1'
38
31
  }
39
32
  })
40
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.31.0
4
+ version: 7.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: exe
19
19
  cert_chain: []
20
- date: 2022-10-18 00:00:00.000000000 Z
20
+ date: 2022-12-12 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -129,14 +129,14 @@ dependencies:
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '2.43'
132
+ version: '2.66'
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '2.43'
139
+ version: '2.66'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: hashdiff
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -489,6 +489,7 @@ files:
489
489
  - app/components/blacklight/response/view_type_component.rb
490
490
  - app/components/blacklight/search_bar_component.html.erb
491
491
  - app/components/blacklight/search_bar_component.rb
492
+ - app/components/blacklight/search_button_component.rb
492
493
  - app/components/blacklight/search_context_component.html.erb
493
494
  - app/components/blacklight/search_context_component.rb
494
495
  - app/components/blacklight/search_history_constraint_layout_component.rb
@@ -792,6 +793,7 @@ files:
792
793
  - spec/components/blacklight/hidden_search_state_component_spec.rb
793
794
  - spec/components/blacklight/metadata_field_component_spec.rb
794
795
  - spec/components/blacklight/response/spellcheck_component_spec.rb
796
+ - spec/components/blacklight/search_bar_component_spec.rb
795
797
  - spec/components/blacklight/start_over_button_component_spec.rb
796
798
  - spec/components/blacklight/system/flash_message_component_spec.rb
797
799
  - spec/controllers/alternate_controller_spec.rb
@@ -952,7 +954,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
952
954
  - !ruby/object:Gem::Version
953
955
  version: '0'
954
956
  requirements: []
955
- rubygems_version: 3.2.32
957
+ rubygems_version: 3.3.7
956
958
  signing_key:
957
959
  specification_version: 4
958
960
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
@@ -973,6 +975,7 @@ test_files:
973
975
  - spec/components/blacklight/hidden_search_state_component_spec.rb
974
976
  - spec/components/blacklight/metadata_field_component_spec.rb
975
977
  - spec/components/blacklight/response/spellcheck_component_spec.rb
978
+ - spec/components/blacklight/search_bar_component_spec.rb
976
979
  - spec/components/blacklight/start_over_button_component_spec.rb
977
980
  - spec/components/blacklight/system/flash_message_component_spec.rb
978
981
  - spec/controllers/alternate_controller_spec.rb