blacklight-spotlight 5.2.1 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/javascripts/spotlight/spotlight.esm.js +34 -13
  4. data/app/assets/javascripts/spotlight/spotlight.esm.js.map +1 -1
  5. data/app/assets/javascripts/spotlight/spotlight.js +34 -13
  6. data/app/assets/javascripts/spotlight/spotlight.js.map +1 -1
  7. data/app/assets/stylesheets/spotlight/_multi_up_item_grid.scss +0 -30
  8. data/app/controllers/spotlight/exhibits_controller.rb +5 -1
  9. data/app/controllers/spotlight/featured_images_controller.rb +6 -0
  10. data/app/helpers/spotlight/crop_helper.rb +1 -0
  11. data/app/javascript/spotlight/admin/blocks/search_result_block.js +0 -2
  12. data/app/javascript/spotlight/admin/blocks/solr_documents_block.js +0 -2
  13. data/app/javascript/spotlight/admin/blocks/solr_documents_carousel_block.js +0 -2
  14. data/app/javascript/spotlight/admin/blocks/solr_documents_embed_block.js +0 -2
  15. data/app/javascript/spotlight/admin/blocks/solr_documents_features_block.js +0 -2
  16. data/app/javascript/spotlight/admin/blocks/solr_documents_grid_block.js +0 -2
  17. data/app/javascript/spotlight/admin/crop.js +34 -1
  18. data/app/javascript/spotlight/controllers/clipboard_controller.js~ +6 -0
  19. data/app/models/spotlight/exhibit.rb +1 -1
  20. data/app/services/spotlight/clone_translated_page_from_locale.rb +1 -1
  21. data/config/locales/spotlight.en.yml +8 -0
  22. data/lib/spotlight/engine.rb +0 -2
  23. data/lib/spotlight/version.rb +1 -1
  24. data/spec/support/features/test_features_helpers.rb +3 -2
  25. metadata +7 -8
  26. data/app/assets/config/spotlight/manifest.js +0 -3
  27. data/app/assets/javascripts/spotlight/application.js +0 -7
@@ -1,33 +1,3 @@
1
- .item-grid-admin {
2
- .field {
3
- input[type='text'] {
4
- width: 89%;
5
- }
6
-
7
- .twitter-typeahead {
8
- margin-bottom: 2*$spacer;
9
- }
10
- }
11
- .field-select {
12
- margin-top: 2*$spacer;
13
- select {
14
- display: inline;
15
- width: auto;
16
- }
17
- }
18
- .dd3-item {
19
- margin-bottom: 2*$spacer;
20
- }
21
- }
22
- // Hide the secondary caption field
23
- // for the Features block so we can
24
- // re-use the rest from the generic
25
- // multi-up item grid.
26
- [data-type='item-features'] {
27
- .secondary-caption {
28
- display: none;
29
- }
30
- }
31
1
  .spotlight-flexbox {
32
2
  display: -webkit-box;
33
3
  display: -moz-box;
@@ -54,6 +54,7 @@ module Spotlight
54
54
  build_initial_exhibit_contact_emails
55
55
  end
56
56
 
57
+ # rubocop:disable Metrics/AbcSize
57
58
  def create
58
59
  @exhibit.attributes = exhibit_params
59
60
 
@@ -61,9 +62,12 @@ module Spotlight
61
62
  @exhibit.roles.create user: current_user, role: 'admin' if current_user
62
63
  redirect_to spotlight.exhibit_dashboard_path(@exhibit), notice: t(:'helpers.submit.exhibit.created', model: @exhibit.class.model_name.human.downcase)
63
64
  else
64
- render action: :new
65
+ flash.now[:alert] = t('spotlight.exhibits.new_exhibit_form.errors.slug_taken') if @exhibit.errors[:slug].present?
66
+
67
+ render :new, status: :unprocessable_entity
65
68
  end
66
69
  end
70
+ # rubocop:enable Metrics/AbcSize
67
71
 
68
72
  def update
69
73
  if @exhibit.update(exhibit_params)
@@ -5,6 +5,8 @@ module Spotlight
5
5
  class FeaturedImagesController < Spotlight::ApplicationController
6
6
  load_and_authorize_resource instance_name: :featured_image, class: 'Spotlight::TemporaryImage'
7
7
 
8
+ rescue_from CarrierWave::UploadError, with: :handle_upload_error
9
+
8
10
  def create
9
11
  if @featured_image.save && @featured_image.file_present?
10
12
  render json: { tilesource:, id: @featured_image.id }
@@ -15,6 +17,10 @@ module Spotlight
15
17
 
16
18
  private
17
19
 
20
+ def handle_upload_error(exception)
21
+ render json: { error: [exception.message] }, status: :unprocessable_entity
22
+ end
23
+
18
24
  def tilesource
19
25
  Spotlight::Engine.config.iiif_service.info_url(@featured_image, request.host)
20
26
  end
@@ -27,6 +27,7 @@ module Spotlight
27
27
  def iiif_upload_tag(f)
28
28
  content_tag(:div) do
29
29
  concat f.file_field_without_bootstrap :file, name: 'featured_image[image]', data: { endpoint: polymorphic_path(f.object.model_name.route_key) }
30
+ concat content_tag(:div, '', class: 'featured-image invalid-feedback')
30
31
  concat f.hidden_field :upload_id
31
32
  end
32
33
  end
@@ -1,5 +1,3 @@
1
- //= require spotlight/admin/blocks/browse_block
2
-
3
1
  SirTrevor.Blocks.SearchResults = (function(){
4
2
 
5
3
  return SirTrevor.Blocks.Browse.extend({
@@ -1,5 +1,3 @@
1
- //= require spotlight/admin/blocks/solr_documents_base_block
2
-
3
1
  SirTrevor.Blocks.SolrDocuments = (function(){
4
2
 
5
3
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -1,5 +1,3 @@
1
- //= require spotlight/admin/blocks/solr_documents_base_block
2
-
3
1
  SirTrevor.Blocks.SolrDocumentsCarousel = (function(){
4
2
 
5
3
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -1,5 +1,3 @@
1
- //= require spotlight/admin/blocks/solr_documents_base_block
2
-
3
1
  SirTrevor.Blocks.SolrDocumentsEmbed = (function(){
4
2
 
5
3
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -1,5 +1,3 @@
1
- //= require spotlight/admin/blocks/solr_documents_base_block
2
-
3
1
  SirTrevor.Blocks.SolrDocumentsFeatures = (function(){
4
2
 
5
3
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -1,5 +1,3 @@
1
- //= require spotlight/admin/blocks/solr_documents_base_block
2
-
3
1
  SirTrevor.Blocks.SolrDocumentsGrid = (function(){
4
2
 
5
3
  return SirTrevor.Blocks.SolrDocumentsBase.extend({
@@ -285,7 +285,7 @@ export default class Crop {
285
285
  url: url, //Server script to process data
286
286
  type: 'POST',
287
287
  success: (data, stat, xhr) => this.successHandler(data, stat, xhr),
288
- // error: errorHandler,
288
+ error: (xhr, stat, error) => this.errorHandler(xhr, stat, error),
289
289
  // Form data
290
290
  data: this.getData(),
291
291
  headers: {
@@ -301,6 +301,39 @@ export default class Crop {
301
301
  successHandler(data, stat, xhr) {
302
302
  this.setIiifFields({ tilesource: data.tilesource });
303
303
  this.setUploadId(data.id);
304
+ this.clearUploadErrors()
305
+ }
306
+
307
+ errorHandler(xhr, stat, error) {
308
+ let errorMessage = "Upload failed"
309
+ if (xhr.responseJSON) {
310
+ if (xhr.responseJSON.errors) {
311
+ errorMessage = xhr.responseJSON.errors.join(', ')
312
+ } else if (xhr.responseJSON.error) {
313
+ errorMessage = xhr.responseJSON.error
314
+ }
315
+ }
316
+ this.showUploadError(errorMessage)
317
+ }
318
+
319
+ getUploadErrorsElement() {
320
+ return this.cropTool.find(".featured-image.invalid-feedback")
321
+ }
322
+
323
+ showUploadError(errorMessage) {
324
+ const errorsElement = this.getUploadErrorsElement()
325
+ if (errorsElement) {
326
+ errorsElement.text(errorMessage).show()
327
+ } else {
328
+ console.error("uploadFile", error, errorMessage)
329
+ }
330
+ }
331
+
332
+ clearUploadErrors() {
333
+ const errorsElement = this.getUploadErrorsElement()
334
+ if (errorsElement) {
335
+ errorsElement.text("").hide()
336
+ }
304
337
  }
305
338
 
306
339
  setUploadId(id) {
@@ -0,0 +1,6 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ // Connects to data-controller="clipboard"
4
+ export default class extends Controller {
5
+
6
+ }
@@ -28,7 +28,7 @@ module Spotlight
28
28
  end
29
29
 
30
30
  validates :title, presence: true, if: -> { I18n.locale == I18n.default_locale }
31
- validates :slug, uniqueness: true
31
+ validates :slug, uniqueness: { message: I18n.t('spotlight.exhibits.new_exhibit_form.errors.slug_taken') }
32
32
  validates :theme, inclusion: { in: Spotlight::Engine.config.exhibit_themes }, allow_blank: true
33
33
 
34
34
  after_validation :move_friendly_id_error_to_slug
@@ -24,7 +24,7 @@ module Spotlight
24
24
  private
25
25
 
26
26
  def destroy
27
- page.translated_page_for(locale).destroy if page.translated_page_for(locale).present?
27
+ page.translated_page_for(locale).presence&.destroy
28
28
  end
29
29
  end
30
30
  end
@@ -23,6 +23,12 @@ en:
23
23
  spotlight/page:
24
24
  display_sidebar?: Show sidebar
25
25
  display_title: Show title
26
+ errors:
27
+ models:
28
+ spotlight/exhibit:
29
+ attributes:
30
+ slug:
31
+ taken: Slug is already taken.
26
32
  help:
27
33
  spotlight/exhibit:
28
34
  tag_list: Enter tags separated by commas.
@@ -616,6 +622,8 @@ en:
616
622
  new:
617
623
  page_title: Create a new exhibit
618
624
  new_exhibit_form:
625
+ errors:
626
+ slug_taken: Slug is already taken. Please choose another.
619
627
  fields:
620
628
  slug:
621
629
  help_block: A hyphenated name to be displayed in the URL for the exhibit (e.g., "maps-of-africa").
@@ -28,8 +28,6 @@ module Spotlight
28
28
  require 'redcarpet' # required for markdown support
29
29
  require 'openseadragon'
30
30
 
31
- config.assets.precompile += %w[spotlight/fallback/*.png] if defined?(Sprockets)
32
-
33
31
  config.autoload_paths += %W[
34
32
  #{config.root}/app/builders
35
33
  #{config.root}/app/controllers/concerns
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spotlight
4
- VERSION = '5.2.1'
4
+ VERSION = '5.2.2'
5
5
  end
@@ -6,8 +6,9 @@ module Spotlight
6
6
  type = opts[:type] || 'default'
7
7
 
8
8
  # Role=combobox indicates that the auto-complete is initialized
9
- expect(page).to have_css("auto-complete [data-#{type}-typeahead][role='combobox']")
10
- find("auto-complete [data-#{type}-typeahead]").fill_in(with: opts[:with])
9
+ find("auto-complete [data-#{type}-typeahead][role='combobox']").fill_in(with: opts[:with])
10
+ # Wait for the autocomplete to show both 'open' and 'aria-expanded="true"' or the results might be stale
11
+ expect(page).to have_css("auto-complete[open] [data-#{type}-typeahead][role='combobox'][aria-expanded='true']")
11
12
  first('auto-complete[open] [role="option"]', text: opts[:with]).click
12
13
  end
13
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-spotlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: '5.0'
36
36
  - - "<"
37
37
  - !ruby/object:Gem::Version
38
- version: '13'
38
+ version: '14'
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: '5.0'
46
46
  - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: '13'
48
+ version: '14'
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: blacklight
51
51
  requirement: !ruby/object:Gem::Requirement
@@ -385,7 +385,7 @@ dependencies:
385
385
  version: '11.0'
386
386
  - - "<"
387
387
  - !ruby/object:Gem::Version
388
- version: '17'
388
+ version: '18'
389
389
  type: :runtime
390
390
  prerelease: false
391
391
  version_requirements: !ruby/object:Gem::Requirement
@@ -395,7 +395,7 @@ dependencies:
395
395
  version: '11.0'
396
396
  - - "<"
397
397
  - !ruby/object:Gem::Version
398
- version: '17'
398
+ version: '18'
399
399
  - !ruby/object:Gem::Dependency
400
400
  name: rails
401
401
  requirement: !ruby/object:Gem::Requirement
@@ -801,12 +801,10 @@ files:
801
801
  - LICENSE
802
802
  - README.md
803
803
  - Rakefile
804
- - app/assets/config/spotlight/manifest.js
805
804
  - app/assets/images/spotlight/blocks/sir-trevor-icons.svg
806
805
  - app/assets/images/spotlight/default_browse_thumbnail.jpg
807
806
  - app/assets/images/spotlight/default_thumbnail.jpg
808
807
  - app/assets/images/spotlight/fallback/default.png
809
- - app/assets/javascripts/spotlight/application.js
810
808
  - app/assets/javascripts/spotlight/spotlight.esm.js
811
809
  - app/assets/javascripts/spotlight/spotlight.esm.js.map
812
810
  - app/assets/javascripts/spotlight/spotlight.js
@@ -1023,6 +1021,7 @@ files:
1023
1021
  - app/javascript/spotlight/admin/translation_progress.js
1024
1022
  - app/javascript/spotlight/admin/users.js
1025
1023
  - app/javascript/spotlight/admin/visibility_toggle.js
1024
+ - app/javascript/spotlight/controllers/clipboard_controller.js~
1026
1025
  - app/javascript/spotlight/controllers/index.js
1027
1026
  - app/javascript/spotlight/controllers/tag_selector_controller.js
1028
1027
  - app/javascript/spotlight/core.js
@@ -1562,7 +1561,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1562
1561
  - !ruby/object:Gem::Version
1563
1562
  version: '0'
1564
1563
  requirements: []
1565
- rubygems_version: 3.6.9
1564
+ rubygems_version: 3.6.7
1566
1565
  specification_version: 4
1567
1566
  summary: Enable librarians, curators, and others who are responsible for digital collections
1568
1567
  to create attractive, feature-rich websites that feature these collections.
@@ -1,3 +0,0 @@
1
- //= link_tree ../../images
2
- //= link_tree ../../../javascript .js
3
- //= link_tree ../../../../vendor/assets/javascripts .js
@@ -1,7 +0,0 @@
1
- // This is the sprockets entrypoint.
2
- //= require leaflet
3
- //= require sir-trevor
4
- //= require clipboard
5
- //= require tiny-slider
6
-
7
- //= require spotlight/spotlight