changed controller action & javascript

This commit is contained in:
Giga Chubinidze 2023-10-09 15:15:54 +04:00
parent 1a6578b460
commit face69e960
3 changed files with 3 additions and 20 deletions

View file

@ -36,19 +36,8 @@ class AssetsController < ApplicationController
def toggle_view_mode
@asset.view_mode = toggle_view_mode_params[:view_mode]
@asset.save!(touch: false)
gallery_view_id = if @assoc.is_a?(Step)
@assoc.id
elsif @assoc.is_a?(Result)
@assoc.my_module.id
end
render json: {
html: render_to_string(
partial: 'assets/asset', locals: {
asset: @asset,
gallery_view_id: gallery_view_id
}
)
}
render json: AssetSerializer.new(@asset, scope: { user: current_user }).as_json
end
def load_asset

View file

@ -139,12 +139,6 @@
type: 'PATCH',
dataType: 'json',
data: { asset: { view_mode: viewMode } }
}).done(data => {
this.$nextTick(function() {
$(`.asset[data-asset-id=${this.attachment.id}] img`)
.replaceWith($(data.html).find(`.asset[data-asset-id=${this.attachment.id}] img`));
ActiveStoragePreviews.reloadPreview(`.asset[data-asset-id=${this.attachment.id}] img`);
})
});
},
deleteAttachment() {

View file

@ -4,7 +4,7 @@
data-asset-updated-at="<%= asset.updated_at.to_i %>"
data-asset-order="1"
>
<%= image_tag asset.medium_preview || rails_blob_path(asset.file, disposition: 'attachment') %>
<%= file_extension_icon_html(asset) %>
<%= link_to rails_blob_path(asset.file, disposition: 'attachment'),
class: "file-preview-link file-name",
id: "modal_link#{asset.id}",