mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-09 16:01:30 +08:00
Merge pull request #6235 from wandji20/wb-SCI-8914
Fix issue previweing and realoding assets on hover and after viewmode change [SCI-8914]
This commit is contained in:
commit
50a87b1562
6 changed files with 46 additions and 21 deletions
|
|
@ -32,8 +32,8 @@ var ActiveStoragePreviews = (function() {
|
||||||
},
|
},
|
||||||
reloadPreview: function(target) {
|
reloadPreview: function(target) {
|
||||||
$(target)
|
$(target)
|
||||||
.one('error', (event) => this.reCheckPreview(event))
|
.on('error', event => this.reCheckPreview(event))
|
||||||
.one('load', (event) => this.showPreview(event))
|
.on('load', event => this.showPreview(event))
|
||||||
.trigger('error');
|
.trigger('error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -365,13 +365,10 @@ var ImageEditorModal = (function() {
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
$(`.asset[data-asset-id=${data.id}] .image-container img`)
|
$(`.asset[data-asset-id=${data.id}] img`)
|
||||||
.replaceWith($(res.html).find('.image-container img'));
|
.replaceWith($(res.html).find(`.asset[data-asset-id=${data.id}] img`));
|
||||||
$(`.asset[data-asset-id=${data.id}] .attachment-preview img`)
|
ActiveStoragePreviews.reloadPreview(`.asset[data-asset-id=${data.id}] img`);
|
||||||
.replaceWith($(res.html).find('.attachment-preview img'));
|
|
||||||
$(`.asset[data-asset-id=${data.id}]`).closest('.attachments').trigger('reorder');
|
$(`.asset[data-asset-id=${data.id}]`).closest('.attachments').trigger('reorder');
|
||||||
ActiveStoragePreviews.reloadPreview(`.asset[data-asset-id=${data.id}] .attachment-preview img,
|
|
||||||
.asset[data-asset-id=${data.id}] .image-container img`);
|
|
||||||
closeEditor();
|
closeEditor();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,12 @@
|
||||||
type: 'PATCH',
|
type: 'PATCH',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: { asset: { view_mode: viewMode } }
|
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() {
|
deleteAttachment() {
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,6 @@
|
||||||
<template v-else-if="attachment.attributes.large_preview !== null">
|
<template v-else-if="attachment.attributes.large_preview !== null">
|
||||||
<div class="image-container">
|
<div class="image-container">
|
||||||
<img :src="attachment.attributes.large_preview"
|
<img :src="attachment.attributes.large_preview"
|
||||||
@error="ActiveStoragePreviews.reCheckPreview"
|
|
||||||
@load="ActiveStoragePreviews.showPreview"
|
|
||||||
style='opacity: 0' />
|
style='opacity: 0' />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -98,6 +96,11 @@
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.showWopi = this.attachment.attributes.file_size > 0;
|
this.showWopi = this.attachment.attributes.file_size > 0;
|
||||||
|
$(this.$nextTick(function() {
|
||||||
|
$(`.image-container img`)
|
||||||
|
.on('error', (event) => ActiveStoragePreviews.reCheckPreview(event))
|
||||||
|
.on('load', (event) => ActiveStoragePreviews.showPreview(event))
|
||||||
|
}))
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
reloadAsset() {
|
reloadAsset() {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
@mouseover="isHovered = true"
|
@mouseover="isHovered = true"
|
||||||
@mouseleave="isHovered = false"
|
@mouseleave="isHovered = false"
|
||||||
>
|
>
|
||||||
<a v-if="!isHovered"
|
<a :class="{ hidden: isHovered }"
|
||||||
:href="attachment.attributes.urls.blob"
|
:href="attachment.attributes.urls.blob"
|
||||||
class="file-preview-link file-name"
|
class="file-preview-link file-name"
|
||||||
:id="`modal_link${attachment.id}`"
|
:id="`modal_link${attachment.id}`"
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
<img v-if="attachment.attributes.medium_preview !== null"
|
<img v-if="attachment.attributes.medium_preview !== null"
|
||||||
class="rounded-sm"
|
class="rounded-sm"
|
||||||
:src="attachment.attributes.medium_preview"
|
:src="attachment.attributes.medium_preview"
|
||||||
@error="ActiveStoragePreviews.reCheckPreview"
|
|
||||||
@load="ActiveStoragePreviews.showPreview"
|
|
||||||
style='opacity: 0' />
|
style='opacity: 0' />
|
||||||
<div v-else class="w-[186px] h-[186px] bg-sn-super-light-grey rounded-sm"></div>
|
<div v-else class="w-[186px] h-[186px] bg-sn-super-light-grey rounded-sm"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -32,7 +30,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div v-else class="hovered-thumbnail h-full">
|
<div :class="{ hidden: !isHovered }" class="hovered-thumbnail h-full">
|
||||||
<a
|
<a
|
||||||
:href="attachment.attributes.urls.blob"
|
:href="attachment.attributes.urls.blob"
|
||||||
class="file-preview-link file-name"
|
class="file-preview-link file-name"
|
||||||
|
|
@ -126,6 +124,25 @@
|
||||||
isHovered: false,
|
isHovered: false,
|
||||||
deleteModal: false
|
deleteModal: false
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
$(this.$nextTick(function() {
|
||||||
|
$(`.attachment-preview img`)
|
||||||
|
.on('error', (event) => ActiveStoragePreviews.reCheckPreview(event))
|
||||||
|
.on('load', (event) => ActiveStoragePreviews.showPreview(event))
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isHovered: function(newValue) {
|
||||||
|
// reload thumbnail on mouse out
|
||||||
|
if(newValue) return;
|
||||||
|
|
||||||
|
$(this.$nextTick(function() {
|
||||||
|
$(`.attachment-preview img`)
|
||||||
|
.on('error', (event) => ActiveStoragePreviews.reCheckPreview(event))
|
||||||
|
.on('load', (event) => ActiveStoragePreviews.showPreview(event))
|
||||||
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,12 @@ partial_locals = {
|
||||||
editable: editable
|
editable: editable
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
<% if asset.inline? %>
|
<div>
|
||||||
<%= render partial: 'assets/asset_inline', locals: partial_locals %>
|
<% if asset.inline? %>
|
||||||
<% elsif asset.list? %>
|
<%= render partial: 'assets/asset_inline', locals: partial_locals %>
|
||||||
<%= render partial: 'assets/asset_list', locals: partial_locals %>
|
<% elsif asset.list? %>
|
||||||
<% else %>
|
<%= render partial: 'assets/asset_list', locals: partial_locals %>
|
||||||
<%= render partial: 'assets/asset_thumbnail', locals: partial_locals %>
|
<% else %>
|
||||||
<% end %>
|
<%= render partial: 'assets/asset_thumbnail', locals: partial_locals %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue