mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Add file preview to list view
This commit is contained in:
parent
d99e279ecc
commit
131d487e69
5 changed files with 23 additions and 6 deletions
|
@ -11,7 +11,7 @@ var FilePreviewModal = (function() {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
params.gallery = $(`.file-preview-link[data-gallery-view-id=${galleryViewId}]`)
|
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);
|
.map(i => i.dataset.id);
|
||||||
$.get($(this).data('preview-url'), params, function(result) {
|
$.get($(this).data('preview-url'), params, function(result) {
|
||||||
$('#filePreviewModal .modal-content').html(result.html);
|
$('#filePreviewModal .modal-content').html(result.html);
|
||||||
|
|
|
@ -381,8 +381,8 @@ var ImageEditorModal = (function() {
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
$(`.step-asset[data-asset-id=${data.id}]`).replaceWith(res.html);
|
$(`.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}]`).closest('.attachments').trigger('reorder');
|
||||||
closeEditor();
|
closeEditor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,7 +34,14 @@ class AssetsController < ApplicationController
|
||||||
def toggle_view_mode
|
def toggle_view_mode
|
||||||
@asset.view_mode = toggle_view_mode_params[:view_mode]
|
@asset.view_mode = toggle_view_mode_params[:view_mode]
|
||||||
if @asset.save(touch: false)
|
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|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
render json: { html: html }, status: :ok
|
render json: { html: html }, status: :ok
|
||||||
|
|
|
@ -9,7 +9,12 @@
|
||||||
<%= link_to rails_blob_path(asset.file, disposition: 'attachment'),
|
<%= link_to rails_blob_path(asset.file, disposition: 'attachment'),
|
||||||
class: "file-preview-link file-name",
|
class: "file-preview-link file-name",
|
||||||
id: "modal_link#{asset.id}",
|
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 %>
|
<%= asset.file_name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="file-metadata">
|
<div class="file-metadata">
|
||||||
|
|
|
@ -10,7 +10,12 @@
|
||||||
<%= link_to rails_blob_path(asset.file, disposition: 'attachment'),
|
<%= link_to rails_blob_path(asset.file, disposition: 'attachment'),
|
||||||
class: "file-preview-link file-name",
|
class: "file-preview-link file-name",
|
||||||
id: "modal_link#{asset.id}",
|
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 %>
|
<%= asset.file_name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="file-metadata">
|
<div class="file-metadata">
|
||||||
|
|
Loading…
Reference in a new issue