diff --git a/frontend/src/components/Activities/Activities.vue b/frontend/src/components/Activities/Activities.vue index cfbbb813..39be4bff 100644 --- a/frontend/src/components/Activities/Activities.vue +++ b/frontend/src/components/Activities/Activities.vue @@ -111,7 +111,10 @@ :key="attachment.name" class="activity" > - + diff --git a/frontend/src/components/Activities/AttachmentArea.vue b/frontend/src/components/Activities/AttachmentArea.vue index 4d7b920b..cdfa9918 100644 --- a/frontend/src/components/Activities/AttachmentArea.vue +++ b/frontend/src/components/Activities/AttachmentArea.vue @@ -35,7 +35,10 @@ - @@ -55,7 +61,8 @@ import FileAudioIcon from '@/components/Icons/FileAudioIcon.vue' import FileTextIcon from '@/components/Icons/FileTextIcon.vue' import FileVideoIcon from '@/components/Icons/FileVideoIcon.vue' -import { Tooltip } from 'frappe-ui' +import { globalStore } from '@/stores/global' +import { call, Tooltip } from 'frappe-ui' import { dateFormat, timeAgo, @@ -63,22 +70,68 @@ import { convertSize, isImage, } from '@/utils' -import FeatherIcon from 'frappe-ui/src/components/FeatherIcon.vue' const props = defineProps({ attachment: Object, }) +const emit = defineEmits(['reload']) + +const { $dialog } = globalStore() + function openFile() { window.open(props.attachment.file_url, '_blank') } -function togglePrivate() { - // FilesUploadHandler.togglePrivate(attachment) +function togglePrivate(fileName, isPrivate) { + let changeTo = isPrivate ? __('public') : __('private') + let title = __('Make attachment {0}', [changeTo]) + let message = __('Are you sure you want to make this attachment {0}?', [ + changeTo, + ]) + $dialog({ + title, + message, + actions: [ + { + label: __('Make {0}', [changeTo]), + variant: 'solid', + onClick: async (close) => { + await call('frappe.client.set_value', { + doctype: 'File', + name: fileName, + fieldname: { + is_private: !isPrivate, + }, + }) + emit('reload') + close() + }, + }, + ], + }) } -function deleteAttachment() { - // FilesUploadHandler.deleteAttachment(attachment) +function deleteAttachment(fileName) { + $dialog({ + title: __('Delete attachment'), + message: __('Are you sure you want to delete this attachment?'), + actions: [ + { + label: __('Delete'), + variant: 'solid', + theme: 'red', + onClick: async (close) => { + await call('frappe.client.delete', { + doctype: 'File', + name: fileName, + }) + emit('reload') + close() + }, + }, + ], + }) } function fileIcon(type) {