fix: added on before create hook in call log modal
(cherry picked from commit ac13b7a3bd58021a91793817f07b4703bd8f42b4)
This commit is contained in:
parent
bca6ef575a
commit
d8f990ac8e
@ -85,7 +85,7 @@ const loading = ref(false)
|
|||||||
const error = ref(null)
|
const error = ref(null)
|
||||||
const editMode = ref(false)
|
const editMode = ref(false)
|
||||||
|
|
||||||
const { document: callLog } = useDocument(
|
const { document: callLog, triggerOnBeforeCreate } = useDocument(
|
||||||
'CRM Call Log',
|
'CRM Call Log',
|
||||||
props.data?.name || '',
|
props.data?.name || '',
|
||||||
)
|
)
|
||||||
@ -97,8 +97,7 @@ const dialogOptions = computed(() => {
|
|||||||
{
|
{
|
||||||
label: editMode.value ? __('Save') : __('Create'),
|
label: editMode.value ? __('Save') : __('Create'),
|
||||||
variant: 'solid',
|
variant: 'solid',
|
||||||
onClick: () =>
|
onClick: () => (editMode.value ? updateCallLog() : createCallLog()),
|
||||||
editMode.value ? updateCallLog() : createCallLog.submit(),
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -135,18 +134,21 @@ async function updateCallLog() {
|
|||||||
await callLog.save.submit(null, callBacks)
|
await callLog.save.submit(null, callBacks)
|
||||||
}
|
}
|
||||||
|
|
||||||
const createCallLog = createResource({
|
async function createCallLog() {
|
||||||
|
Object.assign(callLog.doc, {
|
||||||
|
doctype: 'CRM Call Log',
|
||||||
|
id: getRandom(6),
|
||||||
|
telephony_medium: 'Manual',
|
||||||
|
})
|
||||||
|
|
||||||
|
await triggerOnBeforeCreate?.()
|
||||||
|
await _createCallLog.submit({
|
||||||
|
doc: callLog.doc,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const _createCallLog = createResource({
|
||||||
url: 'frappe.client.insert',
|
url: 'frappe.client.insert',
|
||||||
makeParams() {
|
|
||||||
return {
|
|
||||||
doc: {
|
|
||||||
doctype: 'CRM Call Log',
|
|
||||||
id: getRandom(6),
|
|
||||||
telephony_medium: 'Manual',
|
|
||||||
...callLog.doc,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSuccess(doc) {
|
onSuccess(doc) {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
if (doc.name) {
|
if (doc.name) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user