blacklight-spotlight 5.3.0 → 5.3.1

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 (151) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -1
  3. data/app/assets/javascripts/spotlight/spotlight.esm.js +1679 -1228
  4. data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
  5. data/app/assets/javascripts/spotlight/spotlight.js +1682 -1231
  6. data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
  7. data/app/components/spotlight/analytics/aggregation_component.html.erb +1 -1
  8. data/app/components/spotlight/document_admin_table_component.html.erb +2 -2
  9. data/app/components/spotlight/edit_view_links_component.html.erb +1 -1
  10. data/app/components/spotlight/header_component.html.erb +1 -1
  11. data/app/components/spotlight/tag_list_form_component.html.erb +1 -1
  12. data/app/components/spotlight/tag_selector_component.html.erb +2 -2
  13. data/app/components/spotlight/translations/subheading_component.html.erb +1 -1
  14. data/app/controllers/spotlight/resources_controller.rb +1 -1
  15. data/app/javascript/spotlight/admin/add_another.js +22 -15
  16. data/app/javascript/spotlight/admin/add_image_selector.js +27 -25
  17. data/app/javascript/spotlight/admin/add_new_button.js +47 -43
  18. data/app/javascript/spotlight/admin/blacklight_configuration.js +52 -38
  19. data/app/javascript/spotlight/admin/block_mixins/autocompleteable.js +68 -60
  20. data/app/javascript/spotlight/admin/block_mixins/formable.js +55 -47
  21. data/app/javascript/spotlight/admin/block_mixins/plustextable.js +19 -20
  22. data/app/javascript/spotlight/admin/blocks/block.js +20 -16
  23. data/app/javascript/spotlight/admin/blocks/browse_block.js +42 -37
  24. data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +33 -31
  25. data/app/javascript/spotlight/admin/blocks/iframe_block.js +14 -11
  26. data/app/javascript/spotlight/admin/blocks/link_to_search_block.js +4 -7
  27. data/app/javascript/spotlight/admin/blocks/oembed_block.js +13 -10
  28. data/app/javascript/spotlight/admin/blocks/pages_block.js +20 -13
  29. data/app/javascript/spotlight/admin/blocks/resources_block.js +150 -117
  30. data/app/javascript/spotlight/admin/blocks/rule_block.js +11 -10
  31. data/app/javascript/spotlight/admin/blocks/search_result_block.js +16 -17
  32. data/app/javascript/spotlight/admin/blocks/solr_documents_base_block.js +123 -64
  33. data/app/javascript/spotlight/admin/blocks/solr_documents_block.js +8 -8
  34. data/app/javascript/spotlight/admin/blocks/solr_documents_carousel_block.js +63 -43
  35. data/app/javascript/spotlight/admin/blocks/solr_documents_embed_block.js +9 -9
  36. data/app/javascript/spotlight/admin/blocks/solr_documents_features_block.js +17 -16
  37. data/app/javascript/spotlight/admin/blocks/solr_documents_grid_block.js +6 -7
  38. data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +84 -64
  39. data/app/javascript/spotlight/admin/crop.js +203 -156
  40. data/app/javascript/spotlight/admin/croppable.js +4 -4
  41. data/app/javascript/spotlight/admin/croppable_modal.js +59 -37
  42. data/app/javascript/spotlight/admin/edit_in_place.js +50 -47
  43. data/app/javascript/spotlight/admin/exhibits.js +52 -41
  44. data/app/javascript/spotlight/admin/form_observer.js +59 -53
  45. data/app/javascript/spotlight/admin/iiif.js +26 -25
  46. data/app/javascript/spotlight/admin/index.js +44 -47
  47. data/app/javascript/spotlight/admin/locks.js +14 -14
  48. data/app/javascript/spotlight/admin/multi_image_selector.js +127 -111
  49. data/app/javascript/spotlight/admin/pages.js +21 -21
  50. data/app/javascript/spotlight/admin/progress_monitor.js +67 -65
  51. data/app/javascript/spotlight/admin/readonly_checkbox.js +3 -3
  52. data/app/javascript/spotlight/admin/search_typeahead.js +55 -43
  53. data/app/javascript/spotlight/admin/select_related_input.js +17 -17
  54. data/app/javascript/spotlight/admin/sir-trevor/block_controls.js +100 -84
  55. data/app/javascript/spotlight/admin/sir-trevor/block_limits.js +36 -31
  56. data/app/javascript/spotlight/admin/sir-trevor/locales.js +52 -39
  57. data/app/javascript/spotlight/admin/spotlight_nestable.js +112 -90
  58. data/app/javascript/spotlight/admin/tabs.js +16 -3
  59. data/app/javascript/spotlight/admin/translation_progress.js +13 -7
  60. data/app/javascript/spotlight/admin/users.js +41 -41
  61. data/app/javascript/spotlight/admin/visibility_toggle.js +4 -4
  62. data/app/javascript/spotlight/controllers/clipboard_controller.js +14 -0
  63. data/app/javascript/spotlight/controllers/index.js +4 -2
  64. data/app/javascript/spotlight/controllers/tag_selector_controller.js +116 -79
  65. data/app/javascript/spotlight/core.js +18 -15
  66. data/app/javascript/spotlight/index.js +4 -4
  67. data/app/javascript/spotlight/user/browse_group_categories.js +24 -22
  68. data/app/javascript/spotlight/user/carousel.js +23 -19
  69. data/app/javascript/spotlight/user/clear_form_button.js +15 -15
  70. data/app/javascript/spotlight/user/index.js +4 -4
  71. data/app/javascript/spotlight/user/zpr_links.js +18 -18
  72. data/app/models/spotlight/analytics/ga.rb +0 -1
  73. data/app/models/spotlight/resources/iiif_manifest_v3.rb +2 -2
  74. data/app/services/spotlight/exhibit_import_export_service.rb +0 -2
  75. data/app/views/blacklight/nav/_bookmark.html.erb +1 -1
  76. data/app/views/catalog/_remove_tags.html.erb +1 -1
  77. data/app/views/layouts/spotlight/base.html.erb +1 -1
  78. data/app/views/shared/_header_navbar.html.erb +1 -1
  79. data/app/views/shared/_masthead.html.erb +2 -2
  80. data/app/views/shared/_site_sidebar.html.erb +1 -1
  81. data/app/views/shared/_user_util_links.html.erb +2 -2
  82. data/app/views/spotlight/about_pages/_contacts.html.erb +1 -1
  83. data/app/views/spotlight/accessibility/alt_text.html.erb +1 -1
  84. data/app/views/spotlight/admin_users/index.html.erb +11 -9
  85. data/app/views/spotlight/appearances/edit.html.erb +1 -1
  86. data/app/views/spotlight/browse/_search_box.html.erb +1 -1
  87. data/app/views/spotlight/bulk_updates/_download.html.erb +1 -1
  88. data/app/views/spotlight/bulk_updates/_progress_panel.html.erb +6 -6
  89. data/app/views/spotlight/bulk_updates/edit.html.erb +1 -1
  90. data/app/views/spotlight/catalog/_admin_header.html.erb +1 -1
  91. data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +1 -1
  92. data/app/views/spotlight/catalog/_curation_mode_toggle_default.html.erb +1 -1
  93. data/app/views/spotlight/catalog/_document.html.erb +2 -2
  94. data/app/views/spotlight/catalog/_document_admin_table.html.erb +1 -1
  95. data/app/views/spotlight/catalog/_edit_sidecar.html.erb +1 -1
  96. data/app/views/spotlight/catalog/_index_compact_default.html.erb +1 -1
  97. data/app/views/spotlight/catalog/_reindex_progress_panel.html.erb +6 -6
  98. data/app/views/spotlight/catalog/select_image.html.erb +1 -1
  99. data/app/views/spotlight/contact_mailer/report_problem.html.erb +2 -2
  100. data/app/views/spotlight/exhibits/_contact.html.erb +2 -2
  101. data/app/views/spotlight/exhibits/_delete.html.erb +2 -2
  102. data/app/views/spotlight/exhibits/_exhibit_card.html.erb +1 -1
  103. data/app/views/spotlight/exhibits/_export.html.erb +1 -1
  104. data/app/views/spotlight/exhibits/_form.html.erb +2 -2
  105. data/app/views/spotlight/exhibits/_languages.html.erb +7 -7
  106. data/app/views/spotlight/exhibits/_missing_exhibits.html.erb +1 -1
  107. data/app/views/spotlight/locks/_lock.html.erb +2 -2
  108. data/app/views/spotlight/metadata_configurations/edit.html.erb +1 -1
  109. data/app/views/spotlight/pages/_order_pages.html.erb +3 -3
  110. data/app/views/spotlight/pages/preview.html.erb +1 -1
  111. data/app/views/spotlight/pages/show.html.erb +2 -2
  112. data/app/views/spotlight/resources/_form.html.erb +1 -1
  113. data/app/views/spotlight/resources/csv_upload/_form.html.erb +1 -1
  114. data/app/views/spotlight/resources/upload/_form.html.erb +1 -1
  115. data/app/views/spotlight/roles/index.html.erb +5 -5
  116. data/app/views/spotlight/search_configurations/_search_fields.html.erb +1 -1
  117. data/app/views/spotlight/search_configurations/edit.html.erb +1 -1
  118. data/app/views/spotlight/searches/index.html.erb +2 -2
  119. data/app/views/spotlight/shared/_configuration_sidebar.html.erb +1 -1
  120. data/app/views/spotlight/shared/_curation_sidebar.html.erb +1 -1
  121. data/app/views/spotlight/shared/_dd3_item.html.erb +1 -1
  122. data/app/views/spotlight/sir_trevor/_sir_trevor_block_array.html.erb +1 -1
  123. data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +1 -1
  124. data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +1 -1
  125. data/app/views/spotlight/sir_trevor/blocks/_featured_pages_block.html.erb +2 -2
  126. data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +1 -1
  127. data/app/views/spotlight/sir_trevor/blocks/_rule_block.html.erb +1 -1
  128. data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +1 -1
  129. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +1 -1
  130. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +1 -1
  131. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +1 -1
  132. data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +1 -1
  133. data/app/views/spotlight/sites/edit_exhibits.html.erb +3 -3
  134. data/app/views/spotlight/translations/_browse_categories.html.erb +2 -2
  135. data/app/views/spotlight/translations/_general.html.erb +21 -21
  136. data/app/views/spotlight/translations/_groups.html.erb +1 -1
  137. data/app/views/spotlight/translations/_metadata.html.erb +8 -8
  138. data/app/views/spotlight/translations/_pages_table.html.erb +2 -2
  139. data/app/views/spotlight/translations/_search_fields.html.erb +13 -13
  140. data/app/views/spotlight/translations/edit.html.erb +5 -5
  141. data/config/importmap.rb +0 -1
  142. data/lib/generators/spotlight/assets/propshaft_generator.rb +0 -1
  143. data/lib/generators/spotlight/templates/solr/conf/admin-extra.html +31 -31
  144. data/lib/spotlight/version.rb +1 -1
  145. data/spec/factories/contact_images.rb +1 -1
  146. data/spec/factories/exhibit_thumbnails.rb +1 -1
  147. data/spec/factories/featured_images.rb +1 -1
  148. data/spec/support/features/test_features_helpers.rb +10 -1
  149. metadata +4 -61
  150. data/app/javascript/spotlight/admin/copy_email_addresses.js +0 -7
  151. data/vendor/assets/javascripts/jquery.waitforimages.min.js +0 -2
@@ -11,4 +11,4 @@
11
11
  <% end %>
12
12
  </tr>
13
13
  </tfoot>
14
- </table>
14
+ </table>
@@ -8,7 +8,7 @@
8
8
  itemscope: true,
9
9
  itemtype: @document.itemtype,
10
10
  class: classes.flatten.join(' ') do %>
11
- <% # header bar for doc items in index view -%>
11
+ <%# header bar for doc items in index view -%>
12
12
  <td class="spotlight-admin-thumbnail">
13
13
  <%= thumbnail %>
14
14
  </td>
@@ -31,6 +31,6 @@
31
31
  </td>
32
32
 
33
33
  <td class="checkbox-toggle">
34
- <%= render partial: 'document_visibility_control', locals: { document: presenter.document} %>
34
+ <%= helpers.render partial: 'document_visibility_control', locals: { document: presenter.document} %>
35
35
  </td>
36
36
  <% end %>
@@ -10,4 +10,4 @@
10
10
  <% if delete_link %>
11
11
  &middot; <%= helpers.exhibit_delete_link page %>
12
12
  <% end %>
13
- </div>
13
+ </div>
@@ -1 +1 @@
1
- <%= top_bar %>
1
+ <%= top_bar %>
@@ -11,4 +11,4 @@
11
11
  </div>
12
12
  <% else %>
13
13
  <%= form.text_field :tag_list, value: form.object.tag_list.to_s %>
14
- <% end %>
14
+ <% end %>
@@ -5,8 +5,8 @@
5
5
  <%= form.text_field field_name, value: selected_tags_value, class: 'tag-selector-input', placeholder: t('.no_js_placeholder'), data: { tag_selector_target: "tagsField" } %>
6
6
  <% end %>
7
7
  <input type="hidden" value="<%= selected_tags_value %>" data-tag-selector-target="initialTags">
8
-
9
- <div class='mb-3'>
8
+
9
+ <div class="mb-3">
10
10
  <div class="tag-selection-wrapper" data-tag-selector-target="tagControlWrapper">
11
11
  <div class="dropdown w-100 mb-3 d-inline-block" data-action="click@window->tag-selector#clickOutside">
12
12
  <div data-tag-selector-target="tagSearchDropdown">
@@ -1,3 +1,3 @@
1
- <h2 class='translation-subheading mt-4'>
1
+ <h2 class="translation-subheading mt-4">
2
2
  <%= text %>
3
3
  </h2>
@@ -55,7 +55,7 @@ module Spotlight
55
55
 
56
56
  def resource_params
57
57
  params.require(:resource).tap { |x| x['type'] ||= resource_class.name }
58
- .permit(:url, :type, *resource_class.stored_attributes[:data], data: params[:resource][:data].try(:keys))
58
+ .permit(:url, :type, *resource_class.stored_attributes[:data], data: params[:resource][:data].try(:keys))
59
59
  end
60
60
  end
61
61
  end
@@ -1,24 +1,31 @@
1
1
  export default class {
2
2
  connect() {
3
- $("[data-action='add-another']").on("click", function(event) {
4
- event.preventDefault();
3
+ $("[data-action='add-another']").on("click", function (event) {
4
+ event.preventDefault()
5
5
 
6
- var templateId = $(this).data('template-id');
6
+ var templateId = $(this).data("template-id")
7
7
 
8
- var template = document.querySelector('#' + templateId);
9
- var clone = document.importNode(template.content, true);
8
+ var template = document.querySelector("#" + templateId)
9
+ var clone = document.importNode(template.content, true)
10
10
 
11
- var count = $(this).closest('.form-group').find('[name="' + $(clone).find('[name]').attr('name') + '"]').length + 1;
12
- $(clone).find('[id]').each(function(index, el) {
13
- $(el).attr('id', $(el).attr('id') + '_' + String(count));
14
- });
11
+ var count =
12
+ $(this)
13
+ .closest(".form-group")
14
+ .find('[name="' + $(clone).find("[name]").attr("name") + '"]')
15
+ .length + 1
16
+ $(clone)
17
+ .find("[id]")
18
+ .each(function (index, el) {
19
+ $(el).attr("id", $(el).attr("id") + "_" + String(count))
20
+ })
15
21
 
16
- $(clone).find('[for]').each(function(index, el) {
17
- $(el).attr('for', $(el).attr('for') + '_' + String(count));
18
- });
22
+ $(clone)
23
+ .find("[for]")
24
+ .each(function (index, el) {
25
+ $(el).attr("for", $(el).attr("for") + "_" + String(count))
26
+ })
19
27
 
20
-
21
- $(clone).insertBefore(this);
22
- });
28
+ $(clone).insertBefore(this)
29
+ })
23
30
  }
24
31
  }
@@ -1,38 +1,40 @@
1
- import Iiif from 'spotlight/admin/iiif'
1
+ import Iiif from "spotlight/admin/iiif"
2
2
 
3
3
  export function addImageSelector(input, panel, manifestUrl, initialize) {
4
4
  if (!manifestUrl) {
5
- showNonIiifAlert(input);
6
- return;
5
+ showNonIiifAlert(input)
6
+ return
7
7
  }
8
- var cropper = input.data('iiifCropper');
9
- $.ajax(manifestUrl).done(
10
- function(manifest) {
11
- var iiifManifest = new Iiif(manifestUrl, manifest);
8
+ var cropper = input.data("iiifCropper")
9
+ $.ajax(manifestUrl).done(function (manifest) {
10
+ var iiifManifest = new Iiif(manifestUrl, manifest)
12
11
 
13
- var thumbs = iiifManifest.imagesArray();
12
+ var thumbs = iiifManifest.imagesArray()
14
13
 
15
- hideNonIiifAlert(input);
14
+ hideNonIiifAlert(input)
16
15
 
17
- if (initialize) {
18
- cropper.setIiifFields(thumbs[0]);
19
- panel.multiImageSelector(); // Clears out existing selector
20
- }
16
+ if (initialize) {
17
+ cropper.setIiifFields(thumbs[0])
18
+ panel.multiImageSelector() // Clears out existing selector
19
+ }
21
20
 
22
- if(thumbs.length > 1) {
23
- panel.show();
24
- panel.multiImageSelector(thumbs, function(selectorImage) {
25
- cropper.setIiifFields(selectorImage);
26
- }, cropper.iiifImageField.val());
27
- }
21
+ if (thumbs.length > 1) {
22
+ panel.show()
23
+ panel.multiImageSelector(
24
+ thumbs,
25
+ function (selectorImage) {
26
+ cropper.setIiifFields(selectorImage)
27
+ },
28
+ cropper.iiifImageField.val(),
29
+ )
28
30
  }
29
- );
31
+ })
30
32
  }
31
33
 
32
- function showNonIiifAlert(input){
33
- input.parent().prev('[data-behavior="non-iiif-alert"]').show();
34
+ function showNonIiifAlert(input) {
35
+ input.parent().prev('[data-behavior="non-iiif-alert"]').show()
34
36
  }
35
37
 
36
- function hideNonIiifAlert(input){
37
- input.parent().prev('[data-behavior="non-iiif-alert"]').hide();
38
- }
38
+ function hideNonIiifAlert(input) {
39
+ input.parent().prev('[data-behavior="non-iiif-alert"]').hide()
40
+ }
@@ -1,77 +1,81 @@
1
1
  export default class {
2
2
  connect() {
3
- $("[data-expanded-add-button]").each((_i, el) => this.addExpandBehaviorToButton($(el)))
3
+ $("[data-expanded-add-button]").each((_i, el) =>
4
+ this.addExpandBehaviorToButton($(el)),
5
+ )
4
6
  }
5
7
 
6
- addExpandBehaviorToButton(button){
8
+ addExpandBehaviorToButton(button) {
7
9
  var settings = {
8
- speed: (button.data('speed') || 450),
9
- animate_width: (button.data('animate_width') || 425)
10
+ speed: button.data("speed") || 450,
11
+ animate_width: button.data("animate_width") || 425,
10
12
  }
11
- var target = $(button.data('field-target'));
12
- var save = $("input[data-behavior='save']", target);
13
- var cancel = $("input[data-behavior='cancel']", target);
14
- var input = $("input[type='text']", target);
15
- var original_width = button.outerWidth();
16
- var expanded = false;
13
+ var target = $(button.data("field-target"))
14
+ var save = $("input[data-behavior='save']", target)
15
+ var cancel = $("input[data-behavior='cancel']", target)
16
+ var input = $("input[type='text']", target)
17
+ var original_width = button.outerWidth()
18
+ var expanded = false
17
19
 
18
20
  // Animate button open when the mouse enters or
19
21
  // the button is given focus (i.e. clicked/tabbed)
20
- button.on("mouseenter focus", function(){
21
- expandButton();
22
- });
22
+ button.on("mouseenter focus", function () {
23
+ expandButton()
24
+ })
23
25
 
24
26
  // Don't allow blank titles
25
- save.on('click', function(){
26
- if ( inputEmpty() ) {
27
- return false;
27
+ save.on("click", function () {
28
+ if (inputEmpty()) {
29
+ return false
28
30
  }
29
- });
31
+ })
30
32
 
31
33
  // Empty input and collapse
32
34
  // button on cancel click
33
- cancel.on('click', function(e){
34
- e.preventDefault();
35
- input.val('');
36
- collapseButton();
37
- });
35
+ cancel.on("click", function (e) {
36
+ e.preventDefault()
37
+ input.val("")
38
+ collapseButton()
39
+ })
38
40
 
39
41
  // Collapse the button on when
40
42
  // an empty input loses focus
41
- input.on("blur", function(){
42
- if ( inputEmpty() ) {
43
- collapseButton();
43
+ input.on("blur", function () {
44
+ if (inputEmpty()) {
45
+ collapseButton()
44
46
  }
45
- });
46
- function expandButton(){
47
- // If this has not yet been expanded, recalculate original_width to
47
+ })
48
+ function expandButton() {
49
+ // If this has not yet been expanded, recalculate original_width to
48
50
  // handle things that may have been originally hidden.
49
51
  if (!expanded) {
50
- original_width = button.outerWidth();
52
+ original_width = button.outerWidth()
51
53
  }
52
- if(button.outerWidth() <= (original_width + 5)) {
53
- expanded = true;
54
+ if (button.outerWidth() <= original_width + 5) {
55
+ expanded = true
54
56
  button.animate(
55
- {width: settings.animate_width + 'px'}, settings.speed, function(){
56
- target.show(0, function(){
57
- input.focus();
57
+ { width: settings.animate_width + "px" },
58
+ settings.speed,
59
+ function () {
60
+ target.show(0, function () {
61
+ input.focus()
58
62
  // Set the button to auto width to make
59
63
  // sure it has room for any inputs
60
- button.width("auto");
64
+ button.width("auto")
61
65
  // Explicitly set the width of the button
62
66
  // so the close animation works properly
63
- button.width(button.width());
64
- });
65
- }
67
+ button.width(button.width())
68
+ })
69
+ },
66
70
  )
67
71
  }
68
72
  }
69
- function collapseButton(){
70
- target.hide();
71
- button.animate({width: original_width + 'px'}, settings.speed);
73
+ function collapseButton() {
74
+ target.hide()
75
+ button.animate({ width: original_width + "px" }, settings.speed)
72
76
  }
73
- function inputEmpty(){
74
- return $.trim(input.val()) == "";
77
+ function inputEmpty() {
78
+ return $.trim(input.val()) == ""
75
79
  }
76
80
  }
77
81
  }
@@ -1,62 +1,76 @@
1
1
  export default class {
2
2
  connect() {
3
3
  // Add Select/Deselect all input behavior
4
- this.addCheckboxToggleBehavior();
5
- this.addEnableToggleBehavior();
4
+ this.addCheckboxToggleBehavior()
5
+ this.addEnableToggleBehavior()
6
6
  }
7
-
8
- // Add Select/Deselect all behavior for metadata field names for a given view e.g. Item details.
7
+
8
+ // Add Select/Deselect all behavior for metadata field names for a given view e.g. Item details.
9
9
  addCheckboxToggleBehavior() {
10
- $("[data-behavior='metadata-select']").each(function(){
11
- var selectCheckbox = $(this);
12
- var parentCell = selectCheckbox.parents("th");
13
- var table = parentCell.closest("table");
14
- var columnRows = $("tr td:nth-child(" + (parentCell.index() + 1) + ")", table);
15
- var checkboxes = $("input[type='checkbox']", columnRows);
16
- updateSelectAllInput(selectCheckbox, columnRows);
10
+ $("[data-behavior='metadata-select']").each(function () {
11
+ var selectCheckbox = $(this)
12
+ var parentCell = selectCheckbox.parents("th")
13
+ var table = parentCell.closest("table")
14
+ var columnRows = $(
15
+ "tr td:nth-child(" + (parentCell.index() + 1) + ")",
16
+ table,
17
+ )
18
+ var checkboxes = $("input[type='checkbox']", columnRows)
19
+ updateSelectAllInput(selectCheckbox, columnRows)
17
20
  // Add the check/uncheck behavior to the select/deselect all checkbox
18
- selectCheckbox.on('click', function(e){
19
- var allChecked = allCheckboxesChecked(columnRows);
20
- columnRows.each(function(){
21
- $("input[type='checkbox']", $(this)).prop('checked', !allChecked);
22
- });
23
- });
21
+ selectCheckbox.on("click", function () {
22
+ var allChecked = allCheckboxesChecked(columnRows)
23
+ columnRows.each(function () {
24
+ $("input[type='checkbox']", $(this)).prop("checked", !allChecked)
25
+ })
26
+ })
24
27
  // When a single checkbox is selected/unselected, the "All" checkbox should be updated accordingly.
25
- checkboxes.each(function(){
26
- $(this).on('change', function(){
27
- updateSelectAllInput(selectCheckbox, columnRows);
28
- });
29
- });
30
- });
28
+ checkboxes.each(function () {
29
+ $(this).on("change", function () {
30
+ updateSelectAllInput(selectCheckbox, columnRows)
31
+ })
32
+ })
33
+ })
31
34
 
32
35
  // Check number of checkboxes against the number of checked
33
36
  // checkboxes to determine if all of them are checked or not
34
37
  function allCheckboxesChecked(elements) {
35
- return ($("input[type='checkbox']", elements).length == $("input[type='checkbox']:checked", elements).length)
38
+ return (
39
+ $("input[type='checkbox']", elements).length ==
40
+ $("input[type='checkbox']:checked", elements).length
41
+ )
36
42
  }
37
43
 
38
44
  // Check or uncheck the "All" checkbox for each view column, e.g. Item details, List, etc.
39
45
  function updateSelectAllInput(checkbox, elements) {
40
- if ( allCheckboxesChecked(elements) ) {
41
- checkbox.prop('checked', true);
46
+ if (allCheckboxesChecked(elements)) {
47
+ checkbox.prop("checked", true)
42
48
  } else {
43
- checkbox.prop('checked', false);
49
+ checkbox.prop("checked", false)
44
50
  }
45
51
  }
46
52
  }
47
-
53
+
48
54
  addEnableToggleBehavior() {
49
- $("[data-behavior='enable-feature']").each(function(){
50
- var checkbox = $(this);
51
- var target = $($(this).data('target'));
55
+ $("[data-behavior='enable-feature']").each(function () {
56
+ var checkbox = $(this)
57
+ var target = $($(this).data("target"))
52
58
 
53
- checkbox.on('change', function() {
54
- if ($(this).is(':checked')) {
55
- target.find('input:checkbox').not("[data-behavior='enable-feature']").prop('checked', true).attr('disabled', false);
59
+ checkbox.on("change", function () {
60
+ if ($(this).is(":checked")) {
61
+ target
62
+ .find("input:checkbox")
63
+ .not("[data-behavior='enable-feature']")
64
+ .prop("checked", true)
65
+ .attr("disabled", false)
56
66
  } else {
57
- target.find('input:checkbox').not("[data-behavior='enable-feature']").prop('checked', false).attr('disabled', true);
67
+ target
68
+ .find("input:checkbox")
69
+ .not("[data-behavior='enable-feature']")
70
+ .prop("checked", false)
71
+ .attr("disabled", true)
58
72
  }
59
- });
60
- });
73
+ })
74
+ })
61
75
  }
62
- }
76
+ }
@@ -1,104 +1,112 @@
1
- import { fetchAutocompleteJSON } from 'spotlight/admin/search_typeahead';
2
-
3
- (function ($){
4
- SirTrevor.BlockMixins.Autocompleteable = {
1
+ import { fetchAutocompleteJSON } from "spotlight/admin/search_typeahead"
2
+ ;(function ($) {
3
+ ;((SirTrevor.BlockMixins.Autocompleteable = {
5
4
  mixinName: "Autocompleteable",
6
5
  preload: true,
7
6
 
8
- initializeAutocompleteable: function() {
9
- this.on("onRender", this.addAutocompletetoSirTrevorForm);
7
+ initializeAutocompleteable: function () {
8
+ this.on("onRender", this.addAutocompletetoSirTrevorForm)
10
9
 
11
- if (this['autocomplete_url'] === undefined) {
12
- this.autocomplete_url = function() { return $('form[data-autocomplete-url]').data('autocomplete-url'); };
10
+ if (this["autocomplete_url"] === undefined) {
11
+ this.autocomplete_url = function () {
12
+ return $("form[data-autocomplete-url]").data("autocomplete-url")
13
+ }
13
14
  }
14
15
 
15
- if (this['autocomplete_fetch'] === undefined) {
16
- this.autocomplete_fetch = this.fetchAutocompleteResults;
16
+ if (this["autocomplete_fetch"] === undefined) {
17
+ this.autocomplete_fetch = this.fetchAutocompleteResults
17
18
  }
18
19
 
19
- if (this['transform_autocomplete_results'] === undefined) {
20
+ if (this["transform_autocomplete_results"] === undefined) {
20
21
  this.transform_autocomplete_results = (val) => val
21
22
  }
22
23
 
23
- if (this['highlight'] === undefined) {
24
- this.highlight = function(value) {
25
- if (!value) return '';
26
- const queryValue = this.getQueryValue().trim();
27
- return queryValue ? value.replace(new RegExp(queryValue, 'gi'), '<strong>$&</strong>') : value;
24
+ if (this["highlight"] === undefined) {
25
+ this.highlight = function (value) {
26
+ if (!value) return ""
27
+ const queryValue = this.getQueryValue().trim()
28
+ return queryValue
29
+ ? value.replace(new RegExp(queryValue, "gi"), "<strong>$&</strong>")
30
+ : value
28
31
  }
29
32
  }
30
33
 
31
- if (this['autocomplete_control'] === undefined) {
32
- this.autocomplete_control = function() {
33
- const autocompleteID = this.autocompleteID();
34
+ if (this["autocomplete_control"] === undefined) {
35
+ this.autocomplete_control = function () {
36
+ const autocompleteID = this.autocompleteID()
34
37
  return `
35
38
  <auto-complete src="${this.autocomplete_url()}" for="${autocompleteID}-popup" fetch-on-empty>
36
39
  <input type="text" name="${autocompleteID}" placeholder="${i18n.t("blocks:autocompleteable:placeholder")}" data-default-typeahead>
37
40
  <ul id="${autocompleteID}-popup"></ul>
38
41
  <div id="${autocompleteID}-popup-feedback" class="visually-hidden"></div>
39
42
  </auto-complete>
40
- ` };
43
+ `
44
+ }
41
45
  }
42
46
 
43
- if (this['autocomplete_element_template'] === undefined) {
44
- this.autocomplete_element_template = function(item) {
47
+ if (this["autocomplete_element_template"] === undefined) {
48
+ this.autocomplete_element_template = function (item) {
45
49
  return `<li role="option" data-autocomplete-value="${item.id}">${this.autocomplete_template(item)}</li>`
46
50
  }
47
51
  }
48
52
  },
49
53
 
50
- queryTokenizer: function(query) {
51
- return query.trim().toLowerCase().split(/\s+/).filter(Boolean);
54
+ queryTokenizer: function (query) {
55
+ return query.trim().toLowerCase().split(/\s+/).filter(Boolean)
52
56
  },
53
57
 
54
- filterResults: function(data, query) {
55
- const queryStrings = this.queryTokenizer(query);
56
- return data.filter(item => {
57
- const lowerTitle = item.title.toLowerCase();
58
- return queryStrings.some(queryString => lowerTitle.includes(queryString));
59
- });
58
+ filterResults: function (data, query) {
59
+ const queryStrings = this.queryTokenizer(query)
60
+ return data.filter((item) => {
61
+ const lowerTitle = item.title.toLowerCase()
62
+ return queryStrings.some((queryString) =>
63
+ lowerTitle.includes(queryString),
64
+ )
65
+ })
60
66
  },
61
67
 
62
- fetchAutocompleteResults: async function(url) {
63
- const result = await fetchAutocompleteJSON(url);
64
- const transformed = this.transform_autocomplete_results(result);
65
- this.fetchedData = {};
66
- transformed.map(item => this.fetchedData[item.id] = item);
67
- return transformed.map(item => this.autocomplete_element_template(item)).join('');
68
+ fetchAutocompleteResults: async function (url) {
69
+ const result = await fetchAutocompleteJSON(url)
70
+ const transformed = this.transform_autocomplete_results(result)
71
+ this.fetchedData = {}
72
+ transformed.map((item) => (this.fetchedData[item.id] = item))
73
+ return transformed
74
+ .map((item) => this.autocomplete_element_template(item))
75
+ .join("")
68
76
  },
69
77
 
70
- fetchOnceAndFilterLocalResults: async function(url) {
78
+ fetchOnceAndFilterLocalResults: async function (url) {
71
79
  if (this.fetchedData === undefined) {
72
- await this.fetchAutocompleteResults(url);
80
+ await this.fetchAutocompleteResults(url)
73
81
  }
74
- const query = url.searchParams.get('q');
75
- const data = Object.values(this.fetchedData);
76
- const filteredData = query ? this.filterResults(data, query) : data;
77
- return filteredData.map(item => this.autocomplete_element_template(item)).join('');
82
+ const query = url.searchParams.get("q")
83
+ const data = Object.values(this.fetchedData)
84
+ const filteredData = query ? this.filterResults(data, query) : data
85
+ return filteredData
86
+ .map((item) => this.autocomplete_element_template(item))
87
+ .join("")
78
88
  },
79
89
 
80
- autocompleteID: function() {
81
- return this.blockID + '-autocomplete';
90
+ autocompleteID: function () {
91
+ return this.blockID + "-autocomplete"
82
92
  },
83
93
 
84
- getQueryValue: function() {
85
- const completer = this.inner.querySelector("auto-complete > input");
86
- return completer.value;
94
+ getQueryValue: function () {
95
+ const completer = this.inner.querySelector("auto-complete > input")
96
+ return completer.value
87
97
  },
88
98
 
89
- addAutocompletetoSirTrevorForm: function() {
90
- const completer = this.inner.querySelector("auto-complete");
91
- completer.fetchResult = this.autocomplete_fetch.bind(this);
92
- completer.addEventListener('auto-complete-change', (e) => {
93
- const data = this.fetchedData[e.relatedTarget.value];
99
+ addAutocompletetoSirTrevorForm: function () {
100
+ const completer = this.inner.querySelector("auto-complete")
101
+ completer.fetchResult = this.autocomplete_fetch.bind(this)
102
+ completer.addEventListener("auto-complete-change", (e) => {
103
+ const data = this.fetchedData[e.relatedTarget.value]
94
104
  if (e.relatedTarget.value && data) {
95
- e.value = e.relatedTarget.value = '';
96
- this.createItemPanel({ ...data, display: "true" });
105
+ e.value = e.relatedTarget.value = ""
106
+ this.createItemPanel({ ...data, display: "true" })
97
107
  }
98
- });
108
+ })
99
109
  },
100
- },
101
-
102
-
103
- SirTrevor.Block.prototype.availableMixins.push("autocompleteable");
104
- })(jQuery);
110
+ }),
111
+ SirTrevor.Block.prototype.availableMixins.push("autocompleteable"))
112
+ })(jQuery)