Skip to content

Commit

Permalink
removing form-prefix where not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
hudajkhan committed Dec 18, 2024
1 parent 7c16423 commit c0aa0c6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions app/javascript/spotlight/admin/crop.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default class Crop {
// Exhibit and masthead cropping preserves aspect ratio, while item
// and other widget related cropping does not preserve aspect ratio in the cropping area.
this.preserveAspectRatio = preserveAspectRatio;
this.formPrefix = this.cropTool.data('form-prefix');
// Get the IIIF input elements used to store/reference IIIF information
this.inputPrefix = this.cropTool.data('input-prefix');
this.iiifUrlField = this.iiifInputElement(this.inputPrefix, 'iiif_tilesource', this.cropTool);
Expand Down Expand Up @@ -301,7 +300,11 @@ export default class Crop {
}

setUploadId(id) {
$('#' + this.formPrefix + "_upload_id").val(id);
// This input is currently used for exhibit masthead or thumbnail image upload.
// The name should be sufficient in this case, as we don't use this part of the
// code for solr document widgets where we enable cropping.
// If we require more specificity, we can scope this to this.cropTool.
$('input[name="' + this.inputPrefix + '[upload_id]"]').val(id);
}

aspectRatioPreservingRectangleEditor(aspect) {
Expand Down
2 changes: 1 addition & 1 deletion app/views/spotlight/contacts/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% end %>

<%= f.fields_for :avatar, (@contact.avatar || @contact.build_avatar) do |af| %>
<div data-cropper="<%= af.object.model_name.singular_route_key %>" data-form-prefix="<%= form_prefix(af) %>">
<div data-cropper="<%= af.object.model_name.singular_route_key %>" data-input-prefix="<%= input_prefix(af) %>">
<%= field_set_tag(t(:'.avatar.header')) do %>
<p class="instructions"><%= t(:'featured_images.form.crop_area.help_html', scope: [:spotlight], thing: 'contact photo') %></p>

Expand Down
2 changes: 1 addition & 1 deletion app/views/spotlight/featured_images/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div data-cropper="<%= f.object.model_name.singular_route_key %>" data-form-prefix="<%= form_prefix(f) %>" data-input-prefix="<%= input_prefix(f) %>">
<div data-cropper="<%= f.object.model_name.singular_route_key %>" data-input-prefix="<%= input_prefix(f) %>">
<%= field_set_tag do %>
<%= f.check_box(:display, layout: :vertical) %>
<% end if f.object.is_a? Spotlight::Masthead %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/spotlight/featured_images/_upload_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div data-cropper="<%= f.object.model_name.singular_route_key %>" data-form-prefix="<%= form_prefix(f) %>">
<div data-cropper="<%= f.object.model_name.singular_route_key %>" data-input-prefix="<%= input_prefix(f) %>">
<%= field_set_tag do %>
<%= f.check_box(:display, layout: :vertical) %>
<% end if f.object.is_a? Spotlight::Masthead %>
Expand Down
4 changes: 4 additions & 0 deletions spec/features/javascript/blocks/solr_documents_block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
fill_in_solr_document_block_typeahead_field with: 'dq287tq6352'

# Flappy guard. Wait for the thumbnail src to be populated.
expect(page).to have_selector('li[data-resource-id="dq287tq6352"]')
expect(page).to have_selector('.img-thumbnail')

puts page.body
expect(page).to have_selector('li[data-resource-id="dq287tq6352"] .img-thumbnail[src^="http"]')

within(:css, '.card') do
Expand Down
2 changes: 2 additions & 0 deletions spec/support/features/test_features_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def add_widget(type)

def click_add_widget
if all('.st-block-replacer').blank?
puts "CLICK ADD WIDGET"
puts page.body
expect(page).to have_css('.st-block-addition')
first('.st-block-addition').click
end
Expand Down

0 comments on commit c0aa0c6

Please sign in to comment.