blacklight-spotlight 3.5.0.4 → 3.6.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/Rakefile +6 -7
- data/app/assets/config/spotlight/manifest.js +1 -0
- data/app/assets/javascripts/spotlight/application.js +14 -14
- data/app/assets/javascripts/spotlight/spotlight.esm.js +7148 -0
- data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -0
- data/app/assets/javascripts/spotlight/spotlight.js +7148 -15
- data/app/assets/javascripts/spotlight/spotlight.js.map +1 -0
- data/app/assets/stylesheets/spotlight/_catalog.scss +16 -0
- data/app/controllers/concerns/spotlight/base.rb +2 -1
- data/app/controllers/concerns/spotlight/controller.rb +10 -0
- data/app/controllers/spotlight/admin_users_controller.rb +4 -4
- data/app/controllers/spotlight/appearances_controller.rb +6 -6
- data/app/controllers/spotlight/browse_controller.rb +1 -1
- data/app/controllers/spotlight/catalog_controller.rb +20 -15
- data/app/controllers/spotlight/concerns/application_controller.rb +1 -0
- data/app/controllers/spotlight/concerns/catalog_search_context.rb +2 -2
- data/app/controllers/spotlight/contacts_controller.rb +6 -6
- data/app/controllers/spotlight/dashboards_controller.rb +2 -2
- data/app/controllers/spotlight/exhibits_controller.rb +19 -19
- data/app/controllers/spotlight/featured_images_controller.rb +1 -1
- data/app/controllers/spotlight/home_pages_controller.rb +7 -7
- data/app/controllers/spotlight/lock_controller.rb +1 -1
- data/app/controllers/spotlight/metadata_configurations_controller.rb +2 -2
- data/app/controllers/spotlight/pages_controller.rb +4 -3
- data/app/controllers/spotlight/search_configurations_controller.rb +6 -6
- data/app/controllers/spotlight/searches_controller.rb +22 -22
- data/app/controllers/spotlight/solr_controller.rb +1 -1
- data/app/controllers/spotlight/translations_controller.rb +8 -10
- data/app/controllers/spotlight/versions_controller.rb +2 -1
- data/app/helpers/spotlight/application_helper.rb +33 -17
- data/app/helpers/spotlight/crud_link_helpers.rb +12 -2
- data/app/helpers/spotlight/pages_helper.rb +1 -1
- data/app/helpers/spotlight/roles_helper.rb +2 -2
- data/app/helpers/spotlight/title_helper.rb +1 -1
- data/app/helpers/spotlight/translations_helper.rb +1 -3
- data/app/javascript/spotlight/admin/add_another.es6 +24 -0
- data/app/javascript/spotlight/admin/add_image_selector.es6 +38 -0
- data/app/javascript/spotlight/admin/add_new_button.es6 +77 -0
- data/app/javascript/spotlight/admin/appearance.es6 +22 -0
- data/app/javascript/spotlight/admin/blacklight_configuration.es6 +65 -0
- data/app/{assets/javascripts → javascript}/spotlight/admin/block_mixins/autocompleteable.js +8 -8
- data/app/{assets/javascripts → javascript}/spotlight/admin/block_mixins/formable.js +1 -1
- data/app/javascript/spotlight/admin/block_mixins/plustextable.js +58 -0
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/block.js +2 -1
- data/app/javascript/spotlight/admin/blocks/browse_block.js +86 -0
- data/app/javascript/spotlight/admin/blocks/browse_group_categories_block.js +88 -0
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/iframe_block.js +7 -11
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/link_to_search_block.js +0 -2
- data/app/javascript/spotlight/admin/blocks/oembed_block.js +41 -0
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/pages_block.js +1 -1
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/resources_block.js +45 -42
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/rule_block.js +2 -4
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/search_result_block.js +7 -9
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_base_block.js +22 -22
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_block.js +7 -7
- data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_carousel_block.js +14 -15
- data/app/javascript/spotlight/admin/blocks/uploaded_items_block.js +147 -0
- data/app/javascript/spotlight/admin/checkbox_submit.es6 +75 -0
- data/app/javascript/spotlight/admin/copy_email_addresses.es6 +5 -0
- data/app/{assets/javascripts/spotlight/admin/crop.es6 → javascript/spotlight/admin/crop.js} +5 -4
- data/app/javascript/spotlight/admin/croppable.es6 +10 -0
- data/app/{assets/javascripts/spotlight/admin/edit_in_place.js → javascript/spotlight/admin/edit_in_place.es6} +6 -13
- data/app/javascript/spotlight/admin/exhibit_tag_autocomplete.es6 +39 -0
- data/app/javascript/spotlight/admin/exhibits.es6 +59 -0
- data/app/{assets/javascripts/spotlight/admin/form_observer.js → javascript/spotlight/admin/form_observer.es6} +23 -21
- data/app/javascript/spotlight/admin/index.js +85 -0
- data/app/javascript/spotlight/admin/locks.es6 +12 -0
- data/app/{assets/javascripts → javascript}/spotlight/admin/multi_image_selector.js +2 -1
- data/app/javascript/spotlight/admin/pages.es6 +42 -0
- data/app/{assets/javascripts/spotlight/admin/progress_monitor.js → javascript/spotlight/admin/progress_monitor.es6} +5 -9
- data/app/javascript/spotlight/admin/readonly_checkbox.es6 +8 -0
- data/app/{assets/javascripts → javascript}/spotlight/admin/search_typeahead.js +3 -46
- data/app/{assets/javascripts/spotlight/admin/select_related_input.js → javascript/spotlight/admin/select_related_input.es6} +6 -3
- data/app/{assets/javascripts → javascript}/spotlight/admin/sir-trevor/block_controls.js +6 -4
- data/app/{assets/javascripts → javascript}/spotlight/admin/sir-trevor/block_limits.js +2 -0
- data/app/{assets/javascripts → javascript}/spotlight/admin/spotlight_nestable.js +4 -8
- data/app/javascript/spotlight/admin/tabs.es6 +8 -0
- data/app/{assets/javascripts/spotlight/admin/translation_progress.js → javascript/spotlight/admin/translation_progress.es6} +6 -13
- data/app/{assets/javascripts/spotlight/admin/users.js → javascript/spotlight/admin/users.es6} +7 -17
- data/app/javascript/spotlight/admin/visibility_toggle.es6 +23 -0
- data/app/javascript/spotlight/index.js +10 -0
- data/app/javascript/spotlight/spotlight.js +32 -0
- data/app/{assets/javascripts/spotlight/user/analytics.js → javascript/spotlight/user/analytics.es6} +4 -4
- data/app/{assets/javascripts/spotlight/user/browse_group_categories.js → javascript/spotlight/user/browse_group_categories.es6} +4 -13
- data/app/javascript/spotlight/user/carousel.es6 +5 -0
- data/app/{assets/javascripts/spotlight/user/clear_form_button.js → javascript/spotlight/user/clear_form_button.es6} +5 -9
- data/app/javascript/spotlight/user/index.js +17 -0
- data/app/{assets/javascripts/spotlight/user/report_a_problem.js → javascript/spotlight/user/report_a_problem.es6} +6 -15
- data/app/javascript/spotlight/user/zpr_links.es6 +44 -0
- data/app/jobs/spotlight/add_uploads_from_csv.rb +1 -2
- data/app/models/concerns/spotlight/browse_category_search_builder.rb +1 -10
- data/app/models/concerns/spotlight/exhibit_defaults.rb +1 -1
- data/app/models/concerns/spotlight/exhibit_documents.rb +2 -2
- data/app/models/concerns/spotlight/resources/web.rb +1 -1
- data/app/models/concerns/spotlight/solr_document/atomic_updates.rb +1 -1
- data/app/models/concerns/spotlight/solr_document/finder.rb +2 -2
- data/app/models/concerns/spotlight/solr_document.rb +2 -2
- data/app/models/concerns/spotlight/translatables.rb +1 -1
- data/app/models/sir_trevor_rails/blocks/displayable.rb +2 -2
- data/app/models/sir_trevor_rails/blocks/solr_documents_block.rb +17 -6
- data/app/models/spotlight/analytics/ga.rb +5 -5
- data/app/models/spotlight/blacklight_configuration.rb +12 -12
- data/app/models/spotlight/bulk_update.rb +1 -0
- data/app/models/spotlight/contact_email.rb +1 -1
- data/app/models/spotlight/contact_form.rb +1 -1
- data/app/models/spotlight/exhibit.rb +1 -1
- data/app/models/spotlight/featured_image.rb +1 -2
- data/app/models/spotlight/lock.rb +1 -1
- data/app/models/spotlight/main_navigation.rb +1 -5
- data/app/models/spotlight/page.rb +1 -1
- data/app/models/spotlight/resources/iiif_manifest.rb +4 -4
- data/app/models/spotlight/resources/iiif_service.rb +1 -1
- data/app/models/spotlight/resources/upload.rb +3 -6
- data/app/models/spotlight/search.rb +2 -2
- data/app/models/translation.rb +2 -0
- data/app/presenters/spotlight/iiif_manifest_presenter.rb +2 -1
- data/app/services/spotlight/etl/solr_loader.rb +1 -1
- data/app/services/spotlight/iiif_resource_resolver.rb +10 -10
- data/app/uploaders/spotlight/bulk_updates_uploader.rb +1 -0
- data/app/views/layouts/spotlight/base.html.erb +1 -0
- data/app/views/shared/_exhibit_navbar.html.erb +6 -1
- data/app/views/spotlight/admin_users/index.html.erb +9 -3
- data/app/views/spotlight/browse/show.html.erb +2 -2
- data/app/views/spotlight/catalog/_admin_header.html.erb +3 -1
- data/app/views/spotlight/catalog/_document_visibility_control.html.erb +21 -2
- data/app/views/spotlight/catalog/_index_compact_default.html.erb +1 -1
- data/app/views/spotlight/exhibits/_confirmation_status.html.erb +3 -1
- data/app/views/spotlight/exhibits/_contact.html.erb +5 -1
- data/app/views/spotlight/shared/_exhibit_sidebar.html.erb +2 -0
- data/app/views/spotlight/shared/_report_a_problem.html.erb +1 -1
- data/app/views/spotlight/sir_trevor/blocks/_search_results_block.html.erb +2 -2
- data/app/views/spotlight/translations/_page.html.erb +6 -1
- data/config/locales/spotlight.en.yml +4 -9
- data/lib/generators/spotlight/install_generator.rb +15 -23
- data/lib/generators/spotlight/scaffold_resource_generator.rb +12 -12
- data/lib/generators/spotlight/templates/config/initializers/spotlight_initializer.rb +3 -0
- data/lib/generators/spotlight/templates/solr/conf/_rest_managed.json +3 -0
- data/lib/generators/spotlight/templates/solr/conf/admin-extra.html +31 -0
- data/lib/generators/spotlight/templates/solr/conf/elevate.xml +36 -0
- data/lib/generators/spotlight/templates/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/generators/spotlight/templates/solr/conf/protwords.txt +21 -0
- data/lib/generators/spotlight/templates/solr/{config → conf}/schema.xml +17 -0
- data/lib/generators/spotlight/templates/solr/conf/scripts.conf +24 -0
- data/lib/generators/spotlight/templates/solr/{config → conf}/solrconfig.xml +55 -24
- data/lib/generators/spotlight/templates/solr/conf/spellings.txt +2 -0
- data/lib/generators/spotlight/templates/solr/conf/stopwords.txt +58 -0
- data/lib/generators/spotlight/templates/solr/conf/stopwords_en.txt +58 -0
- data/lib/generators/spotlight/templates/solr/conf/synonyms.txt +31 -0
- data/lib/generators/spotlight/templates/solr/conf/xslt/example.xsl +132 -0
- data/lib/generators/spotlight/templates/solr/conf/xslt/example_atom.xsl +67 -0
- data/lib/generators/spotlight/templates/solr/conf/xslt/example_rss.xsl +66 -0
- data/lib/generators/spotlight/templates/solr/conf/xslt/luke.xsl +337 -0
- data/lib/generators/spotlight/templates/spotlight.js +1 -1
- data/lib/migration/iiif.rb +3 -7
- data/lib/spotlight/engine.rb +18 -16
- data/lib/spotlight/riiif_service.rb +31 -0
- data/lib/spotlight/search_state.rb +19 -0
- data/lib/spotlight/upload_field_config.rb +1 -1
- data/lib/spotlight/version.rb +1 -1
- data/lib/tasks/spotlight_tasks.rake +1 -1
- data/spec/factories/searches.rb +0 -12
- data/spec/fixtures/iiif_responses.rb +64 -64
- data/vendor/assets/javascripts/nestable.js +1 -1
- data/vendor/assets/javascripts/parameterize.js +2 -2
- data/vendor/assets/javascripts/sir-trevor.js +22460 -20591
- data/vendor/assets/stylesheets/sir-trevor/_icons.scss +0 -0
- data/vendor/assets/stylesheets/sir-trevor/_variables.scss +16 -18
- data/vendor/assets/stylesheets/sir-trevor/base.scss +11 -0
- data/vendor/assets/stylesheets/sir-trevor/block-addition-top.scss +4 -1
- data/vendor/assets/stylesheets/sir-trevor/block-addition.scss +3 -2
- data/vendor/assets/stylesheets/sir-trevor/block-controls.scss +4 -0
- data/vendor/assets/stylesheets/sir-trevor/block-positioner.scss +0 -0
- data/vendor/assets/stylesheets/sir-trevor/block-replacer.scss +0 -0
- data/vendor/assets/stylesheets/sir-trevor/block-ui.scss +10 -0
- data/vendor/assets/stylesheets/sir-trevor/block.scss +19 -5
- data/vendor/assets/stylesheets/sir-trevor/errors.scss +0 -0
- data/vendor/assets/stylesheets/sir-trevor/format-bar.scss +0 -0
- data/vendor/assets/stylesheets/sir-trevor/inputs.scss +0 -0
- data/vendor/assets/stylesheets/sir-trevor/main.scss +0 -0
- data/vendor/assets/stylesheets/sir-trevor/patterns/ui-popup.scss +0 -0
- data/vendor/assets/stylesheets/sir-trevor/utils.scss +0 -0
- metadata +118 -131
- data/app/assets/javascripts/spotlight/admin/add_another.js +0 -22
- data/app/assets/javascripts/spotlight/admin/add_new_button.js +0 -81
- data/app/assets/javascripts/spotlight/admin/appearance.js +0 -24
- data/app/assets/javascripts/spotlight/admin/attachments.js +0 -2
- data/app/assets/javascripts/spotlight/admin/blacklight_configuration.js +0 -63
- data/app/assets/javascripts/spotlight/admin/block_mixins/plustextable.js +0 -57
- data/app/assets/javascripts/spotlight/admin/blocks/browse_block.js +0 -87
- data/app/assets/javascripts/spotlight/admin/blocks/browse_group_categories_block.js +0 -88
- data/app/assets/javascripts/spotlight/admin/blocks/oembed_block.js +0 -40
- data/app/assets/javascripts/spotlight/admin/blocks/uploaded_items_block.js +0 -145
- data/app/assets/javascripts/spotlight/admin/catalog_edit.js +0 -16
- data/app/assets/javascripts/spotlight/admin/copy_email_addresses.js +0 -9
- data/app/assets/javascripts/spotlight/admin/croppable.js +0 -25
- data/app/assets/javascripts/spotlight/admin/exhibit_tag_autocomplete.js +0 -37
- data/app/assets/javascripts/spotlight/admin/exhibits.js +0 -58
- data/app/assets/javascripts/spotlight/admin/index.js +0 -16
- data/app/assets/javascripts/spotlight/admin/locks.js +0 -12
- data/app/assets/javascripts/spotlight/admin/pages.js.erb +0 -40
- data/app/assets/javascripts/spotlight/admin/readonly_checkbox.js +0 -6
- data/app/assets/javascripts/spotlight/admin/tabs.js +0 -6
- data/app/assets/javascripts/spotlight/user/carousel.js +0 -3
- data/app/assets/javascripts/spotlight/user/index.js +0 -8
- data/app/assets/javascripts/spotlight/user/zpr_links.js.erb +0 -45
- data/vendor/assets/javascripts/MutationObserver.js +0 -625
- data/vendor/assets/javascripts/eventable.js +0 -205
- data/vendor/assets/javascripts/polyfill.min.js +0 -4
- /data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_embed_block.js +0 -0
- /data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_features_block.js +0 -0
- /data/app/{assets/javascripts → javascript}/spotlight/admin/blocks/solr_documents_grid_block.js +0 -0
- /data/app/{assets/javascripts/spotlight/admin/iiif.es6 → javascript/spotlight/admin/iiif.js} +0 -0
- /data/app/{assets/javascripts → javascript}/spotlight/admin/sir-trevor/locales.js +0 -0
@@ -27,7 +27,7 @@ module Spotlight
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def site_title
|
30
|
-
current_site.title
|
30
|
+
current_site.title.presence
|
31
31
|
end
|
32
32
|
|
33
33
|
# Returns the url for the current page in the new locale. This may be
|
@@ -63,19 +63,6 @@ module Spotlight
|
|
63
63
|
main_app_url_helper?(method) || super
|
64
64
|
end
|
65
65
|
|
66
|
-
##
|
67
|
-
# Override the Blacklight #url_for_document helper to add
|
68
|
-
# the current exhibit context
|
69
|
-
def url_for_document(document)
|
70
|
-
return nil if document.nil?
|
71
|
-
|
72
|
-
if current_exhibit
|
73
|
-
[spotlight, current_exhibit, document]
|
74
|
-
else
|
75
|
-
document
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
66
|
##
|
80
67
|
# Override Blacklight's #document_action_path helper to add
|
81
68
|
# the current exhibit context
|
@@ -139,12 +126,12 @@ module Spotlight
|
|
139
126
|
|
140
127
|
def select_deselect_button
|
141
128
|
button_tag(
|
142
|
-
t(:
|
129
|
+
t(:'.deselect_all'),
|
143
130
|
class: 'btn btn-secondary btn-sm metadata-select',
|
144
131
|
data: {
|
145
132
|
behavior: 'metadata-select',
|
146
|
-
'deselect-text' => t(:
|
147
|
-
'select-text' => t(:
|
133
|
+
'deselect-text' => t(:'.deselect_all'),
|
134
|
+
'select-text' => t(:'.select_all')
|
148
135
|
}
|
149
136
|
)
|
150
137
|
end
|
@@ -171,8 +158,37 @@ module Spotlight
|
|
171
158
|
current_exhibit.theme if current_exhibit && current_exhibit.theme.present? && current_exhibit.themes.include?(current_exhibit.theme)
|
172
159
|
end
|
173
160
|
|
161
|
+
def render_search_bar
|
162
|
+
return super if defined?(super)
|
163
|
+
|
164
|
+
render((blacklight_config&.view_config(document_index_view_type)&.search_bar_component || Blacklight::SearchBarComponent).new(
|
165
|
+
url: search_action_url,
|
166
|
+
advanced_search_url: search_action_url(action: 'advanced_search'),
|
167
|
+
params: search_state.params_for_search.except(:qt),
|
168
|
+
autocomplete_path: suggest_index_catalog_path
|
169
|
+
))
|
170
|
+
end
|
171
|
+
|
172
|
+
def render_constraints(localized_params = nil, local_search_state = nil)
|
173
|
+
return super if defined?(super)
|
174
|
+
|
175
|
+
local_search_state ||= convert_to_search_state(localized_params || search_state)
|
176
|
+
constraints_component = blacklight_config&.view_config(document_index_view_type)&.constraints_component
|
177
|
+
constraints_component ||= Blacklight::ConstraintsComponent
|
178
|
+
render(constraints_component.new(search_state: local_search_state))
|
179
|
+
end
|
180
|
+
|
174
181
|
private
|
175
182
|
|
183
|
+
def convert_to_search_state(params_or_search_state)
|
184
|
+
if params_or_search_state.is_a? Blacklight::SearchState
|
185
|
+
params_or_search_state
|
186
|
+
else
|
187
|
+
# deprecated
|
188
|
+
controller.search_state_class.new(params_or_search_state, blacklight_config, controller)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
176
192
|
def main_app_url_helper?(method)
|
177
193
|
method.to_s.end_with?('_path', '_url') && main_app.respond_to?(method)
|
178
194
|
end
|
@@ -47,14 +47,24 @@ module Spotlight
|
|
47
47
|
def delete_link(model, *args)
|
48
48
|
link_to_options = args.extract_options!
|
49
49
|
link = args.first || [spotlight, model]
|
50
|
-
default_options = {
|
50
|
+
default_options = { data: {
|
51
|
+
method: :delete,
|
52
|
+
turbo_method: :delete,
|
53
|
+
confirm: action_default_value(model, :destroy_are_you_sure),
|
54
|
+
turbo_confirm: action_default_value(model, :destroy_are_you_sure)
|
55
|
+
} }
|
51
56
|
link_to action_default_value(model, :destroy), link, default_options.merge(link_to_options)
|
52
57
|
end
|
53
58
|
|
54
59
|
def exhibit_delete_link(model, *args)
|
55
60
|
link_to_options = args.extract_options!
|
56
61
|
link = args.first || [spotlight, model.exhibit, model]
|
57
|
-
default_options = {
|
62
|
+
default_options = { data: {
|
63
|
+
method: :delete,
|
64
|
+
turbo_method: :delete,
|
65
|
+
confirm: action_default_value(model, :destroy_are_you_sure),
|
66
|
+
turbo_confirm: action_default_value(model, :destroy_are_you_sure)
|
67
|
+
} }
|
58
68
|
link_to action_default_value(model, :destroy), link, default_options.merge(link_to_options)
|
59
69
|
end
|
60
70
|
|
@@ -74,7 +74,7 @@ module Spotlight
|
|
74
74
|
|
75
75
|
# Insert soft breaks into email addresses so they wrap nicely
|
76
76
|
def render_contact_email_address(address)
|
77
|
-
mail_to address, sanitize(address).gsub(/([
|
77
|
+
mail_to address, sanitize(address).gsub(/([@.])/, '\1<wbr />').html_safe
|
78
78
|
end
|
79
79
|
|
80
80
|
def configurations_for_current_page
|
@@ -7,8 +7,8 @@ module Spotlight
|
|
7
7
|
##
|
8
8
|
# Format the available roles for a select_tag
|
9
9
|
def roles_for_select
|
10
|
-
Spotlight::Engine.config.exhibit_roles.
|
11
|
-
|
10
|
+
Spotlight::Engine.config.exhibit_roles.index_by do |key|
|
11
|
+
t("spotlight.role.#{key}")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -7,9 +7,7 @@ module Spotlight
|
|
7
7
|
def non_custom_metadata_fields
|
8
8
|
custom_field_keys = current_exhibit.custom_fields.pluck(:field)
|
9
9
|
|
10
|
-
current_exhibit.blacklight_config.show_fields.
|
11
|
-
custom_field_keys.include?(key)
|
12
|
-
end
|
10
|
+
current_exhibit.blacklight_config.show_fields.except(*custom_field_keys)
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
export default class {
|
2
|
+
connect() {
|
3
|
+
$("[data-action='add-another']").on("click", function(event) {
|
4
|
+
event.preventDefault();
|
5
|
+
|
6
|
+
var templateId = $(this).data('template-id');
|
7
|
+
|
8
|
+
var template = document.querySelector('#' + templateId);
|
9
|
+
var clone = document.importNode(template.content, true);
|
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
|
+
});
|
15
|
+
|
16
|
+
$(clone).find('[for]').each(function(index, el) {
|
17
|
+
$(el).attr('for', $(el).attr('for') + '_' + String(count));
|
18
|
+
});
|
19
|
+
|
20
|
+
|
21
|
+
$(clone).insertBefore(this);
|
22
|
+
});
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import Iiif from 'iiif'
|
2
|
+
|
3
|
+
export function addImageSelector(input, panel, manifestUrl, initialize) {
|
4
|
+
if (!manifestUrl) {
|
5
|
+
showNonIiifAlert(input);
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
var cropper = input.data('iiifCropper');
|
9
|
+
$.ajax(manifestUrl).done(
|
10
|
+
function(manifest) {
|
11
|
+
var iiifManifest = new Iiif(manifestUrl, manifest);
|
12
|
+
|
13
|
+
var thumbs = iiifManifest.imagesArray();
|
14
|
+
|
15
|
+
hideNonIiifAlert(input);
|
16
|
+
|
17
|
+
if (initialize) {
|
18
|
+
cropper.setIiifFields(thumbs[0]);
|
19
|
+
panel.multiImageSelector(); // Clears out existing selector
|
20
|
+
}
|
21
|
+
|
22
|
+
if(thumbs.length > 1) {
|
23
|
+
panel.show();
|
24
|
+
panel.multiImageSelector(thumbs, function(selectorImage) {
|
25
|
+
cropper.setIiifFields(selectorImage);
|
26
|
+
}, cropper.iiifImageField.val());
|
27
|
+
}
|
28
|
+
}
|
29
|
+
);
|
30
|
+
}
|
31
|
+
|
32
|
+
function showNonIiifAlert(input){
|
33
|
+
input.parent().prev('[data-behavior="non-iiif-alert"]').show();
|
34
|
+
}
|
35
|
+
|
36
|
+
function hideNonIiifAlert(input){
|
37
|
+
input.parent().prev('[data-behavior="non-iiif-alert"]').hide();
|
38
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
export default class {
|
2
|
+
connect() {
|
3
|
+
$("[data-expanded-add-button]").each((_i, el) => this.addExpandBehaviorToButton($(el)))
|
4
|
+
}
|
5
|
+
|
6
|
+
addExpandBehaviorToButton(button){
|
7
|
+
var settings = {
|
8
|
+
speed: (button.data('speed') || 450),
|
9
|
+
animate_width: (button.data('animate_width') || 425)
|
10
|
+
}
|
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;
|
17
|
+
|
18
|
+
// Animate button open when the mouse enters or
|
19
|
+
// the button is given focus (i.e. clicked/tabbed)
|
20
|
+
button.on("mouseenter focus", function(){
|
21
|
+
expandButton();
|
22
|
+
});
|
23
|
+
|
24
|
+
// Don't allow blank titles
|
25
|
+
save.on('click', function(){
|
26
|
+
if ( inputEmpty() ) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
});
|
30
|
+
|
31
|
+
// Empty input and collapse
|
32
|
+
// button on cancel click
|
33
|
+
cancel.on('click', function(e){
|
34
|
+
e.preventDefault();
|
35
|
+
input.val('');
|
36
|
+
collapseButton();
|
37
|
+
});
|
38
|
+
|
39
|
+
// Collapse the button on when
|
40
|
+
// an empty input loses focus
|
41
|
+
input.on("blur", function(){
|
42
|
+
if ( inputEmpty() ) {
|
43
|
+
collapseButton();
|
44
|
+
}
|
45
|
+
});
|
46
|
+
function expandButton(){
|
47
|
+
// If this has not yet been expanded, recalculate original_width to
|
48
|
+
// handle things that may have been originally hidden.
|
49
|
+
if (!expanded) {
|
50
|
+
original_width = button.outerWidth();
|
51
|
+
}
|
52
|
+
if(button.outerWidth() <= (original_width + 5)) {
|
53
|
+
expanded = true;
|
54
|
+
button.animate(
|
55
|
+
{width: settings.animate_width + 'px'}, settings.speed, function(){
|
56
|
+
target.show(0, function(){
|
57
|
+
input.focus();
|
58
|
+
// Set the button to auto width to make
|
59
|
+
// sure it has room for any inputs
|
60
|
+
button.width("auto");
|
61
|
+
// Explicitly set the width of the button
|
62
|
+
// so the close animation works properly
|
63
|
+
button.width(button.width());
|
64
|
+
});
|
65
|
+
}
|
66
|
+
)
|
67
|
+
}
|
68
|
+
}
|
69
|
+
function collapseButton(){
|
70
|
+
target.hide();
|
71
|
+
button.animate({width: original_width + 'px'}, settings.speed);
|
72
|
+
}
|
73
|
+
function inputEmpty(){
|
74
|
+
return $.trim(input.val()) == "";
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
export default class {
|
2
|
+
connect(){
|
3
|
+
$("[data-behavior='restore-default']").each(function(){
|
4
|
+
var hidden = $("[data-default-value]", $(this));
|
5
|
+
var value = $($("[data-in-place-edit-target]", $(this)).data('in-place-edit-target'), $(this));
|
6
|
+
var button = $("[data-restore-default]", $(this));
|
7
|
+
hidden.on('blur', function(){
|
8
|
+
if( $(this).val() == $(this).data('default-value') ) {
|
9
|
+
button.addClass('d-none');
|
10
|
+
} else {
|
11
|
+
button.removeClass('d-none');
|
12
|
+
}
|
13
|
+
});
|
14
|
+
button.on('click', function(e){
|
15
|
+
e.preventDefault();
|
16
|
+
hidden.val(hidden.data('default-value'));
|
17
|
+
value.text(hidden.data('default-value'));
|
18
|
+
button.hide();
|
19
|
+
});
|
20
|
+
});
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
export default class {
|
2
|
+
connect() {
|
3
|
+
// Add Select/Deselect all button behavior
|
4
|
+
this.addCheckboxToggleBehavior();
|
5
|
+
this.addEnableToggleBehavior();
|
6
|
+
}
|
7
|
+
|
8
|
+
// Add Select/Deselect all button behavior
|
9
|
+
addCheckboxToggleBehavior() {
|
10
|
+
$("[data-behavior='metadata-select']").each(function(){
|
11
|
+
var button = $(this)
|
12
|
+
var parentCell = button.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
|
+
swapSelectAllButtonText(button, columnRows);
|
17
|
+
// Add the check/uncheck behavior to the button
|
18
|
+
// and swap the button text if necessary
|
19
|
+
button.on('click', function(e){
|
20
|
+
e.preventDefault();
|
21
|
+
var allChecked = allCheckboxesChecked(columnRows);
|
22
|
+
columnRows.each(function(){
|
23
|
+
$("input[type='checkbox']", $(this)).prop('checked', !allChecked);
|
24
|
+
swapSelectAllButtonText(button, columnRows);
|
25
|
+
});
|
26
|
+
});
|
27
|
+
// Swap button text when a checkbox value changes
|
28
|
+
checkboxes.each(function(){
|
29
|
+
$(this).on('change', function(){
|
30
|
+
swapSelectAllButtonText(button, columnRows);
|
31
|
+
});
|
32
|
+
});
|
33
|
+
});
|
34
|
+
// Check number of checkboxes against the number of checked
|
35
|
+
// checkboxes to determine if all of them are checked or not
|
36
|
+
function allCheckboxesChecked(elements) {
|
37
|
+
return ($("input[type='checkbox']", elements).length == $("input[type='checkbox']:checked", elements).length)
|
38
|
+
}
|
39
|
+
// Swap the button text to "Deselect all"
|
40
|
+
// when all the checkboxes are checked and
|
41
|
+
// "Select all" when any are unchecked
|
42
|
+
function swapSelectAllButtonText(button, elements) {
|
43
|
+
if ( allCheckboxesChecked(elements) ) {
|
44
|
+
button.text(button.data('deselect-text'));
|
45
|
+
} else {
|
46
|
+
button.text(button.data('select-text'));
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
addEnableToggleBehavior() {
|
52
|
+
$("[data-behavior='enable-feature']").each(function(){
|
53
|
+
var checkbox = $(this);
|
54
|
+
var target = $($(this).data('target'));
|
55
|
+
|
56
|
+
checkbox.on('change', function() {
|
57
|
+
if ($(this).is(':checked')) {
|
58
|
+
target.find('input:checkbox').not("[data-behavior='enable-feature']").prop('checked', true).attr('disabled', false);
|
59
|
+
} else {
|
60
|
+
target.find('input:checkbox').not("[data-behavior='enable-feature']").prop('checked', false).attr('disabled', true);
|
61
|
+
}
|
62
|
+
});
|
63
|
+
});
|
64
|
+
}
|
65
|
+
}
|
@@ -6,23 +6,23 @@
|
|
6
6
|
initializeAutocompleteable: function() {
|
7
7
|
this.on("onRender", this.addAutocompletetoSirTrevorForm);
|
8
8
|
|
9
|
-
if (
|
9
|
+
if (this['autocomplete_url'] === undefined) {
|
10
10
|
this.autocomplete_url = function() { return $('form[data-autocomplete-url]').data('autocomplete-url').replace("%25QUERY", "%QUERY"); };
|
11
11
|
}
|
12
12
|
|
13
|
-
if (
|
13
|
+
if (this['autocomplete_template'] === undefined) {
|
14
14
|
this.autocomplete_url = function() { return '<div class="autocomplete-item{{#if private}} blacklight-private{{/if}}">{{#if thumbnail}}<div class="document-thumbnail"><img class="img-thumbnail" src="{{thumbnail}}" /></div>{{/if}}<span class="autocomplete-title">{{title}}</span><br/><small> {{description}}</small></div>' };
|
15
15
|
}
|
16
16
|
|
17
|
-
if (
|
18
|
-
this.transform_autocomplete_results =
|
17
|
+
if (this['transform_autocomplete_results'] === undefined) {
|
18
|
+
this.transform_autocomplete_results = (val) => val
|
19
19
|
}
|
20
20
|
|
21
|
-
if (
|
22
|
-
this.autocomplete_control = function() { return
|
21
|
+
if (this['autocomplete_control'] === undefined) {
|
22
|
+
this.autocomplete_control = function() { return `<input type="text" class="st-input-string form-control item-input-field" data-twitter-typeahead="true" placeholder="${i18n.t("blocks:autocompleteable:placeholder")}"/>` };
|
23
23
|
}
|
24
24
|
|
25
|
-
if (
|
25
|
+
if (this['bloodhoundOptions'] === undefined) {
|
26
26
|
this.bloodhoundOptions = function() {
|
27
27
|
return {
|
28
28
|
remote: {
|
@@ -55,7 +55,7 @@
|
|
55
55
|
|
56
56
|
bloodhound: function() {
|
57
57
|
var block = this;
|
58
|
-
var results = new Bloodhound(
|
58
|
+
var results = new Bloodhound(Object.assign({
|
59
59
|
datumTokenizer: function(d) {
|
60
60
|
return Bloodhound.tokenizers.whitespace(d.title);
|
61
61
|
},
|
@@ -0,0 +1,58 @@
|
|
1
|
+
(function ($){
|
2
|
+
SirTrevor.BlockMixins.Plustextable = {
|
3
|
+
mixinName: "Textable",
|
4
|
+
preload: true,
|
5
|
+
|
6
|
+
initializeTextable: function() {
|
7
|
+
if (this['formId'] === undefined) {
|
8
|
+
this.withMixin(SirTrevor.BlockMixins.Formable);
|
9
|
+
}
|
10
|
+
|
11
|
+
if (this['show_heading'] === undefined) {
|
12
|
+
this.show_heading = true;
|
13
|
+
}
|
14
|
+
},
|
15
|
+
|
16
|
+
align_key:"text-align",
|
17
|
+
text_key:"item-text",
|
18
|
+
heading_key: "title",
|
19
|
+
|
20
|
+
text_area: function() {
|
21
|
+
return `
|
22
|
+
<div class="row">
|
23
|
+
<div class="col-md-8">
|
24
|
+
<div class="form-group">
|
25
|
+
${this.heading()}
|
26
|
+
<div class="field">
|
27
|
+
<label for="${this.formId(this.text_key)}" class="col-form-label">${i18n.t("blocks:textable:text")}</label>
|
28
|
+
<div id="${this.formId(this.text_key)}" class="st-text-block form-control" contenteditable="true"></div>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<div class="col-md-4">
|
33
|
+
<div class="text-align">
|
34
|
+
<p>${i18n.t("blocks:textable:align:title")}</p>
|
35
|
+
<input data-key="${this.align_key}" type="radio" name="${this.formId(this.align_key)}" id="${this.formId(this.align_key + "-left")}" value="left" checked="true">
|
36
|
+
<label for="${this.formId(this.align_key + "-left")}">${i18n.t("blocks:textable:align:left")}</label>
|
37
|
+
<input data-key="${this.align_key}" type="radio" name="${this.formId(this.align_key)}" id="${this.formId(this.align_key + "-right")}" value="right">
|
38
|
+
<label for="${this.formId(this.align_key + "-right")}">${i18n.t("blocks:textable:align:right")}</label>
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
</div>`
|
42
|
+
},
|
43
|
+
|
44
|
+
heading: function() {
|
45
|
+
if(this.show_heading) {
|
46
|
+
return `<div class="field">
|
47
|
+
<label for="${this.formId(this.heading_key)}" class="col-form-label">${i18n.t("blocks:textable:heading")}</label>
|
48
|
+
<input type="text" class="form-control" id="${this.formId(this.heading_key)}" name="${this.heading_key}" />
|
49
|
+
</div>`
|
50
|
+
} else {
|
51
|
+
return "";
|
52
|
+
}
|
53
|
+
},
|
54
|
+
};
|
55
|
+
|
56
|
+
|
57
|
+
SirTrevor.Block.prototype.availableMixins.push("plustextable");
|
58
|
+
})(jQuery);
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import Spotlight from 'spotlight'
|
1
2
|
(function ($){
|
2
3
|
Spotlight.Block = SirTrevor.Block.extend({
|
3
4
|
scribeOptions: {
|
@@ -6,7 +7,7 @@
|
|
6
7
|
},
|
7
8
|
formable: true,
|
8
9
|
editorHTML: function() {
|
9
|
-
return
|
10
|
+
return '';
|
10
11
|
},
|
11
12
|
beforeBlockRender: function() {
|
12
13
|
this.availableMixins.forEach(function(mixin) {
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import Spotlight from 'spotlight'
|
2
|
+
|
3
|
+
SirTrevor.Blocks.Browse = (function(){
|
4
|
+
|
5
|
+
return Spotlight.Block.Resources.extend({
|
6
|
+
type: "browse",
|
7
|
+
|
8
|
+
icon_name: "browse",
|
9
|
+
|
10
|
+
autocomplete_url: function() {
|
11
|
+
return $(this.inner).closest('form[data-autocomplete-exhibit-searches-path]').data('autocomplete-exhibit-searches-path').replace("%25QUERY", "%QUERY");
|
12
|
+
},
|
13
|
+
autocomplete_template: function() { return '<div class="autocomplete-item{{#unless published}} blacklight-private{{/unless}}">{{#if thumbnail_image_url}}<div class="document-thumbnail"><img class="img-thumbnail" src="{{thumbnail_image_url}}" /></div>{{/if}}<span class="autocomplete-title">{{full_title}}</span><br/><small> {{description}}</small></div>' },
|
14
|
+
|
15
|
+
bloodhoundOptions: function() {
|
16
|
+
return {
|
17
|
+
prefetch: {
|
18
|
+
url: this.autocomplete_url(),
|
19
|
+
ttl: 0
|
20
|
+
}
|
21
|
+
};
|
22
|
+
},
|
23
|
+
|
24
|
+
_itemPanel: function(data) {
|
25
|
+
var index = "item_" + this.globalIndex++;
|
26
|
+
var checked;
|
27
|
+
if (data.display == "true") {
|
28
|
+
checked = "checked='checked'"
|
29
|
+
} else {
|
30
|
+
checked = "";
|
31
|
+
}
|
32
|
+
var resource_id = data.slug || data.id;
|
33
|
+
var markup = `
|
34
|
+
<li class="field form-inline dd-item dd3-item" data-resource-id="${resource_id}" data-id="${index}" id="${this.formId("item_" + data.id)}">
|
35
|
+
<input type="hidden" name="item[${index}][id]" value="${resource_id}" />
|
36
|
+
<input type="hidden" name="item[${index}][full_title]" value="${(data.full_title || data.title)}" />
|
37
|
+
<input data-property="weight" type="hidden" name="item[${index}][weight]" value="${data.weight}" />
|
38
|
+
<div class="card d-flex dd3-content">
|
39
|
+
<div class="dd-handle dd3-handle">${i18n.t("blocks:resources:panel:drag")}</div>
|
40
|
+
<div class="card-header item-grid">
|
41
|
+
<div class="d-flex">
|
42
|
+
<div class="checkbox">
|
43
|
+
<input name="item[${index}][display]" type="hidden" value="false" />
|
44
|
+
<input name="item[${index}][display]" id="${this.formId(this.display_checkbox + '_' + data.id)}" type="checkbox" ${checked} class="item-grid-checkbox" value="true" />
|
45
|
+
<label class="sr-only" for="${this.formId(this.display_checkbox + '_' + data.id)}">${i18n.t("blocks:resources:panel:display")}</label>
|
46
|
+
</div>
|
47
|
+
<div class="pic">
|
48
|
+
<img class="img-thumbnail" src="${(data.thumbnail_image_url || ((data.iiif_tilesource || "").replace("/info.json", "/full/!100,100/0/default.jpg")))}" />
|
49
|
+
</div>
|
50
|
+
<div class="main">
|
51
|
+
<div class="title card-title">${(data.full_title || data.title)}</div>
|
52
|
+
<div>${(data.slug || data.id)}</div>
|
53
|
+
</div>
|
54
|
+
<div class="remove float-right">
|
55
|
+
<a data-item-grid-panel-remove="true" href="#">${i18n.t("blocks:resources:panel:remove")}</a>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
</li>`
|
61
|
+
|
62
|
+
var panel = $(markup);
|
63
|
+
var context = this;
|
64
|
+
|
65
|
+
$('.remove a', panel).on('click', function(e) {
|
66
|
+
e.preventDefault();
|
67
|
+
$(this).closest('.field').remove();
|
68
|
+
context.afterPanelDelete();
|
69
|
+
|
70
|
+
});
|
71
|
+
|
72
|
+
this.afterPanelRender(data, panel);
|
73
|
+
|
74
|
+
return panel;
|
75
|
+
},
|
76
|
+
|
77
|
+
item_options: function() { return `
|
78
|
+
<label>
|
79
|
+
<input type="hidden" name="display-item-counts" value="false" />
|
80
|
+
<input type="checkbox" name="display-item-counts" value="true" checked />
|
81
|
+
${i18n.t("blocks:browse:item_counts")}
|
82
|
+
</label>`
|
83
|
+
},
|
84
|
+
});
|
85
|
+
|
86
|
+
})();
|