blacklight 7.32.0 → 7.33.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17b8b14189b4ced9faa60d183fa887eb6962dba4d55f3718fee11ff4bed59388
4
- data.tar.gz: dd1f5ea853080c0732313b3ab64de8d310634786cfbcfe5ddde6691bc2137820
3
+ metadata.gz: bd9f780cd93deb22275984f9441e19bbffba7c3b07ba1173bd092786cd68bcef
4
+ data.tar.gz: 320dc37ac26ba35cbb9d4916babb45187f1a93203561cc1bcb214d6e1ebb181e
5
5
  SHA512:
6
- metadata.gz: d481b3b290ca1030fcc593fad5ef8fdbe3e5a42091c4138af3efaaa58b45322f32d8e4956e6d92d01d305e762d4e2a3886f9caa193ba4197920d18d989184308
7
- data.tar.gz: f6010fc1c00b31fddce8d2e73794655dbe3c1c690e65bedace78c693a4c36a884f5ac0589681717e3852bf9e1ff41109a7d5de2c2d4957e835c59afd53cfcfcb
6
+ metadata.gz: 11ab615553f94bbdb382865dc4cd9dc757b9895de17976a8a8e9294987e25ef54d8b1e5d3f744690984508d5f6375cb823b21b78411f9b87c0ab5fe90dde6bec
7
+ data.tar.gz: afab5ae2f8e18deaf6935abb4160a326849cc4234bc9ac9cd21f757395493b7d698c908541f960ee8a17a3beb4c5e48b71f675c578426736f6055e57659c9709
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.32.0
1
+ 7.33.1
@@ -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
  });
@@ -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;
@@ -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
@@ -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.
@@ -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) %>
@@ -577,9 +577,13 @@ module Blacklight
577
577
  document_or_display_types
578
578
  end
579
579
 
580
+ unless display_types.respond_to?(:each)
581
+ Deprecation.warn self, "Calling show_fields_for with a scalar value is deprecated. It must receive an Enumerable."
582
+ display_types = Array.wrap(display_types)
583
+ end
580
584
  fields = {}.with_indifferent_access
581
585
 
582
- Array.wrap(display_types).each do |display_type|
586
+ display_types.each do |display_type|
583
587
  fields = fields.merge(for_display_type(display_type).show_fields)
584
588
  end
585
589
 
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blacklight-frontend",
3
- "version": "7.25.0",
3
+ "version": "7.33.1",
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": {
@@ -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
@@ -535,6 +535,10 @@ RSpec.describe CatalogController, api: true do
535
535
  post :email, xhr: true, params: { id: doc_id, to: 'test_email@projectblacklight.org' }
536
536
  expect(request).to render_template 'email_success'
537
537
  expect(request.flash[:success]).to eq "Email Sent"
538
+ allow(search_service).to receive(:search_results)
539
+ # When we go to another page, the flash message should no longer display
540
+ get :index
541
+ expect(request.flash[:success]).to be_nil
538
542
  end
539
543
  end
540
544
 
@@ -589,6 +593,10 @@ RSpec.describe CatalogController, api: true do
589
593
  post :sms, xhr: true, params: { id: doc_id, to: '5555555555', carrier: 'txt.att.net' }
590
594
  expect(request).to render_template 'sms_success'
591
595
  expect(request.flash[:success]).to eq "SMS Sent"
596
+ allow(search_service).to receive(:search_results)
597
+ # When we go to another page, the flash message should no longer display
598
+ get :index
599
+ expect(request.flash[:success]).to be_nil
592
600
  end
593
601
  end
594
602
  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'
@@ -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.32.0
4
+ version: 7.33.1
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-11-16 00:00:00.000000000 Z
20
+ date: 2023-02-02 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -954,7 +954,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
954
954
  - !ruby/object:Gem::Version
955
955
  version: '0'
956
956
  requirements: []
957
- rubygems_version: 3.3.7
957
+ rubygems_version: 3.3.26
958
958
  signing_key:
959
959
  specification_version: 4
960
960
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)