fix: delete attachment & toggle private/public
This commit is contained in:
parent
21379b6cf4
commit
3a750494b9
@ -111,7 +111,10 @@
|
|||||||
:key="attachment.name"
|
:key="attachment.name"
|
||||||
class="activity"
|
class="activity"
|
||||||
>
|
>
|
||||||
<AttachmentArea :attachment="attachment" />
|
<AttachmentArea
|
||||||
|
:attachment="attachment"
|
||||||
|
@reload="all_activities.reload() && scroll()"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -35,7 +35,10 @@
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
:text="attachment.is_private ? __('Make public') : __('Make private')"
|
:text="attachment.is_private ? __('Make public') : __('Make private')"
|
||||||
>
|
>
|
||||||
<Button class="!size-5" @click="togglePrivate">
|
<Button
|
||||||
|
class="!size-5"
|
||||||
|
@click.stop="togglePrivate(attachment.name, attachment.is_private)"
|
||||||
|
>
|
||||||
<FeatherIcon
|
<FeatherIcon
|
||||||
:name="attachment.is_private ? 'lock' : 'unlock'"
|
:name="attachment.is_private ? 'lock' : 'unlock'"
|
||||||
class="size-3 text-gray-700"
|
class="size-3 text-gray-700"
|
||||||
@ -43,7 +46,10 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :text="__('Delete attachment')">
|
<Tooltip :text="__('Delete attachment')">
|
||||||
<Button class="!size-5" @click="deleteAttachment">
|
<Button
|
||||||
|
class="!size-5"
|
||||||
|
@click.stop="() => deleteAttachment(attachment.name)"
|
||||||
|
>
|
||||||
<FeatherIcon name="trash-2" class="size-3 text-gray-700" />
|
<FeatherIcon name="trash-2" class="size-3 text-gray-700" />
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@ -55,7 +61,8 @@
|
|||||||
import FileAudioIcon from '@/components/Icons/FileAudioIcon.vue'
|
import FileAudioIcon from '@/components/Icons/FileAudioIcon.vue'
|
||||||
import FileTextIcon from '@/components/Icons/FileTextIcon.vue'
|
import FileTextIcon from '@/components/Icons/FileTextIcon.vue'
|
||||||
import FileVideoIcon from '@/components/Icons/FileVideoIcon.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 {
|
import {
|
||||||
dateFormat,
|
dateFormat,
|
||||||
timeAgo,
|
timeAgo,
|
||||||
@ -63,22 +70,68 @@ import {
|
|||||||
convertSize,
|
convertSize,
|
||||||
isImage,
|
isImage,
|
||||||
} from '@/utils'
|
} from '@/utils'
|
||||||
import FeatherIcon from 'frappe-ui/src/components/FeatherIcon.vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
attachment: Object,
|
attachment: Object,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['reload'])
|
||||||
|
|
||||||
|
const { $dialog } = globalStore()
|
||||||
|
|
||||||
function openFile() {
|
function openFile() {
|
||||||
window.open(props.attachment.file_url, '_blank')
|
window.open(props.attachment.file_url, '_blank')
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePrivate() {
|
function togglePrivate(fileName, isPrivate) {
|
||||||
// FilesUploadHandler.togglePrivate(attachment)
|
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() {
|
function deleteAttachment(fileName) {
|
||||||
// FilesUploadHandler.deleteAttachment(attachment)
|
$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) {
|
function fileIcon(type) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user