2022-05-12 23:05:07 +08:00
|
|
|
<template>
|
|
|
|
<div class="attachment-container asset"
|
|
|
|
:data-asset-id="attachment.id"
|
2023-08-30 21:42:55 +08:00
|
|
|
@mouseover="isHovered = true"
|
|
|
|
@mouseleave="isHovered = false"
|
2022-05-12 23:05:07 +08:00
|
|
|
>
|
2023-08-30 21:42:55 +08:00
|
|
|
<a v-if="!isHovered"
|
|
|
|
:href="attachment.attributes.urls.blob"
|
2022-05-12 23:05:07 +08:00
|
|
|
class="file-preview-link file-name"
|
|
|
|
:id="`modal_link${attachment.id}`"
|
|
|
|
data-no-turbolink="true"
|
|
|
|
:data-id="attachment.id"
|
2023-07-24 19:28:44 +08:00
|
|
|
:data-gallery-view-id="parentId"
|
2022-05-12 23:05:07 +08:00
|
|
|
:data-preview-url="attachment.attributes.urls.preview"
|
|
|
|
>
|
2022-05-13 19:07:50 +08:00
|
|
|
<div class="attachment-preview" :class= "attachment.attributes.asset_type">
|
|
|
|
<img v-if="attachment.attributes.medium_preview !== null"
|
|
|
|
:src="attachment.attributes.medium_preview"
|
|
|
|
@error="ActiveStoragePreviews.reCheckPreview"
|
|
|
|
@load="ActiveStoragePreviews.showPreview"
|
2022-05-12 23:05:07 +08:00
|
|
|
style='opacity: 0' />
|
|
|
|
<i v-else class="fas" :class="attachment.attributes.icon"></i>
|
|
|
|
</div>
|
2022-09-02 21:09:56 +08:00
|
|
|
<div class="attachment-label"
|
|
|
|
data-toggle="tooltip"
|
|
|
|
data-placement="bottom"
|
2022-08-16 18:20:37 +08:00
|
|
|
:title="`${ attachment.attributes.file_name }`">
|
2022-05-12 23:05:07 +08:00
|
|
|
{{ attachment.attributes.file_name }}
|
2022-07-15 16:13:55 +08:00
|
|
|
<span v-if="attachment.isNewUpload" class="attachment-label-new">
|
2023-08-11 20:48:20 +08:00
|
|
|
{{ i18n.t('attachments.new.description') }}
|
2022-07-15 16:13:55 +08:00
|
|
|
</span>
|
2022-05-12 23:05:07 +08:00
|
|
|
</div>
|
2023-08-30 21:42:55 +08:00
|
|
|
</a>
|
|
|
|
<div v-else class="hovered-thumbnail">
|
|
|
|
<a
|
|
|
|
:href="attachment.attributes.urls.blob"
|
|
|
|
class="file-preview-link file-name"
|
|
|
|
:id="`modal_link${attachment.id}`"
|
|
|
|
data-no-turbolink="true"
|
|
|
|
:data-id="attachment.id"
|
|
|
|
:data-gallery-view-id="parentId"
|
|
|
|
:data-preview-url="attachment.attributes.urls.preview"
|
|
|
|
>
|
|
|
|
{{ attachment.attributes.file_name }}
|
|
|
|
</a>
|
|
|
|
<div class="absolute bottom-14 text-sn-grey">
|
2022-05-13 19:07:50 +08:00
|
|
|
{{ attachment.attributes.file_size_formatted }}
|
2022-05-12 23:05:07 +08:00
|
|
|
</div>
|
2023-08-30 21:42:55 +08:00
|
|
|
<div class="absolute bottom-2 min-w-[194px] justify-between flex">
|
|
|
|
<a class="btn btn-light icon-btn thumbnail-action-btn image-edit-button"
|
|
|
|
:title="i18n.t('attachments.thumbnail.buttons.edit')"
|
|
|
|
:data-image-id="attachment.id"
|
|
|
|
:data-image-name="attachment.attributes.file_name"
|
|
|
|
:data-image-url="attachment.attributes.urls.asset_file"
|
|
|
|
:data-image-quality="attachment.attributes.image_context.quality"
|
|
|
|
:data-image-mime-type="attachment.attributes.image_context.type"
|
|
|
|
:data-image-start-edit-url="attachment.attributes.urls.start_edit_image"
|
|
|
|
>
|
|
|
|
<i class="sn-icon sn-icon-edit"></i>
|
|
|
|
</a>
|
|
|
|
<a class="btn btn-light icon-btn thumbnail-action-btn" :title="i18n.t('attachments.thumbnail.buttons.move')">
|
|
|
|
<!-- TODO -->
|
|
|
|
<i class="sn-icon sn-icon-move"></i>
|
|
|
|
</a>
|
|
|
|
<a class="btn btn-light icon-btn thumbnail-action-btn"
|
|
|
|
:title="i18n.t('attachments.thumbnail.buttons.download')"
|
|
|
|
:href="attachment.attributes.urls.download" data-turbolinks="false">
|
|
|
|
<i class="sn-icon sn-icon-export"></i>
|
|
|
|
</a>
|
|
|
|
<template v-if="attachment.attributes.urls.delete">
|
|
|
|
<a class="btn btn-light icon-btn thumbnail-action-btn"
|
|
|
|
:title="i18n.t('attachments.thumbnail.buttons.delete')"
|
|
|
|
@click.prevent.stop="deleteModal = true">
|
|
|
|
<i class="sn-icon sn-icon-delete"></i>
|
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-17 16:39:17 +08:00
|
|
|
<ContextMenu
|
|
|
|
:attachment="attachment"
|
|
|
|
@attachment:viewMode="updateViewMode"
|
|
|
|
@attachment:delete="deleteAttachment"
|
|
|
|
/>
|
2023-08-30 21:42:55 +08:00
|
|
|
<deleteAttachmentModal
|
|
|
|
v-if="deleteModal"
|
|
|
|
:fileName="attachment.attributes.file_name"
|
|
|
|
@confirm="deleteAttachment"
|
|
|
|
@cancel="deleteModal = false"
|
|
|
|
/>
|
2022-05-12 23:05:07 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-05-17 16:39:17 +08:00
|
|
|
import ContextMenuMixin from './mixins/context_menu.js'
|
|
|
|
import ContextMenu from './context_menu.vue'
|
2023-08-30 21:42:55 +08:00
|
|
|
import deleteAttachmentModal from './delete_modal.vue'
|
|
|
|
|
2022-05-12 23:05:07 +08:00
|
|
|
export default {
|
|
|
|
name: 'thumbnailAttachment',
|
2022-05-17 16:39:17 +08:00
|
|
|
mixins: [ContextMenuMixin],
|
2023-08-30 21:42:55 +08:00
|
|
|
components: { ContextMenu, deleteAttachmentModal },
|
2022-05-12 23:05:07 +08:00
|
|
|
props: {
|
|
|
|
attachment: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
|
|
|
},
|
2023-07-24 19:28:44 +08:00
|
|
|
parentId: {
|
2022-05-12 23:05:07 +08:00
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
}
|
2023-08-30 21:42:55 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isHovered: false,
|
|
|
|
deleteModal: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
deleteAttachment() {
|
|
|
|
this.deleteModal = false;
|
|
|
|
this.$emit('attachment:delete');
|
|
|
|
}
|
2022-05-13 19:07:50 +08:00
|
|
|
}
|
2022-05-12 23:05:07 +08:00
|
|
|
}
|
|
|
|
</script>
|