blacklight-spotlight 5.3.2 → 6.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +20 -4
- data/Rakefile +1 -2
- data/app/assets/javascripts/spotlight/spotlight.esm.js +2168 -4560
- data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
- data/app/assets/javascripts/spotlight/spotlight.js +2167 -4559
- data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
- data/app/assets/stylesheets/spotlight/_blacklight_overrides.scss +4 -0
- data/app/assets/stylesheets/spotlight/_browse.scss +0 -4
- data/app/assets/stylesheets/spotlight/{_collapse_toggle.scss → _collapse_toggle.css} +2 -2
- data/app/assets/stylesheets/spotlight/_exhibit_admin.scss +8 -0
- data/app/assets/stylesheets/spotlight/_exhibits_index.scss +2 -1
- data/app/assets/stylesheets/spotlight/_footer.scss +2 -2
- data/app/assets/stylesheets/spotlight/_header.scss +8 -8
- data/app/assets/stylesheets/spotlight/_pages.scss +1 -1
- data/app/assets/stylesheets/spotlight/_slideshow_block.scss +15 -0
- data/app/assets/stylesheets/spotlight/_spotlight.scss +1 -1
- data/app/assets/stylesheets/spotlight/_translations.scss +3 -3
- data/app/assets/stylesheets/spotlight/_uploaded_items_block.css +7 -0
- data/app/assets/stylesheets/spotlight/_variables.css +15 -0
- data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +0 -76
- data/app/components/blacklight/icons/pause_component.rb +15 -0
- data/app/components/blacklight/icons/play_arrow_component.rb +15 -0
- data/app/components/spotlight/analytics/dashboard_component.html.erb +1 -1
- data/app/components/spotlight/document_admin_table_component.html.erb +2 -2
- data/app/components/spotlight/masthead_component.html.erb +18 -0
- data/app/components/spotlight/masthead_component.rb +46 -0
- data/app/components/spotlight/save_search_component.html.erb +1 -1
- data/app/components/spotlight/solr_document_legacy_embed_component.html.erb +0 -4
- data/app/components/spotlight/solr_document_legacy_embed_component.rb +2 -2
- data/app/components/spotlight/tag_selector_component.html.erb +1 -1
- data/app/components/spotlight/tag_selector_component.rb +3 -2
- data/app/controllers/concerns/spotlight/controller.rb +15 -14
- data/app/controllers/concerns/spotlight/search_helper.rb +2 -5
- data/app/controllers/spotlight/browse_controller.rb +1 -2
- data/app/controllers/spotlight/catalog_controller.rb +1 -2
- data/app/controllers/spotlight/concerns/application_controller.rb +4 -6
- data/app/controllers/spotlight/exhibits_controller.rb +22 -10
- data/app/controllers/spotlight/lock_controller.rb +1 -1
- data/app/controllers/spotlight/pages_controller.rb +11 -11
- data/app/controllers/spotlight/resources_controller.rb +1 -1
- data/app/helpers/spotlight/application_helper.rb +14 -3
- data/app/helpers/spotlight/main_app_helpers.rb +2 -2
- data/app/javascript/spotlight/admin/add_another.js +37 -25
- data/app/javascript/spotlight/admin/add_image_selector.js +43 -26
- data/app/javascript/spotlight/admin/add_new_button.js +51 -36
- data/app/javascript/spotlight/admin/blacklight_configuration.js +76 -54
- data/app/javascript/spotlight/admin/block_mixins/autocompleteable.js +102 -101
- data/app/javascript/spotlight/admin/block_mixins/formable.js +91 -75
- data/app/javascript/spotlight/admin/block_mixins/plustextable.js +46 -48
- data/app/javascript/spotlight/admin/blocks/block.js +27 -28
- data/app/javascript/spotlight/admin/blocks/browse_block.js +14 -10
- data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +14 -10
- data/app/javascript/spotlight/admin/blocks/pages_block.js +5 -4
- data/app/javascript/spotlight/admin/blocks/resources_block.js +61 -41
- data/app/javascript/spotlight/admin/blocks/search_result_block.js +24 -7
- data/app/javascript/spotlight/admin/blocks/solr_documents_base_block.js +103 -50
- data/app/javascript/spotlight/admin/blocks/solr_documents_carousel_block.js +50 -26
- data/app/javascript/spotlight/admin/blocks/solr_documents_features_block.js +47 -23
- data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +35 -19
- data/app/javascript/spotlight/admin/crop.js +146 -66
- data/app/javascript/spotlight/admin/croppable.js +5 -4
- data/app/javascript/spotlight/admin/croppable_modal.js +67 -32
- data/app/javascript/spotlight/admin/edit_in_place.js +69 -54
- data/app/javascript/spotlight/admin/exhibits.js +92 -45
- data/app/javascript/spotlight/admin/form_observer.js +92 -78
- data/app/javascript/spotlight/admin/multi_image_selector.js +201 -153
- data/app/javascript/spotlight/admin/pages.js +13 -7
- data/app/javascript/spotlight/admin/progress_monitor.js +65 -50
- data/app/javascript/spotlight/admin/readonly_checkbox.js +7 -3
- data/app/javascript/spotlight/admin/search_typeahead.js +20 -11
- data/app/javascript/spotlight/admin/select_related_input.js +23 -23
- data/app/javascript/spotlight/admin/serialize_json.js +120 -0
- data/app/javascript/spotlight/admin/sir-trevor/block_controls.js +24 -11
- data/app/javascript/spotlight/admin/sir-trevor/block_limits.js +9 -6
- data/app/javascript/spotlight/admin/sir-trevor/locales.js +2 -2
- data/app/javascript/spotlight/admin/spotlight_nestable.js +2 -5
- data/app/javascript/spotlight/admin/translation_progress.js +18 -13
- data/app/javascript/spotlight/admin/users.js +151 -64
- data/app/javascript/spotlight/user/carousel.js +104 -32
- data/app/javascript/spotlight/user/clear_form_button.js +24 -14
- data/app/javascript/spotlight/user/index.js +0 -2
- data/app/javascript/spotlight/user/zpr_links.js +99 -40
- data/app/jobs/concerns/spotlight/gather_documents.rb +1 -1
- data/app/jobs/spotlight/add_uploads_from_csv.rb +29 -8
- data/app/models/concerns/spotlight/access_controls_enforcement_search_builder.rb +13 -2
- data/app/models/concerns/spotlight/browse_category_search_builder.rb +3 -3
- data/app/models/concerns/spotlight/exhibit_documents.rb +2 -2
- data/app/models/concerns/spotlight/sitemap.rb +2 -2
- data/app/models/concerns/spotlight/solr_document/finder.rb +2 -2
- data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +2 -1
- data/app/models/spotlight/blacklight_configuration.rb +5 -3
- data/app/models/spotlight/contact_email.rb +2 -2
- data/app/models/spotlight/exhibit.rb +28 -0
- data/app/models/spotlight/featured_image.rb +1 -1
- data/app/models/spotlight/field_metadata.rb +10 -5
- data/app/models/spotlight/job_tracker.rb +2 -2
- data/app/models/spotlight/main_navigation.rb +2 -2
- data/app/models/spotlight/page.rb +3 -3
- data/app/models/spotlight/resources/iiif_harvester.rb +7 -4
- data/app/models/spotlight/resources/iiif_manifest_metadata.rb +1 -3
- data/app/models/spotlight/resources/iiif_service.rb +21 -6
- data/app/models/spotlight/search.rb +5 -5
- data/app/services/spotlight/bulk_updates_csv_template_service.rb +1 -1
- data/app/services/spotlight/etl/pipeline.rb +2 -2
- data/app/services/spotlight/etl/step.rb +2 -2
- data/app/views/catalog/_remove_tags.html.erb +2 -2
- data/app/views/layouts/spotlight/base.html.erb +3 -6
- data/app/views/layouts/spotlight/spotlight.html.erb +2 -2
- data/app/views/shared/_analytics.html.erb +4 -3
- data/app/views/shared/_masthead.html.erb +2 -18
- data/app/views/spotlight/about_pages/_empty.html.erb +1 -1
- data/app/views/spotlight/about_pages/_sidebar.html.erb +10 -8
- data/app/views/spotlight/browse/_search.html.erb +2 -2
- data/app/views/spotlight/browse/_search_box.html.erb +6 -14
- data/app/views/spotlight/browse/index.html.erb +1 -1
- data/app/views/spotlight/browse/show.html.erb +1 -1
- data/app/views/spotlight/catalog/_document_admin_table.html.erb +1 -1
- data/app/views/spotlight/catalog/edit.html.erb +1 -1
- data/app/views/spotlight/dashboards/_page.html.erb +1 -1
- data/app/views/spotlight/exhibits/_exhibit_card.html.erb +3 -1
- data/app/views/spotlight/exhibits/_export.html.erb +17 -1
- data/app/views/spotlight/exhibits/_form.html.erb +20 -4
- data/app/views/spotlight/exhibits/_missing_exhibits.html.erb +3 -3
- data/app/views/spotlight/exhibits/index.html.erb +21 -8
- data/app/views/spotlight/feature_pages/_empty.html.erb +1 -1
- data/app/views/spotlight/feature_pages/_sidebar.html.erb +17 -15
- data/app/views/spotlight/home_pages/_empty.html.erb +7 -7
- data/app/views/spotlight/pages/show.html.erb +1 -0
- data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +5 -16
- data/app/views/spotlight/sir_trevor/blocks/_embedded_document.html.erb +3 -5
- data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +11 -2
- data/app/views/spotlight/sites/_exhibit.html.erb +1 -1
- data/config/locales/spotlight.ar.yml +1 -2
- data/config/locales/spotlight.de.yml +1 -2
- data/config/locales/spotlight.en.yml +39 -6
- data/config/locales/spotlight.es.yml +1 -2
- data/config/locales/spotlight.fr.yml +1 -2
- data/config/locales/spotlight.it.yml +1 -2
- data/config/locales/spotlight.ja.yml +39 -0
- data/config/locales/spotlight.zh.yml +1 -2
- data/db/migrate/20261007133748_add_discovery_enabled_to_spotlight_exhibits.rb +5 -0
- data/lib/generators/spotlight/assets/importmap_generator.rb +2 -10
- data/lib/generators/spotlight/assets/propshaft_generator.rb +5 -4
- data/lib/generators/spotlight/install_generator.rb +2 -4
- data/lib/generators/spotlight/templates/catalog_controller.rb +0 -1
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +18 -4
- data/lib/generators/spotlight/templates/solr/conf/schema.xml +4 -3
- data/lib/generators/spotlight/templates/solr/conf/solrconfig.xml +3 -8
- data/lib/migration/page_language.rb +0 -2
- data/lib/spotlight/engine.rb +23 -7
- data/lib/spotlight/search_state.rb +7 -11
- data/lib/spotlight/version.rb +1 -1
- data/lib/spotlight.rb +1 -1
- data/spec/support/features/capybara_wait_metadata_helper.rb +3 -1
- data/spec/support/features/test_features_helpers.rb +24 -1
- data/spec/support/iiif_manifest_fixtures.rb +33 -0
- data/spec/support/stub_dns_resolution.rb +12 -0
- metadata +38 -58
- data/app/assets/stylesheets/spotlight/_uploaded_items_block.scss +0 -7
- data/app/assets/stylesheets/spotlight/_variables.scss +0 -13
- data/app/components/blacklight/icons/arrow_alt_circle_left_component.rb +0 -15
- data/app/components/blacklight/icons/arrow_alt_circle_right_component.rb +0 -15
- data/app/components/spotlight/icon_component.rb +0 -13
- data/app/javascript/spotlight/user/browse_group_categories.js +0 -54
- data/app/models/concerns/spotlight/resources/web.rb +0 -38
- data/app/services/spotlight/iiif_resource_resolver.rb +0 -78
- data/app/views/shared/_exhibit_navbar.html.erb +0 -2
- data/app/views/shared/_header_navbar.html.erb +0 -6
- data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +0 -23
- data/app/views/spotlight/catalog/_admin_thumbnail_default.html.erb +0 -7
- data/app/views/spotlight/catalog/_document_row.html.erb +0 -2
- data/app/views/spotlight/catalog/_index_compact_default.html.erb +0 -21
- data/lib/generators/spotlight/templates/javascript/jquery-shim.js +0 -1
- data/vendor/assets/javascripts/tiny-slider.js +0 -3221
- data/vendor/assets/stylesheets/tiny-slider.css +0 -1
- /data/app/assets/stylesheets/spotlight/{_breadcrumbs.scss → _breadcrumbs.css} +0 -0
- /data/app/assets/stylesheets/spotlight/{_croppable.scss → _croppable.css} +0 -0
- /data/app/assets/stylesheets/spotlight/{_modals.scss → _modals.css} +0 -0
- /data/app/assets/stylesheets/spotlight/{_utilities.scss → _utilities.css} +0 -0
|
@@ -17,8 +17,7 @@ module Spotlight
|
|
|
17
17
|
helper_method :get_search_results, :search_results, :fetch, :page_collection_name
|
|
18
18
|
|
|
19
19
|
before_action do
|
|
20
|
-
blacklight_config.action_mapping.
|
|
21
|
-
blacklight_config.action_mapping.show = blacklight_config.index
|
|
20
|
+
blacklight_config.action_mapping.show.top_level_config = :index
|
|
22
21
|
blacklight_config.view.gallery.classes = 'row-cols-2 row-cols-md-4' unless @page&.display_sidebar
|
|
23
22
|
end
|
|
24
23
|
|
|
@@ -118,10 +117,11 @@ module Spotlight
|
|
|
118
117
|
|
|
119
118
|
# Add a Page specific search_results method that takes user params as
|
|
120
119
|
# an option and passes that off to the search service to get results
|
|
121
|
-
# @param [Hash] the query parameters
|
|
120
|
+
# @param [Hash] user_params the query parameters
|
|
122
121
|
# @return [Object] the search results object from the configured search service
|
|
123
122
|
def search_results(user_params)
|
|
124
|
-
|
|
123
|
+
state = search_state_class.new(user_params, blacklight_config, self)
|
|
124
|
+
search_service_class.new(config: blacklight_config, search_state: state, **search_service_context).search_results
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
def undo_link
|
|
@@ -197,13 +197,13 @@ module Spotlight
|
|
|
197
197
|
|
|
198
198
|
def redirect_page_to_related_locale_version
|
|
199
199
|
pages_for_id = current_exhibit.pages.find(params[:id])
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
default_page = pages_for_id.default_locale_page || pages_for_id
|
|
201
|
+
target = default_page.translated_page_for(I18n.locale) || pages_for_id.default_locale_page
|
|
202
|
+
raise ActiveRecord::RecordNotFound unless target
|
|
203
|
+
|
|
204
|
+
# Pass the locale explicitly. A host app route default (e.g., `locale: nil`) overrides default_url_options.
|
|
205
|
+
locale = target.locale unless target.default_locale?
|
|
206
|
+
redirect_to polymorphic_path([current_exhibit, target], locale:)
|
|
207
207
|
end
|
|
208
208
|
end
|
|
209
209
|
end
|
|
@@ -28,7 +28,7 @@ module Spotlight
|
|
|
28
28
|
redirect_to spotlight.admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
|
|
29
29
|
else
|
|
30
30
|
flash[:error] = @resource.errors.full_messages.to_sentence if @resource.errors.present?
|
|
31
|
-
render action: 'new'
|
|
31
|
+
render action: 'new', status: :unprocessable_content
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
alias update create
|
|
@@ -45,7 +45,7 @@ module Spotlight
|
|
|
45
45
|
initial_exception = nil
|
|
46
46
|
|
|
47
47
|
([self] + additional_locale_routing_scopes).each do |scope|
|
|
48
|
-
return scope.
|
|
48
|
+
return scope.url_for(params.to_unsafe_h.merge(locale:))
|
|
49
49
|
rescue ActionController::UrlGenerationError => e
|
|
50
50
|
initial_exception ||= e
|
|
51
51
|
end
|
|
@@ -59,9 +59,9 @@ module Spotlight
|
|
|
59
59
|
|
|
60
60
|
# Can search for named routes directly in the main app, omitting
|
|
61
61
|
# the "main_app." prefix
|
|
62
|
-
def method_missing(method,
|
|
62
|
+
def method_missing(method, *, &)
|
|
63
63
|
if main_app_url_helper?(method)
|
|
64
|
-
main_app.send(method, *
|
|
64
|
+
main_app.send(method, *)
|
|
65
65
|
else
|
|
66
66
|
super
|
|
67
67
|
end
|
|
@@ -93,6 +93,17 @@ module Spotlight
|
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
+
##
|
|
97
|
+
# Helper to search the exhibit with a saved search's query. Falls back to the
|
|
98
|
+
# default search field so that a search without a query still lands on the
|
|
99
|
+
# results page instead of being redirected to the exhibit home page
|
|
100
|
+
def path_to_saved_search(search)
|
|
101
|
+
spotlight.search_exhibit_catalog_path(
|
|
102
|
+
search.exhibit,
|
|
103
|
+
search.query_params.presence || { search_field: search.blacklight_config.default_search_field.key }
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
96
107
|
##
|
|
97
108
|
# Override Blacklight's #render_document_class to inject a private class
|
|
98
109
|
def render_document_class(document = @document)
|
|
@@ -27,8 +27,8 @@ module Spotlight
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Expecting to upstream this override in https://github.com/projectblacklight/blacklight/pull/3343/files
|
|
30
|
-
def document_presenter(document, view_config: nil, **
|
|
31
|
-
(view_config&.document_presenter_class || document_presenter_class(document)).new(document, self, view_config:, **
|
|
30
|
+
def document_presenter(document, view_config: nil, **)
|
|
31
|
+
(view_config&.document_presenter_class || document_presenter_class(document)).new(document, self, view_config:, **)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def document_presenter_class(_document)
|
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
export default class {
|
|
2
2
|
connect() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var template = document.querySelector("#" + templateId)
|
|
9
|
-
var clone = document.importNode(template.content, true)
|
|
10
|
-
|
|
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
|
-
})
|
|
3
|
+
document
|
|
4
|
+
.querySelectorAll("[data-action='add-another']")
|
|
5
|
+
.forEach((button) => {
|
|
6
|
+
button.addEventListener("click", (event) => {
|
|
7
|
+
event.preventDefault()
|
|
21
8
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
const templateId = button.dataset.templateId
|
|
10
|
+
if (!templateId) return
|
|
11
|
+
|
|
12
|
+
const template = document.getElementById(templateId)
|
|
13
|
+
if (!template) return
|
|
14
|
+
|
|
15
|
+
const clone = document.importNode(template.content, true)
|
|
16
|
+
|
|
17
|
+
const formGroup = button.closest(".form-group")
|
|
18
|
+
if (!formGroup) return
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const firstNamedElement = clone.querySelector("[name]")
|
|
21
|
+
if (!firstNamedElement) return
|
|
22
|
+
|
|
23
|
+
const nameAttr = firstNamedElement.getAttribute("name")
|
|
24
|
+
const existingElements = formGroup.querySelectorAll(
|
|
25
|
+
`[name="${nameAttr}"]`,
|
|
26
|
+
)
|
|
27
|
+
const count = existingElements.length + 1
|
|
28
|
+
|
|
29
|
+
clone.querySelectorAll("[id]").forEach((el) => {
|
|
30
|
+
const currentId = el.getAttribute("id")
|
|
31
|
+
el.setAttribute("id", `${currentId}_${count}`)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
clone.querySelectorAll("[for]").forEach((el) => {
|
|
35
|
+
const currentFor = el.getAttribute("for")
|
|
36
|
+
el.setAttribute("for", `${currentFor}_${count}`)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
button.parentNode.insertBefore(clone, button)
|
|
40
|
+
})
|
|
41
|
+
})
|
|
30
42
|
}
|
|
31
43
|
}
|
|
@@ -1,40 +1,57 @@
|
|
|
1
1
|
import Iiif from "spotlight/admin/iiif"
|
|
2
|
+
import multiImageSelector from "spotlight/admin/multi_image_selector"
|
|
2
3
|
|
|
3
4
|
export function addImageSelector(input, panel, manifestUrl, initialize) {
|
|
4
5
|
if (!manifestUrl) {
|
|
5
6
|
showNonIiifAlert(input)
|
|
6
7
|
return
|
|
7
8
|
}
|
|
8
|
-
var cropper = input.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
var cropper = input.iiifCropper
|
|
10
|
+
fetch(manifestUrl)
|
|
11
|
+
.then(function (response) {
|
|
12
|
+
return response.json()
|
|
13
|
+
})
|
|
14
|
+
.then(function (manifest) {
|
|
15
|
+
var iiifManifest = new Iiif(manifestUrl, manifest)
|
|
16
|
+
|
|
17
|
+
var thumbs = iiifManifest.imagesArray()
|
|
18
|
+
|
|
19
|
+
hideNonIiifAlert(input)
|
|
20
|
+
|
|
21
|
+
if (initialize) {
|
|
22
|
+
cropper.setIiifFields(thumbs[0])
|
|
23
|
+
multiImageSelector(panel) // Clears out existing selector
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (thumbs.length > 1) {
|
|
27
|
+
panel.style.display = ""
|
|
28
|
+
multiImageSelector(
|
|
29
|
+
panel,
|
|
30
|
+
thumbs,
|
|
31
|
+
function (selectorImage) {
|
|
32
|
+
cropper.setIiifFields(selectorImage)
|
|
33
|
+
},
|
|
34
|
+
cropper.iiifImageField.value,
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function findNonIiifAlert(input) {
|
|
41
|
+
if (!input || !input.parentElement) return null
|
|
42
|
+
var prev = input.parentElement.previousElementSibling
|
|
43
|
+
if (prev && prev.matches('[data-behavior="non-iiif-alert"]')) {
|
|
44
|
+
return prev
|
|
45
|
+
}
|
|
46
|
+
return null
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
function showNonIiifAlert(input) {
|
|
35
|
-
|
|
50
|
+
var alert = findNonIiifAlert(input)
|
|
51
|
+
if (alert) alert.style.display = ""
|
|
36
52
|
}
|
|
37
53
|
|
|
38
54
|
function hideNonIiifAlert(input) {
|
|
39
|
-
|
|
55
|
+
var alert = findNonIiifAlert(input)
|
|
56
|
+
if (alert) alert.style.display = "none"
|
|
40
57
|
}
|
|
@@ -1,81 +1,96 @@
|
|
|
1
1
|
export default class {
|
|
2
2
|
connect() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
document
|
|
4
|
+
.querySelectorAll("[data-expanded-add-button]")
|
|
5
|
+
.forEach((el) => this.addExpandBehaviorToButton(el))
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
addExpandBehaviorToButton(button) {
|
|
9
9
|
var settings = {
|
|
10
|
-
speed: button.
|
|
11
|
-
animate_width: button.
|
|
10
|
+
speed: parseInt(button.dataset.speed || "450", 10),
|
|
11
|
+
animate_width: parseInt(button.dataset.animateWidth || "425", 10),
|
|
12
12
|
}
|
|
13
|
-
var target =
|
|
14
|
-
var save =
|
|
15
|
-
var cancel =
|
|
16
|
-
var input =
|
|
17
|
-
var original_width = button.
|
|
13
|
+
var target = document.querySelector(button.dataset.fieldTarget)
|
|
14
|
+
var save = target.querySelector("input[data-behavior='save']")
|
|
15
|
+
var cancel = target.querySelector("input[data-behavior='cancel']")
|
|
16
|
+
var input = target.querySelector("input[type='text']")
|
|
17
|
+
var original_width = button.offsetWidth
|
|
18
18
|
var expanded = false
|
|
19
19
|
|
|
20
20
|
// Animate button open when the mouse enters or
|
|
21
21
|
// the button is given focus (i.e. clicked/tabbed)
|
|
22
|
-
button.
|
|
23
|
-
|
|
24
|
-
})
|
|
22
|
+
button.addEventListener("mouseenter", expandButton)
|
|
23
|
+
button.addEventListener("focus", expandButton)
|
|
25
24
|
|
|
26
25
|
// Don't allow blank titles
|
|
27
|
-
save.
|
|
26
|
+
save.addEventListener("click", function (e) {
|
|
28
27
|
if (inputEmpty()) {
|
|
29
|
-
|
|
28
|
+
e.preventDefault()
|
|
29
|
+
e.stopPropagation()
|
|
30
30
|
}
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
// Empty input and collapse
|
|
34
34
|
// button on cancel click
|
|
35
|
-
cancel.
|
|
35
|
+
cancel.addEventListener("click", function (e) {
|
|
36
36
|
e.preventDefault()
|
|
37
|
-
input.
|
|
37
|
+
input.value = ""
|
|
38
38
|
collapseButton()
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
// Collapse the button on when
|
|
42
42
|
// an empty input loses focus
|
|
43
|
-
input.
|
|
43
|
+
input.addEventListener("blur", function () {
|
|
44
44
|
if (inputEmpty()) {
|
|
45
45
|
collapseButton()
|
|
46
46
|
}
|
|
47
47
|
})
|
|
48
|
+
|
|
48
49
|
function expandButton() {
|
|
49
50
|
// If this has not yet been expanded, recalculate original_width to
|
|
50
51
|
// handle things that may have been originally hidden.
|
|
51
52
|
if (!expanded) {
|
|
52
|
-
original_width = button.
|
|
53
|
+
original_width = button.offsetWidth
|
|
53
54
|
}
|
|
54
|
-
if (button.
|
|
55
|
+
if (button.offsetWidth <= original_width + 5) {
|
|
55
56
|
expanded = true
|
|
56
|
-
button.animate(
|
|
57
|
+
var anim = button.animate(
|
|
57
58
|
{ width: settings.animate_width + "px" },
|
|
58
|
-
settings.speed,
|
|
59
|
-
function () {
|
|
60
|
-
target.show(0, function () {
|
|
61
|
-
input.focus()
|
|
62
|
-
// Set the button to auto width to make
|
|
63
|
-
// sure it has room for any inputs
|
|
64
|
-
button.width("auto")
|
|
65
|
-
// Explicitly set the width of the button
|
|
66
|
-
// so the close animation works properly
|
|
67
|
-
button.width(button.width())
|
|
68
|
-
})
|
|
69
|
-
},
|
|
59
|
+
{ duration: settings.speed },
|
|
70
60
|
)
|
|
61
|
+
anim.onfinish = function () {
|
|
62
|
+
button.style.width = settings.animate_width + "px"
|
|
63
|
+
showElement(target)
|
|
64
|
+
input.focus()
|
|
65
|
+
// Set the button to auto width to make
|
|
66
|
+
// sure it has room for any inputs
|
|
67
|
+
button.style.width = "auto"
|
|
68
|
+
// Explicitly set the width of the button
|
|
69
|
+
// so the close animation works properly
|
|
70
|
+
button.style.width = button.offsetWidth + "px"
|
|
71
|
+
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
function collapseButton() {
|
|
74
|
-
target.
|
|
75
|
-
button.animate(
|
|
75
|
+
target.style.display = "none"
|
|
76
|
+
var anim = button.animate(
|
|
77
|
+
{ width: original_width + "px" },
|
|
78
|
+
{ duration: settings.speed },
|
|
79
|
+
)
|
|
80
|
+
anim.onfinish = function () {
|
|
81
|
+
button.style.width = original_width + "px"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Show an element that may be hidden via a CSS class by overriding with an
|
|
85
|
+
// appropriate inline display value (mirrors jQuery's .show()).
|
|
86
|
+
function showElement(el) {
|
|
87
|
+
el.style.display = ""
|
|
88
|
+
if (window.getComputedStyle(el).display === "none") {
|
|
89
|
+
el.style.display = "inline-block"
|
|
90
|
+
}
|
|
76
91
|
}
|
|
77
92
|
function inputEmpty() {
|
|
78
|
-
return
|
|
93
|
+
return input.value.trim() == ""
|
|
79
94
|
}
|
|
80
95
|
}
|
|
81
96
|
}
|
|
@@ -7,70 +7,92 @@ export default class {
|
|
|
7
7
|
|
|
8
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 = $(
|
|
15
|
-
"tr td:nth-child(" + (parentCell.index() + 1) + ")",
|
|
16
|
-
table,
|
|
17
|
-
)
|
|
18
|
-
var checkboxes = $("input[type='checkbox']", columnRows)
|
|
19
|
-
updateSelectAllInput(selectCheckbox, columnRows)
|
|
20
|
-
// Add the check/uncheck behavior to the select/deselect all checkbox
|
|
21
|
-
selectCheckbox.on("click", function () {
|
|
22
|
-
var allChecked = allCheckboxesChecked(columnRows)
|
|
23
|
-
columnRows.each(function () {
|
|
24
|
-
$("input[type='checkbox']", $(this)).prop("checked", !allChecked)
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
// When a single checkbox is selected/unselected, the "All" checkbox should be updated accordingly.
|
|
28
|
-
checkboxes.each(function () {
|
|
29
|
-
$(this).on("change", function () {
|
|
30
|
-
updateSelectAllInput(selectCheckbox, columnRows)
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
10
|
// Check number of checkboxes against the number of checked
|
|
36
11
|
// checkboxes to determine if all of them are checked or not
|
|
37
|
-
function allCheckboxesChecked(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
12
|
+
function allCheckboxesChecked(cells) {
|
|
13
|
+
let total = 0
|
|
14
|
+
let checked = 0
|
|
15
|
+
cells.forEach((cell) => {
|
|
16
|
+
cell.querySelectorAll("input[type='checkbox']").forEach((cb) => {
|
|
17
|
+
total++
|
|
18
|
+
if (cb.checked) {
|
|
19
|
+
checked++
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
return total === checked
|
|
42
24
|
}
|
|
43
25
|
|
|
44
26
|
// Check or uncheck the "All" checkbox for each view column, e.g. Item details, List, etc.
|
|
45
|
-
function updateSelectAllInput(checkbox,
|
|
46
|
-
|
|
47
|
-
checkbox.prop("checked", true)
|
|
48
|
-
} else {
|
|
49
|
-
checkbox.prop("checked", false)
|
|
50
|
-
}
|
|
27
|
+
function updateSelectAllInput(checkbox, cells) {
|
|
28
|
+
checkbox.checked = allCheckboxesChecked(cells)
|
|
51
29
|
}
|
|
30
|
+
|
|
31
|
+
document
|
|
32
|
+
.querySelectorAll("[data-behavior='metadata-select']")
|
|
33
|
+
.forEach((selectCheckbox) => {
|
|
34
|
+
const parentCell = selectCheckbox.closest("th")
|
|
35
|
+
if (!parentCell) return
|
|
36
|
+
|
|
37
|
+
const table = parentCell.closest("table")
|
|
38
|
+
if (!table) return
|
|
39
|
+
|
|
40
|
+
const columnIndex = Array.from(parentCell.parentNode.children).indexOf(
|
|
41
|
+
parentCell,
|
|
42
|
+
)
|
|
43
|
+
const columnRows = table.querySelectorAll(
|
|
44
|
+
`tr td:nth-child(${columnIndex + 1})`,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
const checkboxes = []
|
|
48
|
+
columnRows.forEach((cell) => {
|
|
49
|
+
cell.querySelectorAll("input[type='checkbox']").forEach((cb) => {
|
|
50
|
+
checkboxes.push(cb)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
updateSelectAllInput(selectCheckbox, columnRows)
|
|
55
|
+
|
|
56
|
+
// Add the check/uncheck behavior to the select/deselect all checkbox
|
|
57
|
+
selectCheckbox.addEventListener("click", () => {
|
|
58
|
+
const allChecked = allCheckboxesChecked(columnRows)
|
|
59
|
+
columnRows.forEach((cell) => {
|
|
60
|
+
cell.querySelectorAll("input[type='checkbox']").forEach((cb) => {
|
|
61
|
+
cb.checked = !allChecked
|
|
62
|
+
cb.dispatchEvent(new Event("change", { bubbles: true }))
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
updateSelectAllInput(selectCheckbox, columnRows)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// When a single checkbox is selected/unselected, the "All" checkbox should be updated accordingly.
|
|
69
|
+
checkboxes.forEach((cb) => {
|
|
70
|
+
cb.addEventListener("change", () => {
|
|
71
|
+
updateSelectAllInput(selectCheckbox, columnRows)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
})
|
|
52
75
|
}
|
|
53
76
|
|
|
54
77
|
addEnableToggleBehavior() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
document
|
|
79
|
+
.querySelectorAll("[data-behavior='enable-feature']")
|
|
80
|
+
.forEach((checkbox) => {
|
|
81
|
+
const targetSelector = checkbox.dataset.target
|
|
82
|
+
if (!targetSelector) return
|
|
83
|
+
const target = document.querySelector(targetSelector)
|
|
84
|
+
if (!target) return
|
|
58
85
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
target
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.not("[data-behavior='enable-feature']")
|
|
70
|
-
.prop("checked", false)
|
|
71
|
-
.attr("disabled", true)
|
|
72
|
-
}
|
|
86
|
+
checkbox.addEventListener("change", () => {
|
|
87
|
+
const isChecked = checkbox.checked
|
|
88
|
+
target.querySelectorAll("input[type='checkbox']").forEach((cb) => {
|
|
89
|
+
if (!cb.matches("[data-behavior='enable-feature']")) {
|
|
90
|
+
cb.checked = isChecked
|
|
91
|
+
cb.disabled = !isChecked
|
|
92
|
+
cb.dispatchEvent(new Event("change", { bubbles: true }))
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
})
|
|
73
96
|
})
|
|
74
|
-
})
|
|
75
97
|
}
|
|
76
98
|
}
|