fix: added template selector modal in activity and added sendtemplate functionality
This commit is contained in:
parent
7047b8c343
commit
cc47eb976e
@ -62,6 +62,22 @@ def create_whatsapp_message(reference_doctype, reference_name, message, to, atta
|
|||||||
doc.insert(ignore_permissions=True)
|
doc.insert(ignore_permissions=True)
|
||||||
return doc.name
|
return doc.name
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def send_whatsapp_template(reference_doctype, reference_name, template, to):
|
||||||
|
doc = frappe.new_doc("WhatsApp Message")
|
||||||
|
doc.update({
|
||||||
|
"reference_doctype": reference_doctype,
|
||||||
|
"reference_name": reference_name,
|
||||||
|
"message_type": "Template",
|
||||||
|
"message": "Template message",
|
||||||
|
"content_type": "text",
|
||||||
|
"use_template": True,
|
||||||
|
"template": template,
|
||||||
|
"to": to,
|
||||||
|
})
|
||||||
|
doc.insert(ignore_permissions=True)
|
||||||
|
return doc.name
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def react_on_whatsapp_message(emoji, reply_to_name):
|
def react_on_whatsapp_message(emoji, reply_to_name):
|
||||||
reply_to_doc = frappe.get_doc("WhatsApp Message", reply_to_name)
|
reply_to_doc = frappe.get_doc("WhatsApp Message", reply_to_name)
|
||||||
|
|||||||
@ -45,6 +45,10 @@
|
|||||||
<RefreshIcon class="h-4 w-4" />
|
<RefreshIcon class="h-4 w-4" />
|
||||||
</template>
|
</template>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
:label="__('Select Template')"
|
||||||
|
@click="showWhatsappTemplates = true"
|
||||||
|
/>
|
||||||
<Button variant="solid" @click="$refs.whatsappBox.show()">
|
<Button variant="solid" @click="$refs.whatsappBox.show()">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<FeatherIcon name="plus" class="h-4 w-4" />
|
<FeatherIcon name="plus" class="h-4 w-4" />
|
||||||
@ -802,6 +806,10 @@
|
|||||||
:doctype="doctype"
|
:doctype="doctype"
|
||||||
:doc="doc.data?.name"
|
:doc="doc.data?.name"
|
||||||
/>
|
/>
|
||||||
|
<WhatsappTemplateSelectorModal
|
||||||
|
v-model="showWhatsappTemplates"
|
||||||
|
@send="(t) => sendTemplate(t)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import UserAvatar from '@/components/UserAvatar.vue'
|
import UserAvatar from '@/components/UserAvatar.vue'
|
||||||
@ -833,6 +841,7 @@ import AttachmentItem from '@/components/AttachmentItem.vue'
|
|||||||
import CommunicationArea from '@/components/CommunicationArea.vue'
|
import CommunicationArea from '@/components/CommunicationArea.vue'
|
||||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||||
import TaskModal from '@/components/Modals/TaskModal.vue'
|
import TaskModal from '@/components/Modals/TaskModal.vue'
|
||||||
|
import WhatsappTemplateSelectorModal from '@/components/Modals/WhatsappTemplateSelectorModal.vue'
|
||||||
import {
|
import {
|
||||||
timeAgo,
|
timeAgo,
|
||||||
dateFormat,
|
dateFormat,
|
||||||
@ -923,6 +932,8 @@ const all_activities = createResource({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const showWhatsappTemplates = ref(false)
|
||||||
|
|
||||||
const whatsappMessages = createListResource({
|
const whatsappMessages = createListResource({
|
||||||
type: 'list',
|
type: 'list',
|
||||||
doctype: 'WhatsApp Message',
|
doctype: 'WhatsApp Message',
|
||||||
@ -993,6 +1004,23 @@ const whatsappMessages = createListResource({
|
|||||||
onSuccess: () => nextTick(() => scroll()),
|
onSuccess: () => nextTick(() => scroll()),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function sendTemplate(template) {
|
||||||
|
showWhatsappTemplates.value = false
|
||||||
|
createResource({
|
||||||
|
url: 'crm.api.whatsapp.send_whatsapp_template',
|
||||||
|
params: {
|
||||||
|
reference_doctype: props.doctype,
|
||||||
|
reference_name: doc.value.data.name,
|
||||||
|
to: doc.value.data.mobile_no,
|
||||||
|
template,
|
||||||
|
},
|
||||||
|
auto: true,
|
||||||
|
onSuccess() {
|
||||||
|
whatsappMessages.reload()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const replyMessage = ref({})
|
const replyMessage = ref({})
|
||||||
|
|
||||||
function get_activities() {
|
function get_activities() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user