blacklight-spotlight 2.7.2 → 2.8.0
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/app/assets/javascripts/spotlight/admin/add_another.js +22 -0
- data/app/assets/javascripts/spotlight/{add_new_page_button.js → admin/add_new_page_button.js} +0 -0
- data/app/assets/javascripts/spotlight/{appearance.js → admin/appearance.js} +0 -0
- data/app/assets/javascripts/spotlight/{attachments.js → admin/attachments.js} +0 -0
- data/app/assets/javascripts/spotlight/{blacklight_configuration.js → admin/blacklight_configuration.js} +0 -0
- data/app/assets/javascripts/spotlight/{block_mixins → admin/block_mixins}/autocompleteable.js +0 -0
- data/app/assets/javascripts/spotlight/{block_mixins → admin/block_mixins}/formable.js +0 -0
- data/app/assets/javascripts/spotlight/{block_mixins → admin/block_mixins}/plustextable.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/browse_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/iframe_block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/link_to_search_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/oembed_block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/pages_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/resources_block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/rule_block.js +0 -0
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/search_result_block.js +3 -3
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_base_block.js +2 -2
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_carousel_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_embed_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_features_block.js +2 -2
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_grid_block.js +1 -1
- data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/uploaded_items_block.js +0 -0
- data/app/assets/javascripts/spotlight/{catalog_edit.js → admin/catalog_edit.js} +0 -0
- data/app/assets/javascripts/spotlight/{copy_email_addresses.js → admin/copy_email_addresses.js} +0 -0
- data/app/assets/javascripts/spotlight/{crop.es6 → admin/crop.es6} +0 -0
- data/app/assets/javascripts/spotlight/{croppable.js → admin/croppable.js} +1 -1
- data/app/assets/javascripts/spotlight/{edit_in_place.js → admin/edit_in_place.js} +0 -0
- data/app/assets/javascripts/spotlight/{exhibits.js → admin/exhibits.js} +0 -0
- data/app/assets/javascripts/spotlight/{form_observer.js → admin/form_observer.js} +0 -0
- data/app/assets/javascripts/spotlight/{iiif.es6 → admin/iiif.es6} +0 -0
- data/app/assets/javascripts/spotlight/admin/index.js +18 -0
- data/app/assets/javascripts/spotlight/{locks.js → admin/locks.js} +0 -0
- data/app/assets/javascripts/spotlight/{multi_image_selector.js → admin/multi_image_selector.js} +0 -0
- data/app/assets/javascripts/spotlight/{pages.js.erb → admin/pages.js.erb} +0 -2
- data/app/assets/javascripts/spotlight/{readonly_checkbox.js → admin/readonly_checkbox.js} +0 -0
- data/app/assets/javascripts/spotlight/{reindex_monitor.js → admin/reindex_monitor.js} +0 -0
- data/app/assets/javascripts/spotlight/{search_typeahead.js → admin/search_typeahead.js} +1 -1
- data/app/assets/javascripts/spotlight/{select_related_input.js → admin/select_related_input.js} +0 -0
- data/app/assets/javascripts/spotlight/{sir-trevor → admin/sir-trevor}/block_controls.js +0 -0
- data/app/assets/javascripts/spotlight/{sir-trevor → admin/sir-trevor}/block_limits.js +0 -0
- data/app/assets/javascripts/spotlight/{sir-trevor → admin/sir-trevor}/locales.js +0 -0
- data/app/assets/javascripts/spotlight/{spotlight_nestable.js → admin/spotlight_nestable.js} +0 -0
- data/app/assets/javascripts/spotlight/{tabs.js → admin/tabs.js} +0 -0
- data/app/assets/javascripts/spotlight/{translation_progress.js → admin/translation_progress.js} +0 -0
- data/app/assets/javascripts/spotlight/{users.js → admin/users.js} +0 -0
- data/app/assets/javascripts/spotlight/application.js +2 -22
- data/app/assets/javascripts/spotlight/{analytics.js → user/analytics.js} +0 -0
- data/app/assets/javascripts/spotlight/user/carousel.js +3 -0
- data/app/assets/javascripts/spotlight/{clear_form_button.js → user/clear_form_button.js} +0 -0
- data/app/assets/javascripts/spotlight/user/index.js +6 -0
- data/app/assets/javascripts/spotlight/{report_a_problem.js → user/report_a_problem.js} +0 -0
- data/app/assets/javascripts/spotlight/{zpr_links.js.erb → user/zpr_links.js.erb} +0 -0
- data/app/controllers/spotlight/catalog_controller.rb +1 -1
- data/app/controllers/spotlight/custom_fields_controller.rb +1 -1
- data/app/controllers/spotlight/resources/csv_upload_controller.rb +1 -1
- data/app/controllers/spotlight/resources/upload_controller.rb +17 -13
- data/app/controllers/spotlight/resources_controller.rb +5 -0
- data/app/controllers/spotlight/searches_controller.rb +0 -2
- data/app/controllers/spotlight/solr_controller.rb +18 -1
- data/app/helpers/spotlight/pages_helper.rb +10 -0
- data/app/jobs/spotlight/add_uploads_from_csv.rb +1 -1
- data/app/jobs/spotlight/rename_sidecar_field_job.rb +21 -7
- data/app/models/spotlight/blacklight_configuration.rb +4 -2
- data/app/models/spotlight/custom_field.rb +20 -20
- data/app/models/spotlight/exhibit.rb +11 -1
- data/app/models/spotlight/page.rb +10 -4
- data/app/models/spotlight/page_content.rb +18 -0
- data/app/models/spotlight/page_content/sir_trevor.rb +17 -0
- data/app/models/spotlight/solr_document_sidecar.rb +3 -0
- data/app/presenters/spotlight/iiif_manifest_presenter.rb +2 -2
- data/app/serializers/spotlight/exhibit_export_serializer.rb +4 -0
- data/app/services/spotlight/upload_solr_document_builder.rb +10 -3
- data/app/values/custom_field_name.rb +6 -6
- data/app/views/spotlight/catalog/_edit_sidecar.html.erb +9 -14
- data/app/views/spotlight/custom_fields/_form.html.erb +7 -2
- data/app/views/spotlight/custom_fields/form_group/_text.html.erb +14 -0
- data/app/views/spotlight/custom_fields/form_group/_vocab.html.erb +14 -0
- data/app/views/spotlight/pages/_form.html.erb +1 -1
- data/app/views/spotlight/resources/new.html.erb +9 -3
- data/app/views/spotlight/resources/upload/_form.html.erb +3 -1
- data/config/i18n-tasks.yml +1 -0
- data/config/locales/spotlight.en.yml +5 -0
- data/db/migrate/20190807085432_add_content_type_to_pages.rb +5 -0
- data/db/migrate/20190813085432_add_is_multiple_to_custom_fields.rb +7 -0
- data/lib/spotlight/engine.rb +8 -1
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/catalog_controller_spec.rb +6 -0
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +1 -1
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +9 -1
- data/spec/controllers/spotlight/solr_controller_spec.rb +16 -0
- data/spec/examples.txt +1305 -1325
- data/spec/features/add_custom_field_metadata_spec.rb +19 -1
- data/spec/features/add_items_spec.rb +19 -2
- data/spec/features/exhibits/custom_metadata_fields_spec.rb +23 -0
- data/spec/helpers/spotlight/pages_helper_spec.rb +14 -0
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +4 -2
- data/spec/models/spotlight/blacklight_configuration_spec.rb +2 -2
- data/spec/models/spotlight/custom_field_spec.rb +8 -3
- data/spec/models/spotlight/page_spec.rb +35 -0
- metadata +61 -51
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ac1f71a7c34266e2dd2f81dfda9a018875c4ad4944a5a8774049543f90db8b4
|
|
4
|
+
data.tar.gz: eaadb518e5265e68db7218316b47603c475c88dd28f897632a4284e825991092
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa75fcb80e27553c1ccfae5e68e758ed071f7b12859cbf49a99d34db9b47863b17d5bb2e32458a43a7cd019c793b4c88833b9fe61c15c2e2cfeec776c344d89f
|
|
7
|
+
data.tar.gz: d65c481345efae06a0734717111a14c98e3b4a094af74cd6cf3e7abfbd2bc5dadbb02fd0ece058ba077d20e87e402fcef3849ced5202dce44899027c00faed59
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Spotlight.onLoad(function() {
|
|
2
|
+
$("[data-action='add-another']").on("click", function(event) {
|
|
3
|
+
event.preventDefault();
|
|
4
|
+
|
|
5
|
+
var templateId = $(this).data('template-id');
|
|
6
|
+
|
|
7
|
+
var template = document.querySelector('#' + templateId);
|
|
8
|
+
var clone = document.importNode(template.content, true);
|
|
9
|
+
|
|
10
|
+
var count = $(this).closest('.form-group').find('[name="' + $(clone).find('[name]').attr('name') + '"]').length + 1;
|
|
11
|
+
$(clone).find('[id]').each(function(index, el) {
|
|
12
|
+
$(el).attr('id', $(el).attr('id') + '_' + String(count));
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
$(clone).find('[for]').each(function(index, el) {
|
|
16
|
+
$(el).attr('for', $(el).attr('for') + '_' + String(count));
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
$(clone).insertBefore(this);
|
|
21
|
+
});
|
|
22
|
+
});
|
data/app/assets/javascripts/spotlight/{add_new_page_button.js → admin/add_new_page_button.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/app/assets/javascripts/spotlight/{block_mixins → admin/block_mixins}/autocompleteable.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//= require spotlight/blocks/browse_block
|
|
1
|
+
//= require spotlight/admin/blocks/browse_block
|
|
2
2
|
|
|
3
3
|
SirTrevor.Blocks.SearchResults = (function(){
|
|
4
4
|
|
|
@@ -15,7 +15,7 @@ SirTrevor.Blocks.SearchResults = (function(){
|
|
|
15
15
|
content: function() {
|
|
16
16
|
return _.template([this.items_selector()].join("<hr />\n"))(this);
|
|
17
17
|
},
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
item_options: function() {
|
|
20
20
|
var block = this;
|
|
21
21
|
var fields = $('[data-blacklight-configuration-search-views]').data('blacklight-configuration-search-views');
|
|
@@ -41,4 +41,4 @@ SirTrevor.Blocks.SearchResults = (function(){
|
|
|
41
41
|
},
|
|
42
42
|
|
|
43
43
|
});
|
|
44
|
-
})();
|
|
44
|
+
})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//= require spotlight/blocks/resources_block
|
|
1
|
+
//= require spotlight/admin/blocks/resources_block
|
|
2
2
|
|
|
3
3
|
SirTrevor.Blocks.SolrDocumentsBase = (function(){
|
|
4
4
|
|
|
@@ -85,7 +85,7 @@ SirTrevor.Blocks.SolrDocumentsBase = (function(){
|
|
|
85
85
|
|
|
86
86
|
$.ajax(manifestUrl).success(
|
|
87
87
|
function(manifest) {
|
|
88
|
-
var Iiif = require('spotlight/iiif');
|
|
88
|
+
var Iiif = require('spotlight/admin/iiif');
|
|
89
89
|
var iiifManifest = new Iiif(manifestUrl, manifest);
|
|
90
90
|
|
|
91
91
|
var thumbs = iiifManifest.imagesArray();
|
data/app/assets/javascripts/spotlight/{blocks → admin/blocks}/solr_documents_features_block.js
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//= require spotlight/blocks/solr_documents_base_block
|
|
1
|
+
//= require spotlight/admin/blocks/solr_documents_base_block
|
|
2
2
|
|
|
3
3
|
SirTrevor.Blocks.SolrDocumentsFeatures = (function(){
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ SirTrevor.Blocks.SolrDocumentsFeatures = (function(){
|
|
|
7
7
|
type: "solr_documents_features",
|
|
8
8
|
|
|
9
9
|
icon_name: "item_features",
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
afterPreviewLoad: function(options) {
|
|
12
12
|
$(this.inner).find('.carousel').carousel();
|
|
13
13
|
|
|
File without changes
|
|
File without changes
|
data/app/assets/javascripts/spotlight/{copy_email_addresses.js → admin/copy_email_addresses.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -12,7 +12,7 @@ Spotlight.onLoad(function() {
|
|
|
12
12
|
$.fn.croppable = function() {
|
|
13
13
|
var croppables = this;
|
|
14
14
|
|
|
15
|
-
var Crop = require('spotlight/crop');
|
|
15
|
+
var Crop = require('spotlight/admin/crop');
|
|
16
16
|
$(croppables).each(function() {
|
|
17
17
|
var cropElement = $(this);
|
|
18
18
|
var c = new Crop(cropElement);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//= require underscore
|
|
2
|
+
//= require eventable
|
|
3
|
+
//= require sir-trevor
|
|
4
|
+
//= require nestable
|
|
5
|
+
//= require parameterize
|
|
6
|
+
//= require bootstrap-tagsinput
|
|
7
|
+
//= require jquery.serializejson
|
|
8
|
+
//= require clipboard
|
|
9
|
+
//= require leaflet
|
|
10
|
+
//= require leaflet-iiif
|
|
11
|
+
//= require Leaflet.Editable
|
|
12
|
+
//= require Path.Drag
|
|
13
|
+
//= require MutationObserver
|
|
14
|
+
|
|
15
|
+
// Provide AMD module support
|
|
16
|
+
//= require almond
|
|
17
|
+
//= require polyfill.min.js
|
|
18
|
+
//= require_tree .
|
|
File without changes
|
data/app/assets/javascripts/spotlight/{multi_image_selector.js → admin/multi_image_selector.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -73,7 +73,7 @@ function addImageSelector(input, panel, manifestUrl, initialize) {
|
|
|
73
73
|
var cropper = input.data('iiifCropper');
|
|
74
74
|
$.ajax(manifestUrl).success(
|
|
75
75
|
function(manifest) {
|
|
76
|
-
var Iiif = require('spotlight/iiif');
|
|
76
|
+
var Iiif = require('spotlight/admin/iiif');
|
|
77
77
|
var iiifManifest = new Iiif(manifestUrl, manifest);
|
|
78
78
|
|
|
79
79
|
var thumbs = iiifManifest.imagesArray();
|
data/app/assets/javascripts/spotlight/{select_related_input.js → admin/select_related_input.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/app/assets/javascripts/spotlight/{translation_progress.js → admin/translation_progress.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -10,25 +10,5 @@
|
|
|
10
10
|
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
11
|
// about supported directives.
|
|
12
12
|
//
|
|
13
|
-
//= require
|
|
14
|
-
//= require
|
|
15
|
-
//= require sir-trevor
|
|
16
|
-
//= require nestable
|
|
17
|
-
//= require parameterize
|
|
18
|
-
//= require spotlight/spotlight
|
|
19
|
-
//= require bootstrap/tab
|
|
20
|
-
//= require bootstrap/tooltip
|
|
21
|
-
//= require bootstrap/popover
|
|
22
|
-
//= require bootstrap/carousel
|
|
23
|
-
//= require bootstrap-tagsinput
|
|
24
|
-
//= require jquery.serializejson
|
|
25
|
-
//= require clipboard
|
|
26
|
-
//= require leaflet
|
|
27
|
-
//= require leaflet-iiif
|
|
28
|
-
//= require Leaflet.Editable
|
|
29
|
-
//= require Path.Drag
|
|
30
|
-
//= require MutationObserver
|
|
31
|
-
// Provide AMD module support
|
|
32
|
-
//= require almond
|
|
33
|
-
//= require polyfill.min.js
|
|
34
|
-
//= require_tree .
|
|
13
|
+
//= require spotlight/user/index
|
|
14
|
+
//= require spotlight/admin/index
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -18,7 +18,7 @@ module Spotlight
|
|
|
18
18
|
csv = CSV.parse(csv_io_param, headers: true, return_headers: false).map(&:to_hash)
|
|
19
19
|
Spotlight::AddUploadsFromCSV.perform_later(csv, current_exhibit, current_user)
|
|
20
20
|
flash[:notice] = t('spotlight.resources.upload.csv.success', file_name: csv_io_name)
|
|
21
|
-
|
|
21
|
+
redirect_to spotlight.admin_exhibit_catalog_path(current_exhibit)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def template
|
|
@@ -9,35 +9,38 @@ module Spotlight
|
|
|
9
9
|
helper :all
|
|
10
10
|
|
|
11
11
|
before_action :authenticate_user!
|
|
12
|
+
before_action :set_tab, only: [:new, :create]
|
|
12
13
|
|
|
13
14
|
load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
|
|
14
15
|
before_action :build_resource
|
|
15
16
|
|
|
16
17
|
load_and_authorize_resource class: 'Spotlight::Resources::Upload', through_association: 'exhibit.resources', instance_name: 'resource'
|
|
17
18
|
|
|
18
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
19
19
|
def create
|
|
20
|
-
@resource.attributes = resource_params
|
|
21
|
-
@resource.build_upload(image: params[:resources_upload][:url])
|
|
22
|
-
|
|
23
20
|
if @resource.save_and_index
|
|
24
21
|
flash[:notice] = t('spotlight.resources.upload.success')
|
|
25
|
-
if params['add-and-continue']
|
|
26
|
-
redirect_to new_exhibit_resource_path(@resource.exhibit, anchor: :new_resources_upload)
|
|
27
|
-
else
|
|
28
|
-
redirect_to admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
|
|
29
|
-
end
|
|
22
|
+
return redirect_to new_exhibit_resource_path(@resource.exhibit, tab: :upload) if params['add-and-continue']
|
|
30
23
|
else
|
|
31
24
|
flash[:error] = t('spotlight.resources.upload.error')
|
|
32
|
-
redirect_to admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
|
|
33
25
|
end
|
|
26
|
+
|
|
27
|
+
redirect_to admin_exhibit_catalog_path(@resource.exhibit, sort: :timestamp)
|
|
34
28
|
end
|
|
35
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
|
36
29
|
|
|
37
30
|
private
|
|
38
31
|
|
|
32
|
+
def set_tab
|
|
33
|
+
@tab = params[:tab] || 'external_resources_form'
|
|
34
|
+
end
|
|
35
|
+
|
|
39
36
|
def build_resource
|
|
40
|
-
@resource ||=
|
|
37
|
+
@resource ||= begin
|
|
38
|
+
resource = Spotlight::Resources::Upload.new exhibit: current_exhibit
|
|
39
|
+
resource.attributes = resource_params
|
|
40
|
+
resource.build_upload(image: params[:resources_upload][:url]) if params[:resources_upload][:url]
|
|
41
|
+
|
|
42
|
+
resource
|
|
43
|
+
end
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
def resource_params
|
|
@@ -45,7 +48,8 @@ module Spotlight
|
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
def data_param_keys
|
|
48
|
-
Spotlight::Resources::Upload.fields(current_exhibit).map(&:field_name) +
|
|
51
|
+
Spotlight::Resources::Upload.fields(current_exhibit).map(&:field_name) +
|
|
52
|
+
current_exhibit.custom_fields.as_strong_params
|
|
49
53
|
end
|
|
50
54
|
end
|
|
51
55
|
end
|
|
@@ -5,6 +5,7 @@ module Spotlight
|
|
|
5
5
|
# CRUD actions for exhibit resources
|
|
6
6
|
class ResourcesController < Spotlight::ApplicationController
|
|
7
7
|
before_action :authenticate_user!, except: [:show]
|
|
8
|
+
before_action :set_tab, only: [:new, :create]
|
|
8
9
|
|
|
9
10
|
load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
|
|
10
11
|
|
|
@@ -44,6 +45,10 @@ module Spotlight
|
|
|
44
45
|
|
|
45
46
|
protected
|
|
46
47
|
|
|
48
|
+
def set_tab
|
|
49
|
+
@tab = params[:tab] || 'external_resources_form'
|
|
50
|
+
end
|
|
51
|
+
|
|
47
52
|
def resource_class
|
|
48
53
|
Spotlight::Resource
|
|
49
54
|
end
|
|
@@ -4,7 +4,6 @@ module Spotlight
|
|
|
4
4
|
##
|
|
5
5
|
# CRUD actions for curating browse categories (see
|
|
6
6
|
# {Spotlight::BrowseController} for the end-user read and index actions)
|
|
7
|
-
# rubocop:disable Metrics/ClassLength
|
|
8
7
|
class SearchesController < Spotlight::ApplicationController
|
|
9
8
|
load_resource :exhibit, class: 'Spotlight::Exhibit'
|
|
10
9
|
before_action :authenticate_user!
|
|
@@ -142,5 +141,4 @@ module Spotlight
|
|
|
142
141
|
@search = current_exhibit.searches.find(params[:id]) if params[:id].present?
|
|
143
142
|
end
|
|
144
143
|
end
|
|
145
|
-
# rubocop:enable Metrics/ClassLength
|
|
146
144
|
end
|
|
@@ -36,7 +36,14 @@ module Spotlight
|
|
|
36
36
|
req = ActiveSupport::JSON.decode(json_content)
|
|
37
37
|
|
|
38
38
|
Array.wrap(req).map do |r|
|
|
39
|
-
|
|
39
|
+
custom_field_data = r.dup.extract! @exhibit.custom_fields.pluck(:slug)
|
|
40
|
+
other_field_data = r.except(custom_field_data.keys)
|
|
41
|
+
|
|
42
|
+
doc = blacklight_config.document_model.new(other_field_data)
|
|
43
|
+
|
|
44
|
+
create_or_update_solr_document_sidecar(doc, r)
|
|
45
|
+
|
|
46
|
+
doc.to_solr.merge(@exhibit.solr_data).merge(other_field_data)
|
|
40
47
|
end
|
|
41
48
|
end
|
|
42
49
|
|
|
@@ -53,5 +60,15 @@ module Spotlight
|
|
|
53
60
|
|
|
54
61
|
render plain: 'Spotlight is unable to write to solr', status: 409
|
|
55
62
|
end
|
|
63
|
+
|
|
64
|
+
def create_or_update_solr_document_sidecar(doc, data)
|
|
65
|
+
return if data.blank?
|
|
66
|
+
|
|
67
|
+
sidecar = doc.sidecar(@exhibit)
|
|
68
|
+
sidecar.data = sidecar.data.merge(data)
|
|
69
|
+
sidecar.save
|
|
70
|
+
|
|
71
|
+
sidecar
|
|
72
|
+
end
|
|
56
73
|
end
|
|
57
74
|
end
|