2022-05-12 23:05:07 +08:00
|
|
|
<template>
|
|
|
|
<div class="list-attachment-container asset"
|
|
|
|
:data-asset-id="attachment.id"
|
2024-06-07 18:05:31 +08:00
|
|
|
:data-e2e="`e2e-CO-${dataE2e}-attachment${attachment.id}-list`"
|
2022-05-12 23:05:07 +08:00
|
|
|
>
|
2023-09-14 18:12:15 +08:00
|
|
|
<i class="text-sn-grey asset-icon sn-icon" :class="attachment.attributes.icon"></i>
|
2022-05-12 23:05:07 +08:00
|
|
|
<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"
|
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"
|
|
|
|
>
|
2023-08-22 09:55:20 +08:00
|
|
|
<span class="attachment-name" data-toggle="tooltip"
|
|
|
|
data-placement="bottom">
|
2022-08-16 18:20:37 +08:00
|
|
|
{{ attachment.attributes.file_name }}
|
|
|
|
</span>
|
2022-05-12 23:05:07 +08:00
|
|
|
</a>
|
2023-12-18 20:50:56 +08:00
|
|
|
<div v-if="attachment.attributes.medium_preview !== null" class="attachment-image-tooltip bg-white sn-shadow-menu-sm">
|
|
|
|
<img :src="this.imageLoadError ? attachment.attributes.urls.blob : attachment.attributes.medium_preview" @error="ActiveStoragePreviews.reCheckPreview"
|
|
|
|
@load="ActiveStoragePreviews.showPreview"/>
|
2023-08-22 09:55:20 +08:00
|
|
|
</div>
|
2024-07-09 20:55:01 +08:00
|
|
|
<div class="flex items-center gap-2 text-xs text-sn-grey overflow-hidden ml-auto">
|
|
|
|
<span class="truncate" :title="i18n.t('assets.placeholder.modified_label') + ' ' + attachment.attributes.updated_at_formatted">
|
2022-05-12 23:05:07 +08:00
|
|
|
{{ i18n.t('assets.placeholder.modified_label') }}
|
2022-05-16 17:05:18 +08:00
|
|
|
{{ attachment.attributes.updated_at_formatted }}
|
2022-05-12 23:05:07 +08:00
|
|
|
</span>
|
2024-07-09 20:55:01 +08:00
|
|
|
<span class="truncate" :title="i18n.t('assets.placeholder.size_label', {size: attachment.attributes.file_size_formatted})">
|
2022-05-13 19:07:50 +08:00
|
|
|
{{ i18n.t('assets.placeholder.size_label', {size: attachment.attributes.file_size_formatted}) }}
|
2022-05-12 23:05:07 +08:00
|
|
|
</span>
|
|
|
|
</div>
|
2024-07-09 20:55:01 +08:00
|
|
|
<div class="attachment-actions shrink-0 ml-auto">
|
|
|
|
<AttachmentActions
|
|
|
|
:attachment="attachment"
|
|
|
|
@attachment:viewMode="updateViewMode"
|
|
|
|
@attachment:delete="deleteAttachment"
|
|
|
|
@attachment:moved="attachmentMoved"
|
|
|
|
@attachment:uploaded="reloadAttachments"
|
|
|
|
@attachment:changed="$emit('attachment:changed', $event)"
|
|
|
|
@attachment:update="$emit('attachment:update', $event)"
|
|
|
|
@attachment:toggle_menu="toggleMenuDropdown"
|
|
|
|
@attachment:move_modal="showMoveModal"
|
|
|
|
@attachment:open="$emit($event)"
|
|
|
|
/>
|
2024-06-20 17:48:35 +08:00
|
|
|
</div>
|
|
|
|
<Teleport to="body">
|
|
|
|
<moveAssetModal
|
|
|
|
v-if="movingAttachment"
|
|
|
|
:parent_type="attachment.attributes.parent_type"
|
|
|
|
:targets_url="attachment.attributes.urls.move_targets"
|
|
|
|
@confirm="moveAttachment($event)" @cancel="closeMoveModal"
|
|
|
|
/>
|
|
|
|
</Teleport>
|
2022-05-12 23:05:07 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-01-04 23:34:36 +08:00
|
|
|
import AttachmentMovedMixin from './mixins/attachment_moved.js';
|
|
|
|
import ContextMenuMixin from './mixins/context_menu.js';
|
|
|
|
import ContextMenu from './context_menu.vue';
|
2024-03-18 20:48:04 +08:00
|
|
|
import MoveMixin from './mixins/move.js';
|
|
|
|
import MoveAssetModal from '../modal/move.vue';
|
2024-07-09 20:55:01 +08:00
|
|
|
import AttachmentActions from './attachment_actions.vue';
|
2024-03-18 20:48:04 +08:00
|
|
|
import OpenMenu from './open_menu.vue';
|
2022-05-17 16:39:17 +08:00
|
|
|
|
2024-01-04 23:34:36 +08:00
|
|
|
export default {
|
|
|
|
name: 'listAttachment',
|
2024-03-18 20:48:04 +08:00
|
|
|
mixins: [ContextMenuMixin, AttachmentMovedMixin, MoveMixin],
|
|
|
|
components: {
|
|
|
|
ContextMenu,
|
|
|
|
MoveAssetModal,
|
2024-07-09 20:55:01 +08:00
|
|
|
OpenMenu,
|
|
|
|
AttachmentActions
|
2024-03-18 20:48:04 +08:00
|
|
|
},
|
2024-01-04 23:34:36 +08:00
|
|
|
props: {
|
|
|
|
attachment: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
2022-05-12 23:05:07 +08:00
|
|
|
},
|
2024-01-04 23:34:36 +08:00
|
|
|
parentId: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
2024-06-07 18:05:31 +08:00
|
|
|
},
|
|
|
|
dataE2e: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
2024-01-04 23:34:36 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2024-03-18 20:48:04 +08:00
|
|
|
imageLoadError: false,
|
|
|
|
isContextMenuOpen: false,
|
|
|
|
isMenuDropdownOpen: false
|
2024-01-04 23:34:36 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleImageError() {
|
|
|
|
this.imageLoadError = true;
|
2024-03-18 20:48:04 +08:00
|
|
|
},
|
|
|
|
toggleContextMenu(isOpen) {
|
|
|
|
this.isContextMenuOpen = isOpen;
|
|
|
|
},
|
|
|
|
toggleMenuDropdown(isOpen) {
|
|
|
|
this.isMenuDropdownOpen = isOpen;
|
|
|
|
}
|
|
|
|
},
|
2024-01-04 23:34:36 +08:00
|
|
|
};
|
2022-05-12 23:05:07 +08:00
|
|
|
</script>
|