mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-06 15:40:31 +08:00
changed controller action & javascript
This commit is contained in:
parent
1a6578b460
commit
face69e960
3 changed files with 3 additions and 20 deletions
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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}",
|
||||
|
|
Loading…
Reference in a new issue