scinote-web/app/javascript/vue/shared/content/attachments/list.vue

72 lines
2.1 KiB
Vue
Raw Normal View History

2022-05-12 23:05:07 +08:00
<template>
<div class="list-attachment-container asset"
:data-asset-id="attachment.id"
>
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"
:data-gallery-view-id="parentId"
2022-05-12 23:05:07 +08:00
:data-preview-url="attachment.attributes.urls.preview"
>
<span class="attachment-name" data-toggle="tooltip"
data-placement="bottom">
{{ attachment.attributes.file_name }}
</span>
2022-05-12 23:05:07 +08:00
</a>
<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="handleImageError"/>
</div>
2022-05-12 23:05:07 +08:00
<div class="file-metadata">
<span>
{{ i18n.t('assets.placeholder.modified_label') }}
{{ attachment.attributes.updated_at_formatted }}
2022-05-12 23:05:07 +08:00
</span>
<span>
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>
<ContextMenu
:attachment="attachment"
@attachment:viewMode="updateViewMode"
@attachment:delete="deleteAttachment"
@attachment:moved="attachmentMoved"
2023-10-05 21:44:41 +08:00
@attachment:uploaded="reloadAttachments"
/>
2022-05-12 23:05:07 +08:00
</div>
</template>
<script>
import AttachmentMovedMixin from './mixins/attachment_moved.js';
import ContextMenuMixin from './mixins/context_menu.js'
import ContextMenu from './context_menu.vue'
2022-05-12 23:05:07 +08:00
export default {
name: 'listAttachment',
mixins: [ContextMenuMixin, AttachmentMovedMixin],
components: { ContextMenu },
2022-05-12 23:05:07 +08:00
props: {
attachment: {
type: Object,
required: true
},
parentId: {
2022-05-12 23:05:07 +08:00
type: Number,
required: true
},
2022-05-12 23:05:07 +08:00
},
data() {
return {
imageLoadError: false
};
},
methods: {
handleImageError() {
this.imageLoadError = true;
}
}
2022-05-12 23:05:07 +08:00
}
</script>