blacklight-spotlight 5.2.4 → 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.
- checksums.yaml +4 -4
- data/README.md +25 -5
- data/app/assets/javascripts/spotlight/spotlight.esm.js +1679 -1228
- data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
- data/app/assets/javascripts/spotlight/spotlight.js +1682 -1231
- data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
- data/app/assets/stylesheets/spotlight/_spotlight.scss +0 -2
- data/app/components/spotlight/analytics/aggregation_component.html.erb +1 -1
- data/app/components/spotlight/document_admin_table_component.html.erb +2 -2
- data/app/components/spotlight/edit_view_links_component.html.erb +1 -1
- data/app/components/spotlight/header_component.html.erb +1 -1
- data/app/components/spotlight/tag_list_form_component.html.erb +1 -1
- data/app/components/spotlight/tag_selector_component.html.erb +2 -2
- data/app/components/spotlight/translations/subheading_component.html.erb +1 -1
- data/app/controllers/spotlight/bulk_actions_controller.rb +2 -2
- data/app/controllers/spotlight/bulk_updates_controller.rb +2 -2
- data/app/controllers/spotlight/catalog_controller.rb +2 -2
- data/app/controllers/spotlight/contact_forms_controller.rb +1 -1
- data/app/controllers/spotlight/exhibits_controller.rb +1 -1
- data/app/controllers/spotlight/featured_images_controller.rb +1 -1
- data/app/controllers/spotlight/pages_controller.rb +1 -1
- data/app/controllers/spotlight/resources_controller.rb +1 -1
- data/app/controllers/spotlight/searches_controller.rb +3 -4
- data/app/controllers/spotlight/solr_controller.rb +1 -1
- data/app/controllers/spotlight/tags_controller.rb +1 -1
- data/app/controllers/spotlight/versions_controller.rb +1 -1
- data/app/javascript/spotlight/admin/add_another.js +22 -15
- data/app/javascript/spotlight/admin/add_image_selector.js +27 -25
- data/app/javascript/spotlight/admin/add_new_button.js +47 -43
- data/app/javascript/spotlight/admin/blacklight_configuration.js +52 -38
- data/app/javascript/spotlight/admin/block_mixins/autocompleteable.js +68 -60
- data/app/javascript/spotlight/admin/block_mixins/formable.js +55 -47
- data/app/javascript/spotlight/admin/block_mixins/plustextable.js +19 -20
- data/app/javascript/spotlight/admin/blocks/block.js +20 -16
- data/app/javascript/spotlight/admin/blocks/browse_block.js +42 -37
- data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +33 -31
- data/app/javascript/spotlight/admin/blocks/iframe_block.js +14 -11
- data/app/javascript/spotlight/admin/blocks/link_to_search_block.js +4 -7
- data/app/javascript/spotlight/admin/blocks/oembed_block.js +13 -10
- data/app/javascript/spotlight/admin/blocks/pages_block.js +20 -13
- data/app/javascript/spotlight/admin/blocks/resources_block.js +150 -117
- data/app/javascript/spotlight/admin/blocks/rule_block.js +11 -10
- data/app/javascript/spotlight/admin/blocks/search_result_block.js +16 -17
- data/app/javascript/spotlight/admin/blocks/solr_documents_base_block.js +123 -64
- data/app/javascript/spotlight/admin/blocks/solr_documents_block.js +8 -8
- data/app/javascript/spotlight/admin/blocks/solr_documents_carousel_block.js +63 -43
- data/app/javascript/spotlight/admin/blocks/solr_documents_embed_block.js +9 -9
- data/app/javascript/spotlight/admin/blocks/solr_documents_features_block.js +17 -16
- data/app/javascript/spotlight/admin/blocks/solr_documents_grid_block.js +6 -7
- data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +84 -64
- data/app/javascript/spotlight/admin/crop.js +203 -156
- data/app/javascript/spotlight/admin/croppable.js +4 -4
- data/app/javascript/spotlight/admin/croppable_modal.js +59 -37
- data/app/javascript/spotlight/admin/edit_in_place.js +50 -47
- data/app/javascript/spotlight/admin/exhibits.js +52 -41
- data/app/javascript/spotlight/admin/form_observer.js +59 -53
- data/app/javascript/spotlight/admin/iiif.js +26 -25
- data/app/javascript/spotlight/admin/index.js +44 -47
- data/app/javascript/spotlight/admin/locks.js +14 -14
- data/app/javascript/spotlight/admin/multi_image_selector.js +127 -111
- data/app/javascript/spotlight/admin/pages.js +21 -21
- data/app/javascript/spotlight/admin/progress_monitor.js +67 -65
- data/app/javascript/spotlight/admin/readonly_checkbox.js +3 -3
- data/app/javascript/spotlight/admin/search_typeahead.js +55 -43
- data/app/javascript/spotlight/admin/select_related_input.js +17 -17
- data/app/javascript/spotlight/admin/sir-trevor/block_controls.js +100 -84
- data/app/javascript/spotlight/admin/sir-trevor/block_limits.js +36 -31
- data/app/javascript/spotlight/admin/sir-trevor/locales.js +52 -39
- data/app/javascript/spotlight/admin/spotlight_nestable.js +112 -90
- data/app/javascript/spotlight/admin/tabs.js +16 -3
- data/app/javascript/spotlight/admin/translation_progress.js +13 -7
- data/app/javascript/spotlight/admin/users.js +41 -41
- data/app/javascript/spotlight/admin/visibility_toggle.js +4 -4
- data/app/javascript/spotlight/controllers/clipboard_controller.js +14 -0
- data/app/javascript/spotlight/controllers/index.js +4 -2
- data/app/javascript/spotlight/controllers/tag_selector_controller.js +116 -79
- data/app/javascript/spotlight/core.js +18 -15
- data/app/javascript/spotlight/index.js +4 -4
- data/app/javascript/spotlight/user/browse_group_categories.js +24 -22
- data/app/javascript/spotlight/user/carousel.js +23 -19
- data/app/javascript/spotlight/user/clear_form_button.js +15 -15
- data/app/javascript/spotlight/user/index.js +4 -4
- data/app/javascript/spotlight/user/zpr_links.js +18 -18
- data/app/models/spotlight/analytics/ga.rb +0 -1
- data/app/models/spotlight/custom_field.rb +1 -1
- data/app/models/spotlight/resources/iiif_manifest_v3.rb +2 -2
- data/app/services/spotlight/exhibit_import_export_service.rb +0 -2
- data/app/views/blacklight/nav/_bookmark.html.erb +1 -1
- data/app/views/catalog/_remove_tags.html.erb +1 -1
- data/app/views/layouts/spotlight/base.html.erb +1 -1
- data/app/views/shared/_header_navbar.html.erb +1 -1
- data/app/views/shared/_masthead.html.erb +2 -2
- data/app/views/shared/_site_sidebar.html.erb +1 -1
- data/app/views/shared/_user_util_links.html.erb +2 -2
- data/app/views/spotlight/about_pages/_contacts.html.erb +1 -1
- data/app/views/spotlight/accessibility/alt_text.html.erb +1 -1
- data/app/views/spotlight/admin_users/index.html.erb +11 -9
- data/app/views/spotlight/appearances/edit.html.erb +1 -1
- data/app/views/spotlight/browse/_search_box.html.erb +1 -1
- data/app/views/spotlight/bulk_updates/_download.html.erb +1 -1
- data/app/views/spotlight/bulk_updates/_progress_panel.html.erb +6 -6
- data/app/views/spotlight/bulk_updates/edit.html.erb +1 -1
- data/app/views/spotlight/catalog/_admin_header.html.erb +1 -1
- data/app/views/spotlight/catalog/_admin_index_header_default.html.erb +1 -1
- data/app/views/spotlight/catalog/_curation_mode_toggle_default.html.erb +1 -1
- data/app/views/spotlight/catalog/_document.html.erb +2 -2
- data/app/views/spotlight/catalog/_document_admin_table.html.erb +1 -1
- data/app/views/spotlight/catalog/_edit_sidecar.html.erb +1 -1
- data/app/views/spotlight/catalog/_index_compact_default.html.erb +1 -1
- data/app/views/spotlight/catalog/_reindex_progress_panel.html.erb +6 -6
- data/app/views/spotlight/catalog/select_image.html.erb +1 -1
- data/app/views/spotlight/contact_mailer/report_problem.html.erb +2 -2
- data/app/views/spotlight/exhibits/_contact.html.erb +2 -2
- data/app/views/spotlight/exhibits/_delete.html.erb +2 -2
- data/app/views/spotlight/exhibits/_exhibit_card.html.erb +1 -1
- data/app/views/spotlight/exhibits/_export.html.erb +1 -1
- data/app/views/spotlight/exhibits/_form.html.erb +2 -2
- data/app/views/spotlight/exhibits/_languages.html.erb +7 -7
- data/app/views/spotlight/exhibits/_missing_exhibits.html.erb +1 -1
- data/app/views/spotlight/locks/_lock.html.erb +2 -2
- data/app/views/spotlight/metadata_configurations/edit.html.erb +1 -1
- data/app/views/spotlight/pages/_order_pages.html.erb +3 -3
- data/app/views/spotlight/pages/preview.html.erb +1 -1
- data/app/views/spotlight/pages/show.html.erb +2 -2
- data/app/views/spotlight/resources/_form.html.erb +1 -1
- data/app/views/spotlight/resources/csv_upload/_form.html.erb +1 -1
- data/app/views/spotlight/resources/upload/_form.html.erb +1 -1
- data/app/views/spotlight/roles/index.html.erb +5 -5
- data/app/views/spotlight/search_configurations/_search_fields.html.erb +1 -1
- data/app/views/spotlight/search_configurations/edit.html.erb +1 -1
- data/app/views/spotlight/searches/index.html.erb +2 -2
- data/app/views/spotlight/shared/_configuration_sidebar.html.erb +1 -1
- data/app/views/spotlight/shared/_curation_sidebar.html.erb +1 -1
- data/app/views/spotlight/shared/_dd3_item.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/_sir_trevor_block_array.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_browse_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_featured_pages_block.html.erb +2 -2
- data/app/views/spotlight/sir_trevor/blocks/_link_to_search_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_rule_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb +1 -1
- data/app/views/spotlight/sites/edit_exhibits.html.erb +3 -3
- data/app/views/spotlight/translations/_browse_categories.html.erb +2 -2
- data/app/views/spotlight/translations/_general.html.erb +21 -21
- data/app/views/spotlight/translations/_groups.html.erb +1 -1
- data/app/views/spotlight/translations/_metadata.html.erb +8 -8
- data/app/views/spotlight/translations/_pages_table.html.erb +2 -2
- data/app/views/spotlight/translations/_search_fields.html.erb +13 -13
- data/app/views/spotlight/translations/edit.html.erb +5 -5
- data/config/importmap.rb +0 -1
- data/lib/generators/spotlight/assets/propshaft_generator.rb +0 -1
- data/lib/generators/spotlight/templates/solr/conf/admin-extra.html +31 -31
- data/lib/spotlight/version.rb +1 -1
- data/spec/factories/contact_images.rb +1 -1
- data/spec/factories/exhibit_thumbnails.rb +1 -1
- data/spec/factories/featured_images.rb +1 -1
- data/spec/support/features/test_features_helpers.rb +12 -3
- metadata +12 -64
- data/app/assets/stylesheets/spotlight/typeahead.scss +0 -77
- data/app/javascript/spotlight/admin/copy_email_addresses.js +0 -7
- data/vendor/assets/javascripts/jquery.waitforimages.min.js +0 -2
|
@@ -1,144 +1,146 @@
|
|
|
1
1
|
export default class {
|
|
2
2
|
connect() {
|
|
3
|
-
var monitorElements = $('[data-behavior="progress-panel"]')
|
|
4
|
-
var defaultRefreshRate = 3000
|
|
5
|
-
var panelContainer
|
|
6
|
-
var pollers = []
|
|
7
|
-
|
|
8
|
-
$(monitorElements).each(function() {
|
|
9
|
-
panelContainer = $(this)
|
|
10
|
-
panelContainer.hide()
|
|
11
|
-
var monitorUrl = panelContainer.data(
|
|
12
|
-
var refreshRate = panelContainer.data(
|
|
3
|
+
var monitorElements = $('[data-behavior="progress-panel"]')
|
|
4
|
+
var defaultRefreshRate = 3000
|
|
5
|
+
var panelContainer
|
|
6
|
+
var pollers = []
|
|
7
|
+
|
|
8
|
+
$(monitorElements).each(function () {
|
|
9
|
+
panelContainer = $(this)
|
|
10
|
+
panelContainer.hide()
|
|
11
|
+
var monitorUrl = panelContainer.data("monitorUrl")
|
|
12
|
+
var refreshRate = panelContainer.data("refreshRate") || defaultRefreshRate
|
|
13
13
|
pollers.push(
|
|
14
|
-
setInterval(function() {
|
|
15
|
-
checkMonitorUrl(monitorUrl)
|
|
16
|
-
}, refreshRate)
|
|
17
|
-
)
|
|
18
|
-
})
|
|
14
|
+
setInterval(function () {
|
|
15
|
+
checkMonitorUrl(monitorUrl)
|
|
16
|
+
}, refreshRate),
|
|
17
|
+
)
|
|
18
|
+
})
|
|
19
19
|
|
|
20
20
|
// Clear the intervals on turbolink:click event (e.g. when the user navigates away from the page)
|
|
21
|
-
$(document).on(
|
|
21
|
+
$(document).on("turbolinks:click", function () {
|
|
22
22
|
if (pollers.length > 0) {
|
|
23
|
-
$.each(pollers, function() {
|
|
24
|
-
clearInterval(this)
|
|
25
|
-
})
|
|
26
|
-
pollers = []
|
|
23
|
+
$.each(pollers, function () {
|
|
24
|
+
clearInterval(this)
|
|
25
|
+
})
|
|
26
|
+
pollers = []
|
|
27
27
|
}
|
|
28
|
-
})
|
|
28
|
+
})
|
|
29
29
|
|
|
30
30
|
function checkMonitorUrl(url) {
|
|
31
|
-
$.ajax(url).done(success).fail(fail)
|
|
31
|
+
$.ajax(url).done(success).fail(fail)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function success(data) {
|
|
35
35
|
if (data.recently_in_progress) {
|
|
36
|
-
updateMonitorPanel(data)
|
|
37
|
-
monitorPanel().show()
|
|
36
|
+
updateMonitorPanel(data)
|
|
37
|
+
monitorPanel().show()
|
|
38
38
|
} else {
|
|
39
|
-
monitorPanel().hide()
|
|
39
|
+
monitorPanel().hide()
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function fail() {
|
|
43
|
+
function fail() {
|
|
44
|
+
monitorPanel().hide()
|
|
45
|
+
}
|
|
44
46
|
|
|
45
47
|
function updateMonitorPanel(data) {
|
|
46
|
-
panelStartDate().text(data.started_at)
|
|
47
|
-
panelCurrentDate().text(data.updated_at)
|
|
48
|
-
panelCompletedDate().text(data.updated_at)
|
|
49
|
-
panelCurrent().text(data.completed)
|
|
50
|
-
setPanelCompleted(data.finished)
|
|
51
|
-
updatePanelTotals(data)
|
|
52
|
-
updatePanelErrorMessage(data)
|
|
53
|
-
updateProgressBar(data)
|
|
48
|
+
panelStartDate().text(data.started_at)
|
|
49
|
+
panelCurrentDate().text(data.updated_at)
|
|
50
|
+
panelCompletedDate().text(data.updated_at)
|
|
51
|
+
panelCurrent().text(data.completed)
|
|
52
|
+
setPanelCompleted(data.finished)
|
|
53
|
+
updatePanelTotals(data)
|
|
54
|
+
updatePanelErrorMessage(data)
|
|
55
|
+
updateProgressBar(data)
|
|
54
56
|
|
|
55
|
-
panelContainer.show()
|
|
57
|
+
panelContainer.show()
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
function updateProgressBar(data) {
|
|
59
|
-
var percentage = calculatePercentage(data)
|
|
61
|
+
var percentage = calculatePercentage(data)
|
|
60
62
|
progressBar()
|
|
61
|
-
.attr(
|
|
62
|
-
.attr(
|
|
63
|
-
.css(
|
|
64
|
-
.text(percentage +
|
|
63
|
+
.attr("aria-valuemax", data.total)
|
|
64
|
+
.attr("aria-valuenow", percentage)
|
|
65
|
+
.css("width", percentage + "%")
|
|
66
|
+
.text(percentage + "%")
|
|
65
67
|
|
|
66
68
|
if (data.finished) {
|
|
67
|
-
progressBar().removeClass(
|
|
69
|
+
progressBar().removeClass("active").removeClass("progress-bar-striped")
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
function updatePanelErrorMessage(data) {
|
|
72
74
|
// We currently do not store this state,
|
|
73
75
|
// but with this code we can in the future.
|
|
74
|
-
if (
|
|
75
|
-
panelErrorMessage().show()
|
|
76
|
+
if (data.errored) {
|
|
77
|
+
panelErrorMessage().show()
|
|
76
78
|
} else {
|
|
77
|
-
panelErrorMessage().hide()
|
|
79
|
+
panelErrorMessage().hide()
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
function updatePanelTotals(data) {
|
|
82
|
-
panelTotals().each(function() {
|
|
83
|
-
$(this).text(data.total)
|
|
84
|
-
})
|
|
84
|
+
panelTotals().each(function () {
|
|
85
|
+
$(this).text(data.total)
|
|
86
|
+
})
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
function calculatePercentage(data) {
|
|
88
|
-
if (data.total == 0) return 0
|
|
89
|
-
return Math.floor((data.completed / data.total) * 100)
|
|
90
|
+
if (data.total == 0) return 0
|
|
91
|
+
return Math.floor((data.completed / data.total) * 100)
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
function monitorPanel() {
|
|
93
|
-
return panelContainer.find(
|
|
95
|
+
return panelContainer.find(".index-status")
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
function panelStartDate() {
|
|
97
99
|
return monitorPanel()
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
.find('[data-behavior="monitor-start"]')
|
|
101
|
+
.find('[data-behavior="date"]')
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
function panelCurrentDate() {
|
|
103
105
|
return monitorPanel()
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
.find('[data-behavior="monitor-current"]')
|
|
107
|
+
.find('[data-behavior="date"]')
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
function panelCompletedDate() {
|
|
109
111
|
return monitorPanel()
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
.find('[data-behavior="monitor-completed"]')
|
|
113
|
+
.find('[data-behavior="date"]')
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
function panelTotals() {
|
|
115
|
-
return monitorPanel().find('[data-behavior="total"]')
|
|
117
|
+
return monitorPanel().find('[data-behavior="total"]')
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
function panelCurrent() {
|
|
119
121
|
return monitorPanel()
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
.find('[data-behavior="monitor-current"]')
|
|
123
|
+
.find('[data-behavior="completed"]')
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
function progressBar() {
|
|
125
|
-
return monitorPanel().find(
|
|
127
|
+
return monitorPanel().find(".progress-bar")
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
function panelErrorMessage() {
|
|
129
|
-
return monitorPanel().find('[data-behavior="monitor-error"]')
|
|
131
|
+
return monitorPanel().find('[data-behavior="monitor-error"]')
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
function setPanelCompleted(finished) {
|
|
133
|
-
var panel = monitorPanel().find('[data-behavior="monitor-completed"]')
|
|
135
|
+
var panel = monitorPanel().find('[data-behavior="monitor-completed"]')
|
|
134
136
|
|
|
135
137
|
if (finished) {
|
|
136
|
-
panel.show()
|
|
138
|
+
panel.show()
|
|
137
139
|
} else {
|
|
138
|
-
panel.hide()
|
|
140
|
+
panel.hide()
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
|
|
142
|
-
return this
|
|
144
|
+
return this
|
|
143
145
|
}
|
|
144
146
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default class {
|
|
2
2
|
connect() {
|
|
3
|
-
// Don't allow unchecking of checkboxes with the data-readonly attribute
|
|
4
|
-
$("input[type='checkbox'][data-readonly]").on("click", function(event) {
|
|
5
|
-
event.preventDefault()
|
|
3
|
+
// Don't allow unchecking of checkboxes with the data-readonly attribute
|
|
4
|
+
$("input[type='checkbox'][data-readonly]").on("click", function (event) {
|
|
5
|
+
event.preventDefault()
|
|
6
6
|
})
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -1,73 +1,85 @@
|
|
|
1
|
-
import { addImageSelector } from
|
|
1
|
+
import { addImageSelector } from "spotlight/admin/add_image_selector"
|
|
2
2
|
|
|
3
|
-
const docStore = new Map()
|
|
3
|
+
const docStore = new Map()
|
|
4
4
|
|
|
5
5
|
function highlight(value, query) {
|
|
6
|
-
if (query.trim() ===
|
|
7
|
-
const queryValue = query.trim()
|
|
8
|
-
return queryValue
|
|
6
|
+
if (query.trim() === "") return value
|
|
7
|
+
const queryValue = query.trim()
|
|
8
|
+
return queryValue
|
|
9
|
+
? value.replace(new RegExp(queryValue, "gi"), "<strong>$&</strong>")
|
|
10
|
+
: value
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
function templateFunc(obj, query) {
|
|
12
|
-
const thumbnail = obj.thumbnail
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
14
|
+
const thumbnail = obj.thumbnail
|
|
15
|
+
? `<div class="document-thumbnail"><img class="img-thumbnail" src="${obj.thumbnail}" /></div>`
|
|
16
|
+
: ""
|
|
17
|
+
const privateClass = obj.private ? " blacklight-private" : ""
|
|
18
|
+
const title = highlight(obj.title, query)
|
|
19
|
+
const description = obj.description
|
|
20
|
+
? `<small> ${highlight(obj.description, query)}</small>`
|
|
21
|
+
: ""
|
|
16
22
|
return `<div class="autocomplete-item${privateClass}">${thumbnail}
|
|
17
23
|
<span class="autocomplete-title">${title}</span><br/>${description}
|
|
18
|
-
</div
|
|
24
|
+
</div>`
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
function autoCompleteElementTemplate(obj, query) {
|
|
22
|
-
return `<li role="option" data-autocomplete-value="${obj.id}">${templateFunc(obj, query)}</li
|
|
28
|
+
return `<li role="option" data-autocomplete-value="${obj.id}">${templateFunc(obj, query)}</li>`
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
function getAutoCompleteElementDataMap(autoCompleteElement) {
|
|
26
32
|
if (!docStore.has(autoCompleteElement.id)) {
|
|
27
|
-
docStore.set(autoCompleteElement.id, new Map())
|
|
33
|
+
docStore.set(autoCompleteElement.id, new Map())
|
|
28
34
|
}
|
|
29
|
-
return docStore.get(autoCompleteElement.id)
|
|
35
|
+
return docStore.get(autoCompleteElement.id)
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
async function fetchResult(url) {
|
|
33
|
-
const result = await fetchAutocompleteJSON(url)
|
|
34
|
-
const docs = result.docs || []
|
|
35
|
-
const query = this.querySelector(
|
|
36
|
-
const autoCompleteElementDataMap = getAutoCompleteElementDataMap(this)
|
|
37
|
-
return docs
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const result = await fetchAutocompleteJSON(url)
|
|
40
|
+
const docs = result.docs || []
|
|
41
|
+
const query = this.querySelector("input").value || ""
|
|
42
|
+
const autoCompleteElementDataMap = getAutoCompleteElementDataMap(this)
|
|
43
|
+
return docs
|
|
44
|
+
.map((doc) => {
|
|
45
|
+
autoCompleteElementDataMap.set(doc.id, doc)
|
|
46
|
+
return autoCompleteElementTemplate(doc, query)
|
|
47
|
+
})
|
|
48
|
+
.join("")
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
export function addAutocompletetoFeaturedImage(){
|
|
44
|
-
const autocompletePath = $(
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
export function addAutocompletetoFeaturedImage() {
|
|
52
|
+
const autocompletePath = $(
|
|
53
|
+
"form[data-autocomplete-exhibit-catalog-path]",
|
|
54
|
+
).data("autocomplete-exhibit-catalog-path")
|
|
55
|
+
const featuredImageTypeaheads = $("[data-featured-image-typeahead]")
|
|
56
|
+
if (featuredImageTypeaheads.length === 0) return
|
|
47
57
|
|
|
48
|
-
$.each(featuredImageTypeaheads, function(index, autoCompleteInput) {
|
|
49
|
-
const autoCompleteElement = autoCompleteInput.closest(
|
|
58
|
+
$.each(featuredImageTypeaheads, function (index, autoCompleteInput) {
|
|
59
|
+
const autoCompleteElement = autoCompleteInput.closest("auto-complete")
|
|
50
60
|
|
|
51
|
-
autoCompleteElement.setAttribute(
|
|
52
|
-
autoCompleteElement.fetchResult = fetchResult
|
|
53
|
-
autoCompleteElement.addEventListener(
|
|
54
|
-
const data = getAutoCompleteElementDataMap(autoCompleteElement).get(
|
|
55
|
-
|
|
61
|
+
autoCompleteElement.setAttribute("src", autocompletePath)
|
|
62
|
+
autoCompleteElement.fetchResult = fetchResult
|
|
63
|
+
autoCompleteElement.addEventListener("auto-complete-change", (e) => {
|
|
64
|
+
const data = getAutoCompleteElementDataMap(autoCompleteElement).get(
|
|
65
|
+
e.relatedTarget.value,
|
|
66
|
+
)
|
|
67
|
+
if (!data) return
|
|
56
68
|
|
|
57
|
-
const inputElement = $(e.relatedTarget)
|
|
58
|
-
const panel = document.querySelector(e.relatedTarget.dataset.targetPanel)
|
|
59
|
-
e.relatedTarget.value = data.title
|
|
60
|
-
addImageSelector(inputElement, $(panel), data.iiif_manifest, true)
|
|
61
|
-
$(inputElement.data(
|
|
62
|
-
inputElement.attr(
|
|
63
|
-
})
|
|
64
|
-
})
|
|
69
|
+
const inputElement = $(e.relatedTarget)
|
|
70
|
+
const panel = document.querySelector(e.relatedTarget.dataset.targetPanel)
|
|
71
|
+
e.relatedTarget.value = data.title
|
|
72
|
+
addImageSelector(inputElement, $(panel), data.iiif_manifest, true)
|
|
73
|
+
$(inputElement.data("id-field")).val(data["global_id"])
|
|
74
|
+
inputElement.attr("type", "text")
|
|
75
|
+
})
|
|
76
|
+
})
|
|
65
77
|
}
|
|
66
78
|
|
|
67
79
|
export async function fetchAutocompleteJSON(url) {
|
|
68
|
-
const res = await
|
|
80
|
+
const res = await fetch(url.toString())
|
|
69
81
|
if (!res.ok) {
|
|
70
|
-
throw new Error(await res.text())
|
|
82
|
+
throw new Error(await res.text())
|
|
71
83
|
}
|
|
72
|
-
return await res.json()
|
|
84
|
+
return await res.json()
|
|
73
85
|
}
|
|
@@ -2,36 +2,36 @@
|
|
|
2
2
|
Simple plugin to select form elements
|
|
3
3
|
when other elements are clicked.
|
|
4
4
|
*/
|
|
5
|
-
(function($) {
|
|
6
|
-
$.fn.selectRelatedInput = function() {
|
|
7
|
-
var clickElements = this
|
|
5
|
+
;(function ($) {
|
|
6
|
+
$.fn.selectRelatedInput = function () {
|
|
7
|
+
var clickElements = this
|
|
8
8
|
|
|
9
|
-
$(clickElements).each(function() {
|
|
10
|
-
var target = $($(this).data(
|
|
9
|
+
$(clickElements).each(function () {
|
|
10
|
+
var target = $($(this).data("input-select-target"))
|
|
11
11
|
|
|
12
|
-
var event
|
|
12
|
+
var event
|
|
13
13
|
|
|
14
14
|
if ($(this).is("select")) {
|
|
15
|
-
event =
|
|
15
|
+
event = "change"
|
|
16
16
|
} else {
|
|
17
|
-
event =
|
|
17
|
+
event = "click"
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
$(this).on(event, function() {
|
|
20
|
+
$(this).on(event, function () {
|
|
21
21
|
if (target.is(":checkbox") || target.is(":radio")) {
|
|
22
|
-
target.prop(
|
|
22
|
+
target.prop("checked", true)
|
|
23
23
|
} else {
|
|
24
|
-
target.focus()
|
|
24
|
+
target.focus()
|
|
25
25
|
}
|
|
26
|
-
})
|
|
27
|
-
})
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
28
|
|
|
29
|
-
return this
|
|
30
|
-
}
|
|
31
|
-
})(jQuery)
|
|
29
|
+
return this
|
|
30
|
+
}
|
|
31
|
+
})(jQuery)
|
|
32
32
|
|
|
33
33
|
export default class {
|
|
34
34
|
connect() {
|
|
35
|
-
$(
|
|
35
|
+
$("[data-input-select-target]").selectRelatedInput()
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,122 +1,138 @@
|
|
|
1
|
-
import Core from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
el.
|
|
7
|
-
el.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
img.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import Core from "spotlight/core"
|
|
2
|
+
;(function () {
|
|
3
|
+
var BLOCK_REPLACER_CONTROL_TEMPLATE = function (block) {
|
|
4
|
+
var el = document.createElement("button")
|
|
5
|
+
el.className = "st-block-controls__button"
|
|
6
|
+
el.setAttribute("data-type", block.type)
|
|
7
|
+
el.type = "button"
|
|
8
|
+
|
|
9
|
+
var img = document.createElement("svg")
|
|
10
|
+
img.className = "st-icon"
|
|
11
|
+
img.setAttribute("role", "img")
|
|
12
|
+
|
|
13
|
+
var use = document.createElement("use")
|
|
14
|
+
use.setAttributeNS(
|
|
15
|
+
"https://www.w3.org/1999/xlink",
|
|
16
|
+
"href",
|
|
17
|
+
SirTrevor.config.defaults.iconUrl + "#" + block.icon_name,
|
|
18
|
+
)
|
|
19
|
+
img.appendChild(use)
|
|
20
|
+
el.appendChild(img)
|
|
21
|
+
el.appendChild(document.createTextNode(block.title()))
|
|
22
|
+
|
|
23
|
+
return el.outerHTML
|
|
24
|
+
}
|
|
22
25
|
|
|
23
26
|
function generateBlocksHTML(Blocks, availableTypes) {
|
|
24
|
-
var groups = {}
|
|
25
|
-
for(var i in availableTypes) {
|
|
26
|
-
var type = availableTypes[i]
|
|
27
|
-
if (
|
|
28
|
-
|
|
27
|
+
var groups = {}
|
|
28
|
+
for (var i in availableTypes) {
|
|
29
|
+
var type = availableTypes[i]
|
|
30
|
+
if (
|
|
31
|
+
Object.prototype.hasOwnProperty.call(Blocks, type) &&
|
|
32
|
+
Blocks[type].prototype.toolbarEnabled
|
|
33
|
+
) {
|
|
34
|
+
var blockGroup
|
|
29
35
|
|
|
30
36
|
if ($.isFunction(Blocks[type].prototype.blockGroup)) {
|
|
31
|
-
blockGroup = Blocks[type].prototype.blockGroup()
|
|
37
|
+
blockGroup = Blocks[type].prototype.blockGroup()
|
|
32
38
|
} else {
|
|
33
|
-
blockGroup = Blocks[type].prototype.blockGroup
|
|
39
|
+
blockGroup = Blocks[type].prototype.blockGroup
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
if (blockGroup ==
|
|
37
|
-
blockGroup = i18n.t("blocks:group:undefined")
|
|
42
|
+
if (blockGroup == "undefined" || blockGroup === undefined) {
|
|
43
|
+
blockGroup = i18n.t("blocks:group:undefined")
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
groups[blockGroup] = groups[blockGroup] || []
|
|
41
|
-
groups[blockGroup].push(
|
|
46
|
+
groups[blockGroup] = groups[blockGroup] || []
|
|
47
|
+
groups[blockGroup].push(
|
|
48
|
+
BLOCK_REPLACER_CONTROL_TEMPLATE(Blocks[type].prototype),
|
|
49
|
+
)
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
function generateBlock(groups, key) {
|
|
46
|
-
var group
|
|
47
|
-
var groupEl = $(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
var group = groups[key]
|
|
55
|
+
var groupEl = $(
|
|
56
|
+
"<div class='st-controls-group'><div class='st-group-col-form-label'>" +
|
|
57
|
+
key +
|
|
58
|
+
"</div></div>",
|
|
59
|
+
)
|
|
60
|
+
var buttons = group.reduce(function (memo, btn) {
|
|
61
|
+
return memo + btn
|
|
62
|
+
}, "")
|
|
63
|
+
groupEl.append(buttons)
|
|
64
|
+
return groupEl[0].outerHTML
|
|
53
65
|
}
|
|
54
66
|
|
|
55
|
-
var standardWidgets = generateBlock(
|
|
67
|
+
var standardWidgets = generateBlock(
|
|
68
|
+
groups,
|
|
69
|
+
i18n.t("blocks:group:undefined"),
|
|
70
|
+
)
|
|
56
71
|
|
|
57
|
-
var exhibitWidgets = Object.keys(groups)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
var exhibitWidgets = Object.keys(groups)
|
|
73
|
+
.map(function (key) {
|
|
74
|
+
if (key !== i18n.t("blocks:group:undefined")) {
|
|
75
|
+
return generateBlock(groups, key)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.filter(function (element) {
|
|
79
|
+
return element != null
|
|
80
|
+
})
|
|
64
81
|
|
|
65
|
-
var blocks = [standardWidgets].concat(exhibitWidgets).join("<hr />")
|
|
66
|
-
return blocks
|
|
82
|
+
var blocks = [standardWidgets].concat(exhibitWidgets).join("<hr />")
|
|
83
|
+
return blocks
|
|
67
84
|
}
|
|
68
85
|
|
|
69
|
-
function render(
|
|
70
|
-
var el = document.createElement(
|
|
71
|
-
el.className = "st-block-controls__buttons"
|
|
72
|
-
el.innerHTML = generateBlocksHTML.apply(null, arguments)
|
|
86
|
+
function render(_Blocks, _availableTypes) {
|
|
87
|
+
var el = document.createElement("div")
|
|
88
|
+
el.className = "st-block-controls__buttons"
|
|
89
|
+
el.innerHTML = generateBlocksHTML.apply(null, arguments)
|
|
73
90
|
|
|
74
|
-
var elButtons = document.createElement(
|
|
75
|
-
elButtons.className = "spotlight-block-controls"
|
|
76
|
-
elButtons.appendChild(el)
|
|
77
|
-
return elButtons
|
|
91
|
+
var elButtons = document.createElement("div")
|
|
92
|
+
elButtons.className = "spotlight-block-controls"
|
|
93
|
+
elButtons.appendChild(el)
|
|
94
|
+
return elButtons
|
|
78
95
|
}
|
|
79
96
|
|
|
80
|
-
Core.BlockControls = function() {
|
|
81
|
-
Core.BlockControls.create = function(editor) {
|
|
97
|
+
Core.BlockControls = function () {}
|
|
98
|
+
Core.BlockControls.create = function (editor) {
|
|
82
99
|
// REFACTOR - should probably not know about blockManager
|
|
83
|
-
var el = render(SirTrevor.Blocks, editor.blockManager.blockTypes)
|
|
100
|
+
var el = render(SirTrevor.Blocks, editor.blockManager.blockTypes)
|
|
84
101
|
|
|
85
102
|
function hide() {
|
|
86
|
-
var parent = el.parentNode
|
|
87
|
-
if (!parent) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
var parent = el.parentNode
|
|
104
|
+
if (!parent) {
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
parent.removeChild(el)
|
|
108
|
+
parent.classList.remove("st-block--controls-active")
|
|
109
|
+
return parent
|
|
91
110
|
}
|
|
92
111
|
|
|
93
112
|
function destroy() {
|
|
94
|
-
|
|
95
|
-
|
|
113
|
+
// eslint-disable-next-line no-global-assign
|
|
114
|
+
SirTrevor = null
|
|
115
|
+
el = null
|
|
96
116
|
}
|
|
97
117
|
|
|
98
118
|
function insert(e) {
|
|
99
|
-
e.stopPropagation()
|
|
100
|
-
|
|
101
|
-
var parent = this.parentNode;
|
|
102
|
-
if (!parent || hide() === parent) { return; }
|
|
103
|
-
$('.st-block__inner', parent).after(el);
|
|
104
|
-
parent.classList.add("st-block--controls-active");
|
|
105
|
-
}
|
|
119
|
+
e.stopPropagation()
|
|
106
120
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
var parent = this.parentNode
|
|
122
|
+
if (!parent || hide() === parent) {
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
$(".st-block__inner", parent).after(el)
|
|
126
|
+
parent.classList.add("st-block--controls-active")
|
|
111
127
|
}
|
|
112
128
|
|
|
113
|
-
$(editor.wrapper).delegate(".st-block-replacer", "click", insert)
|
|
114
|
-
$(editor.wrapper).delegate(".st-block-controls__button", "click", insert)
|
|
129
|
+
$(editor.wrapper).delegate(".st-block-replacer", "click", insert)
|
|
130
|
+
$(editor.wrapper).delegate(".st-block-controls__button", "click", insert)
|
|
115
131
|
|
|
116
132
|
return {
|
|
117
133
|
el: el,
|
|
118
134
|
hide: hide,
|
|
119
|
-
destroy: destroy
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
})()
|
|
135
|
+
destroy: destroy,
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
})()
|