fix: allow adding/editing note and task in call log
This commit is contained in:
parent
9faa9f7171
commit
0a572c56f8
@ -53,15 +53,17 @@ def add_note_to_call_log(call_sid, note):
|
|||||||
_note = frappe.get_doc(
|
_note = frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "FCRM Note",
|
"doctype": "FCRM Note",
|
||||||
|
"title": note.get("title", "Call Note"),
|
||||||
"content": note.get("content"),
|
"content": note.get("content"),
|
||||||
}
|
}
|
||||||
).insert(ignore_permissions=True)
|
).insert(ignore_permissions=True)
|
||||||
call_log = frappe.get_cached_doc("CRM Call Log", call_sid)
|
|
||||||
call_log.link_with_reference_doc("FCRM Note", _note.name)
|
|
||||||
call_log.save(ignore_permissions=True)
|
|
||||||
else:
|
else:
|
||||||
_note = frappe.set_value("FCRM Note", note.get("name"), "content", note.get("content"))
|
_note = frappe.set_value("FCRM Note", note.get("name"), "content", note.get("content"))
|
||||||
|
|
||||||
|
call_log = frappe.get_cached_doc("CRM Call Log", call_sid)
|
||||||
|
call_log.link_with_reference_doc("FCRM Note", _note.name)
|
||||||
|
call_log.save(ignore_permissions=True)
|
||||||
|
|
||||||
return _note
|
return _note
|
||||||
|
|
||||||
|
|
||||||
@ -75,21 +77,30 @@ def add_task_to_call_log(call_sid, task):
|
|||||||
"doctype": "CRM Task",
|
"doctype": "CRM Task",
|
||||||
"title": task.get("title"),
|
"title": task.get("title"),
|
||||||
"description": task.get("description"),
|
"description": task.get("description"),
|
||||||
|
"assigned_to": task.get("assigned_to"),
|
||||||
|
"due_date": task.get("due_date"),
|
||||||
|
"status": task.get("status"),
|
||||||
|
"priority": task.get("priority"),
|
||||||
}
|
}
|
||||||
).insert(ignore_permissions=True)
|
).insert(ignore_permissions=True)
|
||||||
call_log = frappe.get_doc("CRM Call Log", call_sid)
|
|
||||||
call_log.link_with_reference_doc("CRM Task", _task.name)
|
|
||||||
call_log.save(ignore_permissions=True)
|
|
||||||
else:
|
else:
|
||||||
_task = frappe.get_doc("CRM Task", task.get("name"))
|
_task = frappe.get_doc("CRM Task", task.get("name"))
|
||||||
_task.update(
|
_task.update(
|
||||||
{
|
{
|
||||||
"title": task.get("title"),
|
"title": task.get("title"),
|
||||||
"description": task.get("description"),
|
"description": task.get("description"),
|
||||||
|
"assigned_to": task.get("assigned_to"),
|
||||||
|
"due_date": task.get("due_date"),
|
||||||
|
"status": task.get("status"),
|
||||||
|
"priority": task.get("priority"),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
_task.save(ignore_permissions=True)
|
_task.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
call_log = frappe.get_doc("CRM Call Log", call_sid)
|
||||||
|
call_log.link_with_reference_doc("CRM Task", _task.name)
|
||||||
|
call_log.save(ignore_permissions=True)
|
||||||
|
|
||||||
return _task
|
return _task
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,30 @@
|
|||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
|
<Dropdown
|
||||||
|
:options="[
|
||||||
|
{
|
||||||
|
group: __('Options'),
|
||||||
|
hideLabel: true,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: note?.name ? __('Edit note') : __('Add note'),
|
||||||
|
icon: NoteIcon,
|
||||||
|
onClick: addEditNote,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: task?.name ? __('Edit task') : __('Add task'),
|
||||||
|
icon: TaskIcon,
|
||||||
|
onClick: addEditTask,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<template #default>
|
||||||
|
<Button variant="ghost" icon="more-horizontal" />
|
||||||
|
</template>
|
||||||
|
</Dropdown>
|
||||||
<Button
|
<Button
|
||||||
v-if="isManager() && !isMobileView"
|
v-if="isManager() && !isMobileView"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@ -84,6 +108,23 @@
|
|||||||
/>
|
/>
|
||||||
</FadedScrollableDiv>
|
</FadedScrollableDiv>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="w-full cursor-pointer rounded border px-2 pt-1.5 text-base text-ink-gray-7"
|
||||||
|
v-else-if="field.name == 'task'"
|
||||||
|
@click="() => (showTaskModal = true)"
|
||||||
|
>
|
||||||
|
<FadedScrollableDiv class="max-h-24 min-h-16 overflow-y-auto">
|
||||||
|
<div
|
||||||
|
v-if="field.value?.title"
|
||||||
|
:class="[field.value?.description ? 'mb-1 font-bold' : '']"
|
||||||
|
v-html="field.value?.title"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-if="field.value?.description"
|
||||||
|
v-html="field.value?.description"
|
||||||
|
/>
|
||||||
|
</FadedScrollableDiv>
|
||||||
|
</div>
|
||||||
<div v-else :class="field.color ? `text-${field.color}-600` : ''">
|
<div v-else :class="field.color ? `text-${field.color}-600` : ''">
|
||||||
{{ field.value }}
|
{{ field.value }}
|
||||||
</div>
|
</div>
|
||||||
@ -110,7 +151,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<NoteModal v-model="showNoteModal" :note="callLog?.data?._notes?.[0]" />
|
<NoteModal v-model="showNoteModal" :note="note" @after="addNoteToCallLog" />
|
||||||
|
<TaskModal v-model="showTaskModal" :task="task" @after="addTaskToCallLog" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
@ -122,13 +164,15 @@ import LeadsIcon from '@/components/Icons/LeadsIcon.vue'
|
|||||||
import Dealsicon from '@/components/Icons/DealsIcon.vue'
|
import Dealsicon from '@/components/Icons/DealsIcon.vue'
|
||||||
import CalendarIcon from '@/components/Icons/CalendarIcon.vue'
|
import CalendarIcon from '@/components/Icons/CalendarIcon.vue'
|
||||||
import NoteIcon from '@/components/Icons/NoteIcon.vue'
|
import NoteIcon from '@/components/Icons/NoteIcon.vue'
|
||||||
|
import TaskIcon from '@/components/Icons/TaskIcon.vue'
|
||||||
import CheckCircleIcon from '@/components/Icons/CheckCircleIcon.vue'
|
import CheckCircleIcon from '@/components/Icons/CheckCircleIcon.vue'
|
||||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||||
|
import TaskModal from '@/components/Modals/TaskModal.vue'
|
||||||
import FadedScrollableDiv from '@/components/FadedScrollableDiv.vue'
|
import FadedScrollableDiv from '@/components/FadedScrollableDiv.vue'
|
||||||
import { getCallLogDetail } from '@/utils/callLog'
|
import { getCallLogDetail } from '@/utils/callLog'
|
||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
import { isMobileView } from '@/composables/settings'
|
import { isMobileView } from '@/composables/settings'
|
||||||
import { FeatherIcon, Avatar, Tooltip, call } from 'frappe-ui'
|
import { FeatherIcon, Dropdown, Avatar, Tooltip, call } from 'frappe-ui'
|
||||||
import { ref, computed, h, nextTick } from 'vue'
|
import { ref, computed, h, nextTick } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
@ -137,9 +181,24 @@ const router = useRouter()
|
|||||||
|
|
||||||
const show = defineModel()
|
const show = defineModel()
|
||||||
const showNoteModal = ref(false)
|
const showNoteModal = ref(false)
|
||||||
|
const showTaskModal = ref(false)
|
||||||
|
|
||||||
const callLog = defineModel('callLog')
|
const callLog = defineModel('callLog')
|
||||||
|
|
||||||
|
const note = ref({
|
||||||
|
title: '',
|
||||||
|
content: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const task = ref({
|
||||||
|
title: '',
|
||||||
|
description: '',
|
||||||
|
assigned_to: '',
|
||||||
|
due_date: '',
|
||||||
|
status: 'Backlog',
|
||||||
|
priority: 'Low',
|
||||||
|
})
|
||||||
|
|
||||||
const detailFields = computed(() => {
|
const detailFields = computed(() => {
|
||||||
if (!callLog.value?.data) return []
|
if (!callLog.value?.data) return []
|
||||||
|
|
||||||
@ -149,6 +208,9 @@ const detailFields = computed(() => {
|
|||||||
data[key] = getCallLogDetail(key, data)
|
data[key] = getCallLogDetail(key, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
note.value = data._notes?.[0] ?? null
|
||||||
|
task.value = data._tasks?.[0] ?? null
|
||||||
|
|
||||||
let details = [
|
let details = [
|
||||||
{
|
{
|
||||||
icon: h(FeatherIcon, {
|
icon: h(FeatherIcon, {
|
||||||
@ -215,6 +277,11 @@ const detailFields = computed(() => {
|
|||||||
name: 'note',
|
name: 'note',
|
||||||
value: data._notes?.[0] ?? null,
|
value: data._notes?.[0] ?? null,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
icon: TaskIcon,
|
||||||
|
name: 'task',
|
||||||
|
value: data._tasks?.[0] ?? null,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
return details
|
return details
|
||||||
@ -240,6 +307,50 @@ function openCallLogModal() {
|
|||||||
show.value = false
|
show.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addEditNote() {
|
||||||
|
if (!note.value?.name) {
|
||||||
|
note.value = {
|
||||||
|
title: '',
|
||||||
|
content: '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showNoteModal.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function addEditTask() {
|
||||||
|
if (!task.value?.name) {
|
||||||
|
task.value = {
|
||||||
|
title: '',
|
||||||
|
description: '',
|
||||||
|
assigned_to: '',
|
||||||
|
due_date: '',
|
||||||
|
status: 'Backlog',
|
||||||
|
priority: 'Low',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
showTaskModal.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addNoteToCallLog(_note, insert_mode = false) {
|
||||||
|
note.value = _note
|
||||||
|
if (insert_mode && _note.name) {
|
||||||
|
await call('crm.integrations.api.add_note_to_call_log', {
|
||||||
|
call_sid: callLog.value?.data?.id,
|
||||||
|
note: _note,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addTaskToCallLog(_task, insert_mode = false) {
|
||||||
|
task.value = _task
|
||||||
|
if (insert_mode && _task.name) {
|
||||||
|
await call('crm.integrations.api.add_task_to_call_log', {
|
||||||
|
call_sid: callLog.value?.data?.id,
|
||||||
|
task: _task,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@ -187,7 +187,8 @@ async function updateTask() {
|
|||||||
fieldname: _task.value,
|
fieldname: _task.value,
|
||||||
})
|
})
|
||||||
if (d.name) {
|
if (d.name) {
|
||||||
tasks.value.reload()
|
tasks.value?.reload()
|
||||||
|
emit('after', d)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let d = await call('frappe.client.insert', {
|
let d = await call('frappe.client.insert', {
|
||||||
@ -200,8 +201,8 @@ async function updateTask() {
|
|||||||
})
|
})
|
||||||
if (d.name) {
|
if (d.name) {
|
||||||
capture('task_created')
|
capture('task_created')
|
||||||
tasks.value.reload()
|
tasks.value?.reload()
|
||||||
emit('after')
|
emit('after', d, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
show.value = false
|
show.value = false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user