fix: load and show attachments in attachments tab
This commit is contained in:
parent
b40fd4a1af
commit
4eb506ee45
@ -35,10 +35,11 @@ def get_deal_activities(name):
|
||||
calls = []
|
||||
notes = []
|
||||
tasks = []
|
||||
attachments = []
|
||||
creation_text = "created this deal"
|
||||
|
||||
if lead:
|
||||
activities, calls, notes, tasks = get_lead_activities(lead)
|
||||
activities, calls, notes, tasks, attachments = get_lead_activities(lead)
|
||||
creation_text = "converted the lead to this deal"
|
||||
|
||||
activities.append({
|
||||
@ -134,11 +135,12 @@ def get_deal_activities(name):
|
||||
calls = calls + get_linked_calls(name)
|
||||
notes = notes + get_linked_notes(name)
|
||||
tasks = tasks + get_linked_tasks(name)
|
||||
attachments = attachments + get_attachments('CRM Deal', name)
|
||||
|
||||
activities.sort(key=lambda x: x["creation"], reverse=True)
|
||||
activities = handle_multiple_versions(activities)
|
||||
|
||||
return activities, calls, notes, tasks
|
||||
return activities, calls, notes, tasks, attachments
|
||||
|
||||
def get_lead_activities(name):
|
||||
get_docinfo('', "CRM Lead", name)
|
||||
@ -248,19 +250,20 @@ def get_lead_activities(name):
|
||||
calls = get_linked_calls(name)
|
||||
notes = get_linked_notes(name)
|
||||
tasks = get_linked_tasks(name)
|
||||
attachments = get_attachments('CRM Lead', name)
|
||||
|
||||
activities.sort(key=lambda x: x["creation"], reverse=True)
|
||||
activities = handle_multiple_versions(activities)
|
||||
|
||||
return activities, calls, notes, tasks
|
||||
return activities, calls, notes, tasks, attachments
|
||||
|
||||
@redis_cache()
|
||||
def get_attachments(doctype, name):
|
||||
return frappe.db.get_all(
|
||||
"File",
|
||||
filters={"attached_to_doctype": doctype, "attached_to_name": name},
|
||||
fields=["name", "file_name", "file_url", "file_size", "is_private"],
|
||||
)
|
||||
fields=["name", "file_name", "file_url", "file_size", "is_private", "creation", "owner"],
|
||||
) or []
|
||||
|
||||
def handle_multiple_versions(versions):
|
||||
activities = []
|
||||
|
||||
@ -104,6 +104,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="title == 'Attachments'">
|
||||
<div
|
||||
class="grid grid-cols-1 gap-4 px-3 pb-3 sm:px-10 sm:pb-5 lg:grid-cols-2 xl:grid-cols-3"
|
||||
>
|
||||
<div v-for="attachment in activities">
|
||||
<AttachmentArea :attachment="attachment" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
v-for="(activity, i) in activities"
|
||||
@ -415,6 +424,7 @@ import CommentArea from '@/components/Activities/CommentArea.vue'
|
||||
import CallArea from '@/components/Activities/CallArea.vue'
|
||||
import NoteArea from '@/components/Activities/NoteArea.vue'
|
||||
import TaskArea from '@/components/Activities/TaskArea.vue'
|
||||
import AttachmentArea from '@/components/Activities/AttachmentArea.vue'
|
||||
import UserAvatar from '@/components/UserAvatar.vue'
|
||||
import ActivityIcon from '@/components/Icons/ActivityIcon.vue'
|
||||
import Email2Icon from '@/components/Icons/Email2Icon.vue'
|
||||
@ -498,7 +508,7 @@ const all_activities = createResource({
|
||||
params: { name: doc.value.data.name },
|
||||
cache: ['activity', doc.value.data.name],
|
||||
auto: true,
|
||||
transform: ([versions, calls, notes, tasks]) => {
|
||||
transform: ([versions, calls, notes, tasks, attachments]) => {
|
||||
if (calls?.length) {
|
||||
calls.forEach((doc) => {
|
||||
doc.show_recording = false
|
||||
@ -533,7 +543,7 @@ const all_activities = createResource({
|
||||
}
|
||||
})
|
||||
}
|
||||
return { versions, calls, notes, tasks }
|
||||
return { versions, calls, notes, tasks, attachments }
|
||||
},
|
||||
})
|
||||
|
||||
@ -621,6 +631,9 @@ const activities = computed(() => {
|
||||
} else if (title.value == 'Notes') {
|
||||
if (!all_activities.data?.notes) return []
|
||||
return sortByCreation(all_activities.data.notes)
|
||||
} else if (title.value == 'Attachments') {
|
||||
if (!all_activities.data?.attachments) return []
|
||||
return sortByCreation(all_activities.data.attachments)
|
||||
}
|
||||
|
||||
activities.forEach((activity) => {
|
||||
|
||||
8
frontend/src/components/Activities/AttachmentArea.vue
Normal file
8
frontend/src/components/Activities/AttachmentArea.vue
Normal file
@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div>{{ attachment }}</div>
|
||||
</template>
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
attachment: Object,
|
||||
})
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user