blacklight 7.33.0 → 7.34.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -0
  3. data/.github/workflows/ruby.yml +21 -1
  4. data/.rubocop.yml +2 -0
  5. data/Gemfile +4 -0
  6. data/VERSION +1 -1
  7. data/app/assets/javascripts/blacklight/blacklight.js +52 -82
  8. data/app/builders/blacklight/action_builder.rb +1 -1
  9. data/app/components/blacklight/advanced_search_form_component.html.erb +1 -1
  10. data/app/components/blacklight/advanced_search_form_component.rb +5 -5
  11. data/app/components/blacklight/content_areas_shim.rb +1 -1
  12. data/app/components/blacklight/document/action_component.html.erb +2 -9
  13. data/app/components/blacklight/document/action_component.rb +18 -0
  14. data/app/components/blacklight/document/actions_component.rb +1 -1
  15. data/app/components/blacklight/document_component.rb +33 -10
  16. data/app/components/blacklight/document_metadata_component.html.erb +4 -2
  17. data/app/components/blacklight/document_metadata_component.rb +6 -2
  18. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -2
  19. data/app/components/blacklight/facet_field_list_component.html.erb +2 -2
  20. data/app/components/blacklight/header_component.html.erb +2 -0
  21. data/app/components/blacklight/header_component.rb +26 -0
  22. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  23. data/app/components/blacklight/metadata_field_layout_component.rb +7 -4
  24. data/app/components/blacklight/response/pagination_component.html.erb +1 -1
  25. data/app/components/blacklight/response/pagination_component.rb +5 -1
  26. data/app/components/blacklight/response/view_type_component.rb +1 -1
  27. data/app/components/blacklight/search_navbar_component.html.erb +5 -0
  28. data/app/components/blacklight/search_navbar_component.rb +34 -0
  29. data/app/components/blacklight/system/dropdown_component.rb +2 -2
  30. data/app/components/blacklight/system/flash_message_component.rb +1 -1
  31. data/app/components/blacklight/top_navbar_component.html.erb +12 -0
  32. data/app/components/blacklight/top_navbar_component.rb +17 -0
  33. data/app/controllers/concerns/blacklight/base.rb +5 -0
  34. data/app/controllers/concerns/blacklight/catalog.rb +4 -1
  35. data/app/controllers/concerns/blacklight/controller.rb +3 -2
  36. data/app/helpers/blacklight/blacklight_helper_behavior.rb +2 -2
  37. data/app/helpers/blacklight/render_partials_helper_behavior.rb +1 -0
  38. data/app/models/concerns/blacklight/document/attributes.rb +50 -0
  39. data/app/models/concerns/blacklight/document.rb +12 -20
  40. data/app/presenters/blacklight/rendering/join.rb +1 -1
  41. data/app/values/blacklight/types.rb +99 -11
  42. data/app/views/catalog/_document.html.erb +1 -1
  43. data/app/views/catalog/_facet_layout.html.erb +2 -2
  44. data/app/views/catalog/_search_form.html.erb +1 -1
  45. data/app/views/catalog/_show_main_content.html.erb +2 -2
  46. data/app/views/catalog/_show_sidebar.html.erb +1 -1
  47. data/app/views/catalog/_show_tools.html.erb +4 -3
  48. data/app/views/catalog/facet.html.erb +3 -3
  49. data/app/views/layouts/blacklight/base.html.erb +7 -7
  50. data/app/views/shared/_header_navbar.html.erb +1 -22
  51. data/blacklight.gemspec +1 -2
  52. data/config/locales/blacklight.en.yml +1 -0
  53. data/docker-compose.yml +1 -0
  54. data/lib/blacklight/configuration.rb +44 -3
  55. data/lib/blacklight/engine.rb +4 -0
  56. data/lib/blacklight/solr/repository.rb +14 -2
  57. data/lib/blacklight/solr/request.rb +2 -0
  58. data/lib/blacklight/solr/search_builder_behavior.rb +2 -1
  59. data/lib/blacklight.rb +1 -1
  60. data/lib/generators/blacklight/assets_generator.rb +1 -1
  61. data/lib/generators/blacklight/install_generator.rb +1 -1
  62. data/lib/generators/blacklight/templates/catalog_controller.rb +4 -0
  63. data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +69 -0
  64. data/lib/generators/blacklight/templates/solr_document.rb +1 -1
  65. data/lib/railties/blacklight.rake +4 -4
  66. data/package.json +2 -2
  67. data/spec/components/blacklight/document_component_spec.rb +60 -11
  68. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +3 -2
  69. data/spec/components/blacklight/header_component_spec.rb +20 -0
  70. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  71. data/spec/controllers/blacklight/base_spec.rb +1 -1
  72. data/spec/controllers/catalog_controller_spec.rb +8 -0
  73. data/spec/features/advanced_search_spec.rb +56 -0
  74. data/spec/features/axe_spec.rb +5 -0
  75. data/spec/features/sitelinks_search_box_spec.rb +13 -0
  76. data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +8 -15
  77. data/spec/models/blacklight/configuration_spec.rb +22 -0
  78. data/spec/models/blacklight/solr/repository_spec.rb +27 -0
  79. data/spec/models/blacklight/solr/search_builder_spec.rb +16 -0
  80. data/spec/models/solr_document_spec.rb +21 -3
  81. data/spec/presenters/blacklight/show_presenter_spec.rb +4 -10
  82. data/spec/spec_helper.rb +4 -5
  83. data/spec/support/view_component_test_helpers.rb +35 -0
  84. data/spec/views/catalog/_show_tools.html.erb_spec.rb +24 -10
  85. metadata +24 -23
  86. data/spec/features/sitelinks_search_box.rb +0 -13
  87. data/spec/support/view_component_capybara_test_helpers.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cddd27d147401ca52ab08c98094933b5327eff0fb3e160eaa960975a9697246f
4
- data.tar.gz: f714a77235467a6088f021d4b44e2d1826a407a5cf922eb53d78ac163a470f6a
3
+ metadata.gz: 65ccb9085e62a93389eab98519e5cb673b61d8fc3c6e973a2810e4ac66a87cf1
4
+ data.tar.gz: 56e423a036a4e82382f6bda36084b79758c966ccc8757dfe004deb26963ee400
5
5
  SHA512:
6
- metadata.gz: ab11dc139997c5398b1c83cc72ddf1142598bf3e50f8bdca34d2e74fb7e9159b209237ad11a60cc23fe8313eab0436f03615e81ae204480a2552173d24b967d8
7
- data.tar.gz: 7a1b670887503b620af4b36ce44504c155f494b3d1c1e35ed57d8f90471c7e7aeb1be5fb815d383baf98de89d2924ec481a2ba4c3567b9a0ed222f02a47f5596
6
+ metadata.gz: 49ebde9d47e594d7ddeaaf893f2a9a99c4162592065800d8c4d5b3f84b7e08d2c95a57f47f20a079b0ba8bfc36e6c83fc31e96aa4587695db913a40194999a42
7
+ data.tar.gz: 94a1cfe6e885d009a1117a7bede81a4db4f8215cd8b3f37b2d38fa89da17e239478556809f2265fb9a47761644da5c0ef6487042276655151b9372b0919664f8
data/.env CHANGED
@@ -1,5 +1,6 @@
1
1
  ALPINE_RUBY_VERSION=2.7.5
2
2
  RAILS_VERSION=5.2.6
3
+ VIEW_COMPONENT_VERSION=2.6.6
3
4
  SOLR_PORT=8983
4
5
  SOLR_URL=http://solr:8983/solr/blacklight-core
5
6
  SOLR_VERSION=latest
@@ -32,7 +32,7 @@ jobs:
32
32
  runs-on: ubuntu-latest
33
33
  strategy:
34
34
  matrix:
35
- ruby: [2.7, '3.0', 3.1]
35
+ ruby: [2.7, '3.0', 3.1, 3.2]
36
36
  steps:
37
37
  - uses: actions/checkout@v2
38
38
  - name: Set up Ruby
@@ -129,6 +129,26 @@ jobs:
129
129
  env:
130
130
  RAILS_VERSION: 6.1.6.1
131
131
  ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-keeps --skip-action-cable --skip-test'
132
+ test_vc3:
133
+ runs-on: ubuntu-latest
134
+ strategy:
135
+ matrix:
136
+ ruby: ['3.2']
137
+ env:
138
+ VIEW_COMPONENT_VERSION: ${{ matrix.view_component_version }}
139
+ steps:
140
+ - uses: actions/checkout@v2
141
+ - name: Set up Ruby
142
+ uses: ruby/setup-ruby@v1
143
+ with:
144
+ ruby-version: ${{ matrix.ruby }}
145
+ bundler: 'latest'
146
+ - name: Install dependencies
147
+ run: bundle install
148
+ - name: Run tests
149
+ run: bundle exec rake ci
150
+ env:
151
+ ENGINE_CART_RAILS_OPTIONS: '--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test'
132
152
  api_test:
133
153
  runs-on: ubuntu-latest
134
154
  strategy:
data/.rubocop.yml CHANGED
@@ -63,6 +63,8 @@ Naming/MethodParameterName:
63
63
  - id
64
64
  - q
65
65
  - as
66
+ - of
67
+ - by
66
68
 
67
69
  Naming/PredicateName:
68
70
  ForbiddenPrefixes:
data/Gemfile CHANGED
@@ -33,6 +33,10 @@ else
33
33
  end
34
34
  end
35
35
 
36
+ unless ENV['VIEW_COMPONENT_VERSION'].to_s == ""
37
+ gem 'view_component', ENV.fetch('VIEW_COMPONENT_VERSION')
38
+ end
39
+
36
40
  case ENV['RAILS_VERSION']
37
41
  when /^6.0/
38
42
  gem 'sass-rails', '>= 6'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.33.0
1
+ 7.34.0
@@ -13,7 +13,6 @@ var Blacklight = function () {
13
13
  },
14
14
  listeners: function listeners() {
15
15
  var listeners = [];
16
-
17
16
  if (typeof Turbo !== 'undefined') {
18
17
  listeners.push('turbo:load');
19
18
  } else if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
@@ -27,23 +26,23 @@ var Blacklight = function () {
27
26
  } else {
28
27
  listeners.push('DOMContentLoaded');
29
28
  }
30
-
31
29
  return listeners;
32
30
  }
33
31
  };
34
- }(); // turbolinks triggers page:load events on page transition
35
- // If app isn't using turbolinks, this event will never be triggered, no prob.
36
-
32
+ }();
37
33
 
34
+ // turbolinks triggers page:load events on page transition
35
+ // If app isn't using turbolinks, this event will never be triggered, no prob.
38
36
  Blacklight.listeners().forEach(function (listener) {
39
37
  document.addEventListener(listener, function () {
40
38
  Blacklight.activate();
41
39
  });
42
40
  });
43
41
  Blacklight.onLoad(function () {
44
- var elem = document.querySelector('.no-js'); // The "no-js" class may already have been removed because this function is
45
- // run on every turbo:load event, in that case, it won't find an element.
42
+ var elem = document.querySelector('.no-js');
46
43
 
44
+ // The "no-js" class may already have been removed because this function is
45
+ // run on every turbo:load event, in that case, it won't find an element.
47
46
  if (!elem) return;
48
47
  elem.classList.remove('no-js');
49
48
  elem.classList.add('js');
@@ -56,11 +55,9 @@ Blacklight.onLoad(function () {
56
55
 
57
56
  $('[data-autocomplete-enabled="true"]').each(function () {
58
57
  var $el = $(this);
59
-
60
58
  if ($el.hasClass('tt-hint')) {
61
59
  return;
62
60
  }
63
-
64
61
  var suggestUrl = $el.data().autocompletePath;
65
62
  var terms = new Bloodhound({
66
63
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
@@ -82,7 +79,6 @@ Blacklight.onLoad(function () {
82
79
  });
83
80
  });
84
81
  });
85
-
86
82
  (function ($) {
87
83
  //change form submit toggle to checkbox
88
84
  Blacklight.doBookmarkToggleBehavior = function () {
@@ -90,7 +86,6 @@ Blacklight.onLoad(function () {
90
86
  console.warn("do_bookmark_toggle_behavior is deprecated. Use doBookmarkToggleBehavior instead.");
91
87
  return Blacklight.do_bookmark_toggle_behavior();
92
88
  }
93
-
94
89
  $(Blacklight.doBookmarkToggleBehavior.selector).blCheckboxSubmit({
95
90
  // cssClass is added to elements added, plus used for id base
96
91
  cssClass: 'toggle-bookmark',
@@ -101,13 +96,11 @@ Blacklight.onLoad(function () {
101
96
  }
102
97
  });
103
98
  };
104
-
105
99
  Blacklight.doBookmarkToggleBehavior.selector = 'form.bookmark-toggle';
106
100
  Blacklight.onLoad(function () {
107
101
  Blacklight.doBookmarkToggleBehavior();
108
102
  });
109
103
  })(jQuery);
110
-
111
104
  Blacklight.onLoad(function () {
112
105
  // Button clicks should change focus. As of 10/3/19, Firefox for Mac and
113
106
  // Safari both do not set focus to a button on button click.
@@ -148,23 +141,23 @@ Blacklight.onLoad(function () {
148
141
  }
149
142
  });
150
143
  */
151
-
152
144
  (function ($) {
153
145
  $.fn.blCheckboxSubmit = function (argOpts) {
154
146
  this.each(function () {
155
147
  var options = $.extend({}, $.fn.blCheckboxSubmit.defaults, argOpts);
156
148
  var form = $(this);
157
- form.children().hide(); //We're going to use the existing form to actually send our add/removes
149
+ form.children().hide();
150
+ //We're going to use the existing form to actually send our add/removes
158
151
  //This works conveneintly because the exact same action href is used
159
152
  //for both bookmarks/$doc_id. But let's take out the irrelevant parts
160
153
  //of the form to avoid any future confusion.
154
+ form.find('input[type=submit]').remove();
161
155
 
162
- form.find('input[type=submit]').remove(); //View needs to set data-doc-id so we know a unique value
156
+ //View needs to set data-doc-id so we know a unique value
163
157
  //for making DOM id
164
-
165
- var uniqueId = form.attr('data-doc-id') || Math.random(); // if form is currently using method delete to change state,
158
+ var uniqueId = form.attr('data-doc-id') || Math.random();
159
+ // if form is currently using method delete to change state,
166
160
  // then checkbox is currently checked
167
-
168
161
  var checked = form.find('input[name=_method][value=delete]').length != 0;
169
162
  var checkbox = $('<input type="checkbox">').addClass(options.cssClass).attr('id', options.cssClass + '_' + uniqueId);
170
163
  var label = $('<label>').addClass(options.cssClass).attr('for', options.cssClass + '_' + uniqueId).attr('title', form.attr('title') || '');
@@ -173,11 +166,9 @@ Blacklight.onLoad(function () {
173
166
  label.append(' ');
174
167
  label.append(span);
175
168
  var checkboxDiv = $('<div class="checkbox" />').addClass(options.cssClass).append(label);
176
-
177
169
  function updateStateFor(state) {
178
170
  checkbox.prop('checked', state);
179
171
  label.toggleClass('checked', state);
180
-
181
172
  if (state) {
182
173
  //Set the Rails hidden field that fakes an HTTP verb
183
174
  //properly for current state action.
@@ -188,7 +179,6 @@ Blacklight.onLoad(function () {
188
179
  span.html(form.attr('data-absent'));
189
180
  }
190
181
  }
191
-
192
182
  form.append(checkboxDiv);
193
183
  updateStateFor(checked);
194
184
  checkbox.click(function () {
@@ -224,10 +214,8 @@ Blacklight.onLoad(function () {
224
214
  return false;
225
215
  }); //checkbox.click
226
216
  }); //this.each
227
-
228
217
  return this;
229
218
  };
230
-
231
219
  $.fn.blCheckboxSubmit.defaults = {
232
220
  //cssClass is added to elements added, plus used for id base
233
221
  cssClass: 'blCheckboxSubmit',
@@ -235,32 +223,26 @@ Blacklight.onLoad(function () {
235
223
  alert("Error");
236
224
  },
237
225
  success: function success() {} //callback
238
-
239
226
  };
240
227
  })(jQuery);
241
228
  /*global Blacklight */
242
229
 
243
-
244
230
  'use strict';
245
-
246
231
  Blacklight.doResizeFacetLabelsAndCounts = function () {
247
232
  // adjust width of facet columns to fit their contents
248
233
  function longer(a, b) {
249
234
  return b.textContent.length - a.textContent.length;
250
235
  }
251
-
252
236
  document.querySelectorAll('.facet-values, .pivot-facet').forEach(function (elem) {
253
- var nodes = elem.querySelectorAll('.facet-count'); // TODO: when we drop ie11 support, this can become the spread operator:
254
-
237
+ var nodes = elem.querySelectorAll('.facet-count');
238
+ // TODO: when we drop ie11 support, this can become the spread operator:
255
239
  var longest = Array.from(nodes).sort(longer)[0];
256
-
257
240
  if (longest && longest.textContent) {
258
241
  var width = longest.textContent.length + 1 + 'ch';
259
242
  elem.querySelector('.facet-count').style.width = width;
260
243
  }
261
244
  });
262
245
  };
263
-
264
246
  Blacklight.onLoad(function () {
265
247
  Blacklight.doResizeFacetLabelsAndCounts();
266
248
  });
@@ -336,99 +318,99 @@ Blacklight.onLoad(function () {
336
318
 
337
319
  The data-blacklight-modal=close behavior is implemented with this event, see for example.
338
320
  */
321
+
339
322
  // We keep all our data in Blacklight.modal object.
340
323
  // Create lazily if someone else created first.
341
-
342
324
  if (Blacklight.modal === undefined) {
343
325
  Blacklight.modal = {};
344
- } // a Bootstrap modal div that should be already on the page hidden
326
+ }
345
327
 
328
+ // a Bootstrap modal div that should be already on the page hidden
329
+ Blacklight.modal.modalSelector = '#blacklight-modal';
346
330
 
347
- Blacklight.modal.modalSelector = '#blacklight-modal'; // Trigger selectors identify forms or hyperlinks that should open
331
+ // Trigger selectors identify forms or hyperlinks that should open
348
332
  // inside a modal dialog.
349
-
350
333
  Blacklight.modal.triggerLinkSelector = 'a[data-blacklight-modal~=trigger]';
351
- Blacklight.modal.triggerFormSelector = 'form[data-blacklight-modal~=trigger]'; // preserve selectors identify forms or hyperlinks that, if activated already
334
+ Blacklight.modal.triggerFormSelector = 'form[data-blacklight-modal~=trigger]';
335
+
336
+ // preserve selectors identify forms or hyperlinks that, if activated already
352
337
  // inside a modal dialog, should have destinations remain inside the modal -- but
353
338
  // won't trigger a modal if not already in one.
354
339
  //
355
340
  // No need to repeat selectors from trigger selectors, those will already
356
341
  // be preserved. MUST be manually prefixed with the modal selector,
357
342
  // so they only apply to things inside a modal.
358
-
359
343
  Blacklight.modal.preserveLinkSelector = Blacklight.modal.modalSelector + ' a[data-blacklight-modal~=preserve]';
360
344
  Blacklight.modal.containerSelector = '[data-blacklight-modal~=container]';
361
- Blacklight.modal.modalCloseSelector = '[data-blacklight-modal~=close]'; // Called on fatal failure of ajax load, function returns content
345
+ Blacklight.modal.modalCloseSelector = '[data-blacklight-modal~=close]';
346
+
347
+ // Called on fatal failure of ajax load, function returns content
362
348
  // to show to user in modal. Right now called only for extreme
363
349
  // network errors.
364
-
365
350
  Blacklight.modal.onFailure = function (jqXHR, textStatus, errorThrown) {
366
351
  console.error('Server error:', this.url, jqXHR.status, errorThrown);
367
352
  var contents = '<div class="modal-header">' + '<div class="modal-title">There was a problem with your request.</div>' + '<button type="button" class="blacklight-modal-close btn-close close" data-dismiss="modal" aria-label="Close">' + ' <span aria-hidden="true">&times;</span>' + '</button></div>' + ' <div class="modal-body"><p>Expected a successful response from the server, but got an error</p>' + '<pre>' + this.type + ' ' + this.url + "\n" + jqXHR.status + ': ' + errorThrown + '</pre></div>';
368
353
  $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);
369
354
  Blacklight.modal.show();
370
355
  };
371
-
372
356
  Blacklight.modal.receiveAjax = function (contents) {
373
357
  // does it have a data- selector for container?
374
358
  // important we don't execute script tags, we shouldn't.
375
359
  // code modelled off of JQuery ajax.load. https://github.com/jquery/jquery/blob/main/src/ajax/load.js?source=c#L62
376
360
  var container = $('<div>').append(jQuery.parseHTML(contents)).find(Blacklight.modal.containerSelector).first();
377
-
378
361
  if (container.length !== 0) {
379
362
  contents = container.html();
380
363
  }
364
+ $(Blacklight.modal.modalSelector).find('.modal-content').html(contents);
381
365
 
382
- $(Blacklight.modal.modalSelector).find('.modal-content').html(contents); // send custom event with the modal dialog div as the target
383
-
366
+ // send custom event with the modal dialog div as the target
384
367
  var e = $.Event('loaded.blacklight.blacklight-modal');
385
- $(Blacklight.modal.modalSelector).trigger(e); // if they did preventDefault, don't show the dialog
386
-
368
+ $(Blacklight.modal.modalSelector).trigger(e);
369
+ // if they did preventDefault, don't show the dialog
387
370
  if (e.isDefaultPrevented()) return;
388
371
  Blacklight.modal.show();
389
372
  };
390
-
391
373
  Blacklight.modal.modalAjaxLinkClick = function (e) {
392
374
  e.preventDefault();
393
375
  $.ajax({
394
376
  url: $(this).attr('href')
395
377
  }).fail(Blacklight.modal.onFailure).done(Blacklight.modal.receiveAjax);
396
378
  };
397
-
398
379
  Blacklight.modal.modalAjaxFormSubmit = function (e) {
399
380
  e.preventDefault();
400
381
  $.ajax({
401
382
  url: $(this).attr('action'),
402
383
  data: $(this).serialize(),
403
384
  type: $(this).attr('method') // POST
404
-
405
385
  }).fail(Blacklight.modal.onFailure).done(Blacklight.modal.receiveAjax);
406
386
  };
407
-
408
387
  Blacklight.modal.setupModal = function () {
409
388
  // Event indicating blacklight is setting up a modal link,
410
389
  // you can catch it and call e.preventDefault() to abort
411
390
  // setup.
412
391
  var e = $.Event('setup.blacklight.blacklight-modal');
413
392
  $('body').trigger(e);
414
- if (e.isDefaultPrevented()) return; // Register both trigger and preserve selectors in ONE event handler, combining
393
+ if (e.isDefaultPrevented()) return;
394
+
395
+ // Register both trigger and preserve selectors in ONE event handler, combining
415
396
  // into one selector with a comma, so if something matches BOTH selectors, it
416
397
  // still only gets the event handler called once.
417
-
418
398
  $('body').on('click', Blacklight.modal.triggerLinkSelector + ', ' + Blacklight.modal.preserveLinkSelector, Blacklight.modal.modalAjaxLinkClick);
419
- $('body').on('submit', Blacklight.modal.triggerFormSelector + ', ' + Blacklight.modal.preserveFormSelector, Blacklight.modal.modalAjaxFormSubmit); // Catch our own custom loaded event to implement data-blacklight-modal=closed
399
+ $('body').on('submit', Blacklight.modal.triggerFormSelector + ', ' + Blacklight.modal.preserveFormSelector, Blacklight.modal.modalAjaxFormSubmit);
400
+
401
+ // Catch our own custom loaded event to implement data-blacklight-modal=closed
402
+ $('body').on('loaded.blacklight.blacklight-modal', Blacklight.modal.checkCloseModal);
420
403
 
421
- $('body').on('loaded.blacklight.blacklight-modal', Blacklight.modal.checkCloseModal); // we support doing data-dismiss=modal on a <a> with a href for non-ajax
404
+ // we support doing data-dismiss=modal on a <a> with a href for non-ajax
422
405
  // use, we need to suppress following the a's href that's there for
423
406
  // non-JS contexts.
424
-
425
407
  $('body').on('click', Blacklight.modal.modalSelector + ' a[data-dismiss~=modal]', function (e) {
426
408
  e.preventDefault();
427
409
  });
428
- }; // A function used as an event handler on loaded.blacklight.blacklight-modal
429
- // to catch contained data-blacklight-modal=closed directions
430
-
410
+ };
431
411
 
412
+ // A function used as an event handler on loaded.blacklight.blacklight-modal
413
+ // to catch contained data-blacklight-modal=closed directions
432
414
  Blacklight.modal.checkCloseModal = function (event) {
433
415
  if ($(event.target).find(Blacklight.modal.modalCloseSelector).length) {
434
416
  var modalFlashes = $(this).find('.flash_messages');
@@ -439,7 +421,6 @@ Blacklight.modal.checkCloseModal = function (event) {
439
421
  modalFlashes.fadeIn(500);
440
422
  }
441
423
  };
442
-
443
424
  Blacklight.modal.hide = function (el) {
444
425
  if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
445
426
  bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).hide();
@@ -447,7 +428,6 @@ Blacklight.modal.hide = function (el) {
447
428
  $(el || Blacklight.modal.modalSelector).modal('hide');
448
429
  }
449
430
  };
450
-
451
431
  Blacklight.modal.show = function (el) {
452
432
  if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
453
433
  bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).show();
@@ -455,19 +435,16 @@ Blacklight.modal.show = function (el) {
455
435
  $(el || Blacklight.modal.modalSelector).modal('show');
456
436
  }
457
437
  };
458
-
459
438
  Blacklight.onLoad(function () {
460
439
  Blacklight.modal.setupModal();
461
440
  });
462
-
463
441
  Blacklight.doSearchContextBehavior = function () {
464
442
  if (typeof Blacklight.do_search_context_behavior == 'function') {
465
443
  console.warn("do_search_context_behavior is deprecated. Use doSearchContextBehavior instead.");
466
444
  return Blacklight.do_search_context_behavior();
467
445
  }
468
-
469
- var elements = document.querySelectorAll('a[data-context-href]'); // Equivalent to Array.from(), but supports ie11
470
-
446
+ var elements = document.querySelectorAll('a[data-context-href]');
447
+ // Equivalent to Array.from(), but supports ie11
471
448
  var nodes = Array.prototype.slice.call(elements);
472
449
  nodes.forEach(function (element) {
473
450
  element.addEventListener('click', function (e) {
@@ -475,29 +452,25 @@ Blacklight.doSearchContextBehavior = function () {
475
452
  });
476
453
  });
477
454
  };
478
-
479
455
  Blacklight.csrfToken = function () {
480
456
  var _document$querySelect;
481
-
482
457
  return (_document$querySelect = document.querySelector('meta[name=csrf-token]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.content;
483
458
  };
484
-
485
459
  Blacklight.csrfParam = function () {
486
460
  var _document$querySelect2;
487
-
488
461
  return (_document$querySelect2 = document.querySelector('meta[name=csrf-param]')) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.content;
489
- }; // this is the Rails.handleMethod with a couple adjustments, described inline:
490
- // first, we're attaching this directly to the event handler, so we can check for meta-keys
491
-
462
+ };
492
463
 
464
+ // this is the Rails.handleMethod with a couple adjustments, described inline:
465
+ // first, we're attaching this directly to the event handler, so we can check for meta-keys
493
466
  Blacklight.handleSearchContextMethod = function (event) {
494
467
  if (typeof Blacklight.handle_search_context_method == 'function') {
495
468
  console.warn("handle_search_context_method is deprecated. Use handleSearchContextMethod instead.");
496
469
  return Blacklight.handle_search_context_method(event);
497
470
  }
471
+ var link = this;
498
472
 
499
- var link = this; // instead of using the normal href, we need to use the context href instead
500
-
473
+ // instead of using the normal href, we need to use the context href instead
501
474
  var href = link.getAttribute('data-context-href');
502
475
  var target = link.getAttribute('target');
503
476
  var csrfToken = Blacklight.csrfToken();
@@ -505,24 +478,22 @@ Blacklight.handleSearchContextMethod = function (event) {
505
478
  var form = document.createElement('form');
506
479
  form.method = 'post';
507
480
  form.action = href;
508
- var formContent = "<input name=\"_method\" value=\"post\" type=\"hidden\" />\n <input name=\"redirect\" value=\"".concat(link.getAttribute('href'), "\" type=\"hidden\" />"); // check for meta keys.. if set, we should open in a new tab
481
+ var formContent = "<input name=\"_method\" value=\"post\" type=\"hidden\" />\n <input name=\"redirect\" value=\"".concat(link.getAttribute('href'), "\" type=\"hidden\" />");
509
482
 
483
+ // check for meta keys.. if set, we should open in a new tab
510
484
  if (event.metaKey || event.ctrlKey) {
511
485
  target = '_blank';
512
486
  }
513
-
514
487
  if (csrfParam !== undefined && csrfToken !== undefined) {
515
488
  formContent += "<input name=\"".concat(csrfParam, "\" value=\"").concat(csrfToken, "\" type=\"hidden\" />");
516
- } // Must trigger submit by click on a button, else "submit" event handler won't work!
517
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
518
-
489
+ }
519
490
 
491
+ // Must trigger submit by click on a button, else "submit" event handler won't work!
492
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
520
493
  formContent += '<input type="submit" />';
521
-
522
494
  if (target) {
523
495
  form.setAttribute('target', target);
524
496
  }
525
-
526
497
  form.style.display = 'none';
527
498
  form.innerHTML = formContent;
528
499
  document.body.appendChild(form);
@@ -530,7 +501,6 @@ Blacklight.handleSearchContextMethod = function (event) {
530
501
  event.preventDefault();
531
502
  event.stopPropagation();
532
503
  };
533
-
534
504
  Blacklight.onLoad(function () {
535
505
  Blacklight.doSearchContextBehavior();
536
506
  });
@@ -34,7 +34,7 @@ module Blacklight
34
34
 
35
35
  send(#{callback}, @documents)
36
36
 
37
- flash[:success] ||= I18n.t("blacklight.#{name}.success", default: nil)
37
+ flash.now[:success] ||= I18n.t("blacklight.#{name}.success", default: nil)
38
38
 
39
39
  respond_to do |format|
40
40
  format.html do
@@ -40,7 +40,7 @@
40
40
 
41
41
  <% if sort_fields_select %>
42
42
  <div class="form-group row mb-4">
43
- <%= content_tag :h2, t('blacklight.advanced_search.form.sort_label'), class: 'col-md-3 col-form-label text-md-right' %>
43
+ <%= content_tag :h2, t('blacklight.advanced_search.form.sort_label'), id: 'advanced-search-sort-label', class: 'col-md-3 col-form-label text-md-right' %>
44
44
  <div class="col">
45
45
  <%= sort_fields_select %>
46
46
  </div>
@@ -26,21 +26,21 @@ module Blacklight
26
26
 
27
27
  def default_operator_menu
28
28
  options_with_labels = [:must, :should].index_by { |op| t(op, scope: 'blacklight.advanced_search.op') }
29
- select_tag(:op, options_for_select(options_with_labels, params[:op]), class: 'input-small')
29
+ label_tag(:op, t('blacklight.advanced_search.op.label'), class: 'sr-only visually-hidden') + select_tag(:op, options_for_select(options_with_labels, params[:op]), class: 'input-small')
30
30
  end
31
31
 
32
32
  def sort_fields_select
33
33
  options = sort_fields.values.map { |field_config| [helpers.sort_field_label(field_config.key), field_config.key] }
34
34
  return unless options.any?
35
35
 
36
- select_tag(:sort, options_for_select(options, params[:sort]), class: "form-control sort-select w-auto")
36
+ select_tag(:sort, options_for_select(options, params[:sort]), class: "form-control sort-select w-auto", aria: { labelledby: 'advanced-search-sort-label' })
37
37
  end
38
38
 
39
39
  private
40
40
 
41
41
  def initialize_search_field_controls
42
42
  search_fields.values.each.with_index do |field, i|
43
- search_field_control do
43
+ with_search_field_control do
44
44
  fields_for('clause[]', i, include_id: false) do |f|
45
45
  content_tag(:div, class: 'form-group advanced-search-field row') do
46
46
  f.label(:query, field.display_label('search'), class: "col-sm-3 col-form-label text-md-right") +
@@ -59,7 +59,7 @@ module Blacklight
59
59
 
60
60
  fields.each do |_k, config|
61
61
  display_facet = @response.aggregations[config.field]
62
- search_filter_control(config: config, display_facet: display_facet)
62
+ with_search_filter_control(config: config, display_facet: display_facet)
63
63
  end
64
64
  end
65
65
 
@@ -72,7 +72,7 @@ module Blacklight
72
72
 
73
73
  return if constraints_text.blank?
74
74
 
75
- constraint do
75
+ with_constraint do
76
76
  constraints_text
77
77
  end
78
78
  end
@@ -7,7 +7,7 @@ module Blacklight
7
7
  def with(slot_name, *args, **kwargs, &block)
8
8
  Deprecation.warn(Blacklight::ContentAreasShim,
9
9
  'ViewComponents deprecated `with` and it will be removed in ViewComponents 3.0. content_areas. Use slots (https://viewcomponent.org/guide/slots.html) instead.')
10
- public_send(slot_name, *args, **kwargs, &block)
10
+ public_send("with_#{slot_name}", *args, **kwargs, &block)
11
11
  end
12
12
  end
13
13
  end
@@ -1,9 +1,2 @@
1
- <% if using_default_document_action? %>
2
- <%= link_to label,
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,6 +16,12 @@ 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
26
  return true if @action.component
21
27
  return false unless @action.partial == 'document_action'
@@ -23,6 +29,18 @@ module Blacklight
23
29
  helpers.partial_from_blacklight?(@action.partial)
24
30
  end
25
31
 
32
+ def link_to_modal_control
33
+ link_to label,
34
+ url,
35
+ id: @id,
36
+ class: @link_classes,
37
+ data: {}.merge(({ blacklight_modal: "trigger", turbo: false } if @action.modal != false) || {})
38
+ end
39
+
40
+ def render_partial
41
+ helpers.render(partial: @action.partial || @action.name.to_s, locals: { document: @document, document_action_config: @action }.merge(@options))
42
+ end
43
+
26
44
  def label
27
45
  Deprecation.silence(Blacklight::ComponentHelperBehavior) do
28
46
  helpers.document_action_label(@action.name, @action)
@@ -28,7 +28,7 @@ module Blacklight
28
28
  return if actions.present?
29
29
 
30
30
  @actions.each do |a|
31
- action(component: a.component, action: a)
31
+ with_action(component: a.component, action: a)
32
32
  end
33
33
  end
34
34