diff --git a/app/assets/javascripts/sitewide/file_preview.js b/app/assets/javascripts/sitewide/file_preview.js index 20280be98..715bcb6d0 100644 --- a/app/assets/javascripts/sitewide/file_preview.js +++ b/app/assets/javascripts/sitewide/file_preview.js @@ -11,7 +11,7 @@ var FilePreviewModal = (function() { e.preventDefault(); e.stopPropagation(); params.gallery = $(`.file-preview-link[data-gallery-view-id=${galleryViewId}]`) - .toArray().sort((a, b) => $(a).closest('.step-asset').css('order') - $(b).closest('.step-asset').css('order')) + .toArray().sort((a, b) => $(a).closest('.asset').css('order') - $(b).closest('.asset').css('order')) .map(i => i.dataset.id); $.get($(this).data('preview-url'), params, function(result) { $('#filePreviewModal .modal-content').html(result.html); diff --git a/app/assets/javascripts/sitewide/image_editor.js b/app/assets/javascripts/sitewide/image_editor.js index 3be16555e..209b73844 100644 --- a/app/assets/javascripts/sitewide/image_editor.js +++ b/app/assets/javascripts/sitewide/image_editor.js @@ -381,8 +381,8 @@ var ImageEditorModal = (function() { contentType: false, processData: false, success: function(res) { - $(`.step-asset[data-asset-id=${data.id}]`).replaceWith(res.html); - $(`.step-asset[data-asset-id=${data.id}]`).closest('.attachments').trigger('reorder'); + $(`.asset[data-asset-id=${data.id}]`).replaceWith(res.html); + $(`.asset[data-asset-id=${data.id}]`).closest('.attachments').trigger('reorder'); closeEditor(); } }); diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index cc34c19f0..15a65ca60 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -34,7 +34,14 @@ class AssetsController < ApplicationController def toggle_view_mode @asset.view_mode = toggle_view_mode_params[:view_mode] if @asset.save(touch: false) - html = render_to_string(partial: 'assets/asset.html.erb', locals: { asset: @asset }) + if @assoc.class == Step + gallery_view_id = @assoc.id + end + + html = render_to_string(partial: 'assets/asset.html.erb', locals: { + asset: @asset, + gallery_view_id: gallery_view_id + }) respond_to do |format| format.json do render json: { html: html }, status: :ok diff --git a/app/views/assets/_asset_inline.html.erb b/app/views/assets/_asset_inline.html.erb index 35415b5a2..9db49bb4f 100644 --- a/app/views/assets/_asset_inline.html.erb +++ b/app/views/assets/_asset_inline.html.erb @@ -9,7 +9,12 @@ <%= link_to rails_blob_path(asset.file, disposition: 'attachment'), class: "file-preview-link file-name", id: "modal_link#{asset.id}", - data: { no_turbolink: true, id: true, 'preview-url': asset_file_preview_path(asset)} do %> + data: { + no_turbolink: true, + id: asset.id, + gallery_view_id: gallery_view_id, + preview_url: asset_file_preview_path(asset) + } do %> <%= asset.file_name %> <% end %>
diff --git a/app/views/assets/_asset_list.html.erb b/app/views/assets/_asset_list.html.erb index ab9349d23..d27d8c76e 100644 --- a/app/views/assets/_asset_list.html.erb +++ b/app/views/assets/_asset_list.html.erb @@ -10,7 +10,12 @@ <%= link_to rails_blob_path(asset.file, disposition: 'attachment'), class: "file-preview-link file-name", id: "modal_link#{asset.id}", - data: { no_turbolink: true, id: true, 'preview-url': asset_file_preview_path(asset)} do %> + data: { + no_turbolink: true, + id: asset.id, + gallery_view_id: gallery_view_id, + preview_url: asset_file_preview_path(asset) + } do %> <%= asset.file_name %> <% end %>