fix: validate before saving
This commit is contained in:
parent
b757a0170a
commit
dde6d3736f
@ -46,12 +46,14 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "exotel_number",
|
"fieldname": "exotel_number",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
"label": "Exotel Number"
|
"label": "Exotel Number"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-01-15 16:19:21.965415",
|
"modified": "2025-01-15 20:03:31.162162",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "FCRM",
|
"module": "FCRM",
|
||||||
"name": "CRM Exotel Agent",
|
"name": "CRM Exotel Agent",
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
>
|
>
|
||||||
<div>{{ __('Telephony Settings') }}</div>
|
<div>{{ __('Telephony Settings') }}</div>
|
||||||
<Badge
|
<Badge
|
||||||
v-if="twilio.isDirty || exotel.isDirty"
|
v-if="twilio.isDirty || exotel.isDirty || mediumChanged"
|
||||||
:label="__('Not Saved')"
|
:label="__('Not Saved')"
|
||||||
variant="subtle"
|
variant="subtle"
|
||||||
theme="orange"
|
theme="orange"
|
||||||
@ -59,8 +59,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between gap-2">
|
<div class="flex justify-between gap-2">
|
||||||
<div>
|
<div>
|
||||||
<ErrorMessage class="mt-2" :message="twilio.save.error" />
|
<ErrorMessage
|
||||||
<ErrorMessage class="mt-2" :message="exotel.save.error" />
|
class="mt-2"
|
||||||
|
:message="twilio.save.error || exotel.save.error || error"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
:loading="twilio.save.loading || exotel.save.loading"
|
:loading="twilio.save.loading || exotel.save.loading"
|
||||||
@ -84,7 +86,7 @@ import {
|
|||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { defaultCallingMedium } from '@/composables/settings'
|
import { defaultCallingMedium } from '@/composables/settings'
|
||||||
import { createToast, getRandom } from '@/utils'
|
import { createToast, getRandom } from '@/utils'
|
||||||
import { computed } from 'vue'
|
import { ref, computed, watch } from 'vue'
|
||||||
|
|
||||||
const twilioFields = createResource({
|
const twilioFields = createResource({
|
||||||
url: 'crm.api.doc.get_fields',
|
url: 'crm.api.doc.get_fields',
|
||||||
@ -260,10 +262,17 @@ const exotelTabs = computed(() => {
|
|||||||
return _tabs
|
return _tabs
|
||||||
})
|
})
|
||||||
|
|
||||||
async function update() {
|
const mediumChanged = ref(false)
|
||||||
call('crm.integrations.api.set_default_calling_medium', {
|
|
||||||
medium: defaultCallingMedium.value,
|
watch(defaultCallingMedium, () => {
|
||||||
})
|
mediumChanged.value = true
|
||||||
|
})
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
if (!validateIfDefaultMediumIsEnabled()) return
|
||||||
|
if (mediumChanged.value) {
|
||||||
|
updateMedium()
|
||||||
|
}
|
||||||
if (twilio.isDirty) {
|
if (twilio.isDirty) {
|
||||||
twilio.save.submit()
|
twilio.save.submit()
|
||||||
}
|
}
|
||||||
@ -271,4 +280,32 @@ async function update() {
|
|||||||
exotel.save.submit()
|
exotel.save.submit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateMedium() {
|
||||||
|
await call('crm.integrations.api.set_default_calling_medium', {
|
||||||
|
medium: defaultCallingMedium.value,
|
||||||
|
})
|
||||||
|
mediumChanged.value = false
|
||||||
|
error.value = ''
|
||||||
|
createToast({
|
||||||
|
title: __('Success'),
|
||||||
|
text: __('Default calling medium updated successfully'),
|
||||||
|
icon: 'check',
|
||||||
|
iconClasses: 'text-ink-green-3',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const error = ref('')
|
||||||
|
|
||||||
|
function validateIfDefaultMediumIsEnabled() {
|
||||||
|
if (defaultCallingMedium.value === 'Twilio' && !twilio.doc.enabled) {
|
||||||
|
error.value = __('Twilio is not enabled')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (defaultCallingMedium.value === 'Exotel' && !exotel.doc.enabled) {
|
||||||
|
error.value = __('Exotel is not enabled')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user