Merge pull request #890 from frappe/main-hotfix
This commit is contained in:
commit
3d363222aa
@ -41,13 +41,15 @@
|
||||
"fieldname": "from",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "From"
|
||||
"label": "From",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"label": "Status",
|
||||
"options": "Initiated\nRinging\nIn Progress\nCompleted\nFailed\nBusy\nNo Answer\nQueued\nCanceled"
|
||||
"options": "Initiated\nRinging\nIn Progress\nCompleted\nFailed\nBusy\nNo Answer\nQueued\nCanceled",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "start_time",
|
||||
@ -69,13 +71,15 @@
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Type",
|
||||
"options": "Incoming\nOutgoing"
|
||||
"options": "Incoming\nOutgoing",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "to",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "To"
|
||||
"label": "To",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"description": "Call duration in seconds",
|
||||
@ -153,7 +157,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2025-01-22 17:57:59.289548",
|
||||
"modified": "2025-04-01 16:01:54.479309",
|
||||
"modified_by": "Administrator",
|
||||
"module": "FCRM",
|
||||
"name": "CRM Call Log",
|
||||
|
||||
@ -19,7 +19,8 @@
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Title"
|
||||
"label": "Title",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "content",
|
||||
@ -49,7 +50,7 @@
|
||||
"link_fieldname": "note"
|
||||
}
|
||||
],
|
||||
"modified": "2024-01-19 21:56:30.123334",
|
||||
"modified": "2025-04-01 15:30:14.742001",
|
||||
"modified_by": "Administrator",
|
||||
"module": "FCRM",
|
||||
"name": "FCRM Note",
|
||||
|
||||
@ -250,7 +250,7 @@
|
||||
</span>
|
||||
<span v-if="activity.type">{{ __(activity.type) }}</span>
|
||||
<span
|
||||
v-if="activity.data.field_label"
|
||||
v-if="activity.data?.field_label"
|
||||
class="max-w-xs truncate font-medium text-ink-gray-8"
|
||||
>
|
||||
{{ __(activity.data.field_label) }}
|
||||
@ -307,7 +307,7 @@
|
||||
>
|
||||
<div class="inline-flex flex-wrap gap-1 text-ink-gray-5">
|
||||
<span
|
||||
v-if="activity.data.field_label"
|
||||
v-if="activity.data?.field_label"
|
||||
class="max-w-xs truncate text-ink-gray-5"
|
||||
>
|
||||
{{ __(activity.data.field_label) }}
|
||||
|
||||
@ -91,10 +91,8 @@ function createCallLog() {
|
||||
let doctype = props.doctype
|
||||
let docname = props.doc.data?.name
|
||||
callLog.value = {
|
||||
data: {
|
||||
reference_doctype: doctype,
|
||||
reference_docname: docname,
|
||||
},
|
||||
reference_doctype: doctype,
|
||||
reference_docname: docname,
|
||||
}
|
||||
showCallLogModal.value = true
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@
|
||||
v-model:callLogModal="showCallLogModal"
|
||||
v-model:callLog="callLog"
|
||||
/>
|
||||
<CallLogModal v-model="showCallLogModal" v-model:callLog="callLog" />
|
||||
<CallLogModal v-model="showCallLogModal" v-model:callLog="callLog.data" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
|
||||
@ -5,9 +5,11 @@
|
||||
<MobileAppHeader />
|
||||
<slot />
|
||||
</div>
|
||||
<GlobalModals />
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import MobileSidebar from '@/components/Mobile/MobileSidebar.vue'
|
||||
import MobileAppHeader from '@/components/Mobile/MobileAppHeader.vue'
|
||||
import GlobalModals from '@/components/Modals/GlobalModals.vue'
|
||||
</script>
|
||||
|
||||
@ -22,8 +22,12 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="tabs.data">
|
||||
<FieldLayout :tabs="tabs.data" :data="_address" doctype="Address" />
|
||||
<div v-if="tabs.data && _address.doc">
|
||||
<FieldLayout
|
||||
:tabs="tabs.data"
|
||||
:data="_address.doc"
|
||||
doctype="Address"
|
||||
/>
|
||||
<ErrorMessage class="mt-2" :message="error" />
|
||||
</div>
|
||||
</div>
|
||||
@ -41,24 +45,24 @@
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="Address"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { capture } from '@/telemetry'
|
||||
import { FeatherIcon, createResource, ErrorMessage } from 'frappe-ui'
|
||||
import { ref, nextTick, watch, computed } from 'vue'
|
||||
import { ref, nextTick, computed, onMounted } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
address: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
default: {
|
||||
@ -70,30 +74,18 @@ const props = defineProps({
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const show = defineModel()
|
||||
const address = defineModel('address')
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref(null)
|
||||
const title = ref(null)
|
||||
const editMode = ref(false)
|
||||
|
||||
let _address = ref({
|
||||
name: '',
|
||||
address_title: '',
|
||||
address_type: 'Billing',
|
||||
address_line1: '',
|
||||
address_line2: '',
|
||||
city: '',
|
||||
county: '',
|
||||
state: '',
|
||||
country: '',
|
||||
pincode: '',
|
||||
})
|
||||
const { document: _address } = useDocument('Address', props.address || '')
|
||||
|
||||
const dialogOptions = computed(() => {
|
||||
let title = !editMode.value
|
||||
? __('New Address')
|
||||
: __(_address.value.address_title)
|
||||
: __(_address.doc?.address_title)
|
||||
let size = 'xl'
|
||||
let actions = [
|
||||
{
|
||||
@ -114,42 +106,28 @@ const tabs = createResource({
|
||||
auto: true,
|
||||
})
|
||||
|
||||
let doc = ref({})
|
||||
|
||||
function updateAddress() {
|
||||
error.value = null
|
||||
const old = { ...doc.value }
|
||||
const newAddress = { ..._address.value }
|
||||
|
||||
const dirty = JSON.stringify(old) !== JSON.stringify(newAddress)
|
||||
const values = newAddress
|
||||
|
||||
if (!dirty) {
|
||||
show.value = false
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
updateAddressValues.submit({
|
||||
doctype: 'Address',
|
||||
name: _address.value.name,
|
||||
fieldname: values,
|
||||
})
|
||||
}
|
||||
|
||||
const updateAddressValues = createResource({
|
||||
url: 'frappe.client.set_value',
|
||||
onSuccess(doc) {
|
||||
const callBacks = {
|
||||
onSuccess: (doc) => {
|
||||
loading.value = false
|
||||
if (doc.name) {
|
||||
handleAddressUpdate(doc)
|
||||
}
|
||||
handleAddressUpdate(doc)
|
||||
},
|
||||
onError(err) {
|
||||
onError: (err) => {
|
||||
loading.value = false
|
||||
if (err.exc_type == 'MandatoryError') {
|
||||
const errorMessage = err.messages
|
||||
.map((msg) => msg.split(': ')[2].trim())
|
||||
.join(', ')
|
||||
error.value = __('These fields are required: {0}', [errorMessage])
|
||||
return
|
||||
}
|
||||
error.value = err
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function updateAddress() {
|
||||
loading.value = true
|
||||
await _address.save.submit(null, callBacks)
|
||||
}
|
||||
|
||||
const createAddress = createResource({
|
||||
url: 'frappe.client.insert',
|
||||
@ -157,7 +135,7 @@ const createAddress = createResource({
|
||||
return {
|
||||
doc: {
|
||||
doctype: 'Address',
|
||||
..._address.value,
|
||||
..._address.doc,
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -179,27 +157,17 @@ function handleAddressUpdate(doc) {
|
||||
props.options.afterInsert && props.options.afterInsert(doc)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => show.value,
|
||||
(value) => {
|
||||
if (!value) return
|
||||
editMode.value = false
|
||||
nextTick(() => {
|
||||
// TODO: Issue with FormControl
|
||||
// title.value.el.focus()
|
||||
doc.value = address.value?.doc || address.value || {}
|
||||
_address.value = { ...doc.value }
|
||||
if (_address.value.name) {
|
||||
editMode.value = true
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
onMounted(() => {
|
||||
editMode.value = props.address ? true : false
|
||||
|
||||
const showQuickEntryModal = ref(false)
|
||||
if (!props.address) {
|
||||
_address.doc = { address_type: 'Billing' }
|
||||
}
|
||||
})
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = { doctype: 'Address' }
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
|
||||
@ -1,73 +1,56 @@
|
||||
<template>
|
||||
<Dialog v-model="show" :options="dialogOptions">
|
||||
<template #body>
|
||||
<div class="bg-surface-modal px-4 pb-6 pt-5 sm:px-6">
|
||||
<div class="mb-5 flex items-center justify-between">
|
||||
<div>
|
||||
<div class="px-4 pt-5 pb-6 bg-surface-modal sm:px-6">
|
||||
<div class="flex items-center justify-between mb-5">
|
||||
<div class="flex items-center gap-2">
|
||||
<h3 class="text-2xl font-semibold leading-6 text-ink-gray-9">
|
||||
{{ __(dialogOptions.title) || __('Untitled') }}
|
||||
</h3>
|
||||
<Badge v-if="callLog.isDirty" :label="'Not Saved'" theme="orange" />
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<Button
|
||||
v-if="isManager() && !isMobileView"
|
||||
variant="ghost"
|
||||
class="w-7"
|
||||
@click="openQuickEntryModal"
|
||||
>
|
||||
<EditIcon class="h-4 w-4" />
|
||||
<Button v-if="isManager() && !isMobileView" variant="ghost" class="w-7" @click="openQuickEntryModal">
|
||||
<EditIcon class="w-4 h-4" />
|
||||
</Button>
|
||||
<Button variant="ghost" class="w-7" @click="show = false">
|
||||
<FeatherIcon name="x" class="h-4 w-4" />
|
||||
<FeatherIcon name="x" class="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="tabs.data">
|
||||
<FieldLayout
|
||||
:tabs="tabs.data"
|
||||
:data="_callLog"
|
||||
doctype="CRM Call Log"
|
||||
/>
|
||||
<ErrorMessage class="mt-2" :message="error" />
|
||||
<FieldLayout :tabs="tabs.data" :data="_callLog" doctype="CRM Call Log" />
|
||||
<ErrorMessage class="mt-8" :message="error" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4 pb-7 pt-4 sm:px-6">
|
||||
<div class="px-4 pt-4 pb-7 sm:px-6">
|
||||
<div class="space-y-2">
|
||||
<Button
|
||||
class="w-full"
|
||||
v-for="action in dialogOptions.actions"
|
||||
:key="action.label"
|
||||
v-bind="action"
|
||||
:label="__(action.label)"
|
||||
:loading="loading"
|
||||
/>
|
||||
<Button class="w-full" v-for="action in dialogOptions.actions" :key="action.label" v-bind="action"
|
||||
:label="__(action.label)" :loading="loading" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Call Log"
|
||||
/>
|
||||
<QuickEntryModal v-if="showQuickEntryModal" v-model="showQuickEntryModal" doctype="CRM Call Log" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { getRandom } from '@/utils'
|
||||
import { capture } from '@/telemetry'
|
||||
import { FeatherIcon, createResource, ErrorMessage } from 'frappe-ui'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { FeatherIcon, createResource, ErrorMessage, Badge } from 'frappe-ui'
|
||||
import { ref, nextTick, watch, computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
options: {
|
||||
type: Object,
|
||||
default: {
|
||||
afterInsert: () => {},
|
||||
afterInsert: () => { },
|
||||
},
|
||||
},
|
||||
})
|
||||
@ -75,26 +58,14 @@ const props = defineProps({
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const show = defineModel()
|
||||
const callLog = defineModel('callLog')
|
||||
const _callLog = defineModel('callLog')
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref(null)
|
||||
const title = ref(null)
|
||||
const editMode = ref(false)
|
||||
|
||||
let _callLog = ref({
|
||||
name: '',
|
||||
type: '',
|
||||
from: '',
|
||||
to: '',
|
||||
medium: '',
|
||||
duration: '',
|
||||
caller: '',
|
||||
receiver: '',
|
||||
status: '',
|
||||
recording_url: '',
|
||||
telephony_medium: 'Manual',
|
||||
})
|
||||
const callLog = ref(null)
|
||||
|
||||
const dialogOptions = computed(() => {
|
||||
let title = !editMode.value ? __('New Call Log') : __('Edit Call Log')
|
||||
@ -118,41 +89,28 @@ const tabs = createResource({
|
||||
auto: true,
|
||||
})
|
||||
|
||||
let doc = ref({})
|
||||
|
||||
function updateCallLog() {
|
||||
error.value = null
|
||||
const old = { ...doc.value }
|
||||
const newCallLog = { ..._callLog.value }
|
||||
|
||||
const dirty = JSON.stringify(old) !== JSON.stringify(newCallLog)
|
||||
|
||||
if (!dirty) {
|
||||
show.value = false
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
updateCallLogValues.submit({
|
||||
doctype: 'CRM Call Log',
|
||||
name: _callLog.value.name,
|
||||
fieldname: newCallLog,
|
||||
})
|
||||
}
|
||||
|
||||
const updateCallLogValues = createResource({
|
||||
url: 'frappe.client.set_value',
|
||||
onSuccess(doc) {
|
||||
const callBacks = {
|
||||
onSuccess: (doc) => {
|
||||
loading.value = false
|
||||
if (doc.name) {
|
||||
handleCallLogUpdate(doc)
|
||||
}
|
||||
handleCallLogUpdate(doc)
|
||||
},
|
||||
onError(err) {
|
||||
onError: (err) => {
|
||||
loading.value = false
|
||||
if (err.exc_type == 'MandatoryError') {
|
||||
const errorMessage = err.messages
|
||||
.map((msg) => msg.split(': ')[2].trim())
|
||||
.join(', ')
|
||||
error.value = __('These fields are required: {0}', [errorMessage])
|
||||
return
|
||||
}
|
||||
error.value = err
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function updateCallLog() {
|
||||
loading.value = true
|
||||
await callLog.value.save.submit(null, callBacks)
|
||||
}
|
||||
|
||||
const createCallLog = createResource({
|
||||
url: 'frappe.client.insert',
|
||||
@ -162,7 +120,7 @@ const createCallLog = createResource({
|
||||
doctype: 'CRM Call Log',
|
||||
id: getRandom(6),
|
||||
telephony_medium: 'Manual',
|
||||
..._callLog.value,
|
||||
...callLog.value.doc,
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -174,8 +132,7 @@ const createCallLog = createResource({
|
||||
}
|
||||
},
|
||||
onError(err) {
|
||||
loading.value = false
|
||||
error.value = err
|
||||
callBacks.onError(err)
|
||||
},
|
||||
})
|
||||
|
||||
@ -189,24 +146,22 @@ watch(
|
||||
(value) => {
|
||||
if (!value) return
|
||||
editMode.value = false
|
||||
nextTick(() => {
|
||||
// TODO: Issue with FormControl
|
||||
// title.value.el.focus()
|
||||
doc.value = callLog.value?.data || {}
|
||||
_callLog.value = { ...doc.value }
|
||||
if (_callLog.value.name) {
|
||||
editMode.value = true
|
||||
}
|
||||
})
|
||||
|
||||
let docname = _callLog.value?.name
|
||||
const { document } = useDocument('CRM Call Log', docname)
|
||||
callLog.value = document
|
||||
|
||||
if (docname) {
|
||||
editMode.value = true
|
||||
} else {
|
||||
callLog.value.doc = { ..._callLog.value }
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
quickEntryProps.value = { doctype: 'CRM Call Log' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
<FieldLayout
|
||||
v-if="tabs.data?.length"
|
||||
:tabs="tabs.data"
|
||||
:data="_contact"
|
||||
:data="_contact.doc"
|
||||
doctype="Contact"
|
||||
/>
|
||||
</div>
|
||||
@ -49,9 +49,16 @@ import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import {
|
||||
showQuickEntryModal,
|
||||
quickEntryProps,
|
||||
showAddressModal,
|
||||
addressProps,
|
||||
} from '@/composables/modals'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { capture } from '@/telemetry'
|
||||
import { call, createResource } from 'frappe-ui'
|
||||
import { ref, nextTick, watch } from 'vue'
|
||||
import { ref, nextTick, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
@ -68,8 +75,6 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['openAddressModal'])
|
||||
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const router = useRouter()
|
||||
@ -77,23 +82,27 @@ const show = defineModel()
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
let _contact = ref({})
|
||||
const { document: _contact } = useDocument('Contact')
|
||||
|
||||
if (Object.keys(_contact.doc).length != 0) {
|
||||
_contact.doc = {}
|
||||
}
|
||||
|
||||
async function createContact() {
|
||||
if (_contact.value.email_id) {
|
||||
_contact.value.email_ids = [{ email_id: _contact.value.email_id }]
|
||||
delete _contact.value.email_id
|
||||
if (_contact.doc.email_id) {
|
||||
_contact.doc.email_ids = [{ email_id: _contact.doc.email_id }]
|
||||
delete _contact.doc.email_id
|
||||
}
|
||||
|
||||
if (_contact.value.mobile_no) {
|
||||
_contact.value.phone_nos = [{ phone: _contact.value.mobile_no }]
|
||||
delete _contact.value.mobile_no
|
||||
if (_contact.doc.mobile_no) {
|
||||
_contact.doc.phone_nos = [{ phone: _contact.doc.mobile_no }]
|
||||
delete _contact.doc.mobile_no
|
||||
}
|
||||
|
||||
const doc = await call('frappe.client.insert', {
|
||||
doc: {
|
||||
doctype: 'Contact',
|
||||
..._contact.value,
|
||||
..._contact.doc,
|
||||
},
|
||||
})
|
||||
if (doc.name) {
|
||||
@ -130,17 +139,13 @@ const tabs = createResource({
|
||||
field.read_only = false
|
||||
} else if (field.fieldname == 'address') {
|
||||
field.create = (value, close) => {
|
||||
_contact.value.address = value
|
||||
emit('openAddressModal')
|
||||
show.value = false
|
||||
_contact.doc.address = value
|
||||
openAddressModal()
|
||||
close()
|
||||
}
|
||||
field.edit = (address) => {
|
||||
emit('openAddressModal', address)
|
||||
show.value = false
|
||||
}
|
||||
field.edit = (address) => openAddressModal(address)
|
||||
} else if (field.fieldtype === 'Table') {
|
||||
_contact.value[field.fieldname] = []
|
||||
_contact.doc[field.fieldname] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -149,20 +154,22 @@ const tabs = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
watch(
|
||||
() => show.value,
|
||||
(value) => {
|
||||
if (!value) return
|
||||
nextTick(() => {
|
||||
_contact.value = { ...props.contact.data }
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
const showQuickEntryModal = defineModel('showQuickEntryModal')
|
||||
onMounted(() => {
|
||||
Object.assign(_contact.doc, props.contact.data || props.contact || {})
|
||||
})
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = { doctype: 'Contact' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -48,6 +48,7 @@ import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { FeatherIcon, createResource, ErrorMessage, call } from 'frappe-ui'
|
||||
import { ref, nextTick, watch, computed } from 'vue'
|
||||
|
||||
@ -62,7 +63,7 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['showQuickEntryModal', 'callback'])
|
||||
const emit = defineEmits(['callback'])
|
||||
|
||||
const { isManager } = usersStore()
|
||||
|
||||
@ -139,9 +140,8 @@ watch(
|
||||
)
|
||||
|
||||
function openQuickEntryModal() {
|
||||
emit('showQuickEntryModal', props.doctype)
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = { doctype: props.doctype }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
ref="fieldLayoutRef"
|
||||
v-if="tabs.data?.length"
|
||||
:tabs="tabs.data"
|
||||
:data="deal"
|
||||
:data="deal.doc"
|
||||
doctype="CRM Deal"
|
||||
/>
|
||||
<ErrorMessage class="mt-4" v-if="error" :message="__(error)" />
|
||||
@ -76,9 +76,11 @@ import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { statusesStore } from '@/stores/statuses'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { capture } from '@/telemetry'
|
||||
import { Switch, createResource } from 'frappe-ui'
|
||||
import { computed, ref, reactive, onMounted, nextTick, watch } from 'vue'
|
||||
import { computed, ref, onMounted, nextTick, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
@ -92,24 +94,11 @@ const show = defineModel()
|
||||
const router = useRouter()
|
||||
const error = ref(null)
|
||||
|
||||
const deal = reactive({
|
||||
organization: '',
|
||||
organization_name: '',
|
||||
website: '',
|
||||
no_of_employees: '',
|
||||
territory: '',
|
||||
annual_revenue: '',
|
||||
industry: '',
|
||||
contact: '',
|
||||
salutation: '',
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
email: '',
|
||||
mobile_no: '',
|
||||
gender: '',
|
||||
status: '',
|
||||
deal_owner: '',
|
||||
})
|
||||
const { document: deal } = useDocument('CRM Deal')
|
||||
|
||||
if (Object.keys(deal.doc).length != 0) {
|
||||
deal.doc = {}
|
||||
}
|
||||
|
||||
const hasOrganizationSections = ref(true)
|
||||
const hasContactSections = ref(true)
|
||||
@ -165,11 +154,11 @@ const tabs = createResource({
|
||||
if (field.fieldname == 'status') {
|
||||
field.fieldtype = 'Select'
|
||||
field.options = dealStatuses.value
|
||||
field.prefix = getDealStatus(deal.status).color
|
||||
field.prefix = getDealStatus(deal.doc.status).color
|
||||
}
|
||||
|
||||
if (field.fieldtype === 'Table') {
|
||||
deal[field.fieldname] = []
|
||||
deal.doc[field.fieldname] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -180,46 +169,49 @@ const tabs = createResource({
|
||||
|
||||
const dealStatuses = computed(() => {
|
||||
let statuses = statusOptions('deal')
|
||||
if (!deal.status) {
|
||||
deal.status = statuses[0].value
|
||||
if (!deal.doc.status) {
|
||||
deal.doc.status = statuses[0].value
|
||||
}
|
||||
return statuses
|
||||
})
|
||||
|
||||
function createDeal() {
|
||||
if (deal.website && !deal.website.startsWith('http')) {
|
||||
deal.website = 'https://' + deal.website
|
||||
if (deal.doc.website && !deal.doc.website.startsWith('http')) {
|
||||
deal.doc.website = 'https://' + deal.doc.website
|
||||
}
|
||||
if (chooseExistingContact.value) {
|
||||
deal['first_name'] = null
|
||||
deal['last_name'] = null
|
||||
deal['email'] = null
|
||||
deal['mobile_no'] = null
|
||||
} else deal['contact'] = null
|
||||
deal.doc['first_name'] = null
|
||||
deal.doc['last_name'] = null
|
||||
deal.doc['email'] = null
|
||||
deal.doc['mobile_no'] = null
|
||||
} else deal.doc['contact'] = null
|
||||
|
||||
createResource({
|
||||
url: 'crm.fcrm.doctype.crm_deal.crm_deal.create_deal',
|
||||
params: { args: deal },
|
||||
params: { args: deal.doc },
|
||||
auto: true,
|
||||
validate() {
|
||||
error.value = null
|
||||
if (deal.annual_revenue) {
|
||||
if (typeof deal.annual_revenue === 'string') {
|
||||
deal.annual_revenue = deal.annual_revenue.replace(/,/g, '')
|
||||
} else if (isNaN(deal.annual_revenue)) {
|
||||
if (deal.doc.annual_revenue) {
|
||||
if (typeof deal.doc.annual_revenue === 'string') {
|
||||
deal.doc.annual_revenue = deal.doc.annual_revenue.replace(/,/g, '')
|
||||
} else if (isNaN(deal.doc.annual_revenue)) {
|
||||
error.value = __('Annual Revenue should be a number')
|
||||
return error.value
|
||||
}
|
||||
}
|
||||
if (deal.mobile_no && isNaN(deal.mobile_no.replace(/[-+() ]/g, ''))) {
|
||||
if (
|
||||
deal.doc.mobile_no &&
|
||||
isNaN(deal.doc.mobile_no.replace(/[-+() ]/g, ''))
|
||||
) {
|
||||
error.value = __('Mobile No should be a number')
|
||||
return error.value
|
||||
}
|
||||
if (deal.email && !deal.email.includes('@')) {
|
||||
if (deal.doc.email && !deal.doc.email.includes('@')) {
|
||||
error.value = __('Invalid Email')
|
||||
return error.value
|
||||
}
|
||||
if (!deal.status) {
|
||||
if (!deal.doc.status) {
|
||||
error.value = __('Status is required')
|
||||
return error.value
|
||||
}
|
||||
@ -242,22 +234,19 @@ function createDeal() {
|
||||
})
|
||||
}
|
||||
|
||||
const showQuickEntryModal = defineModel('quickEntry')
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
quickEntryProps.value = { doctype: 'CRM Deal' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
Object.assign(deal, props.defaults)
|
||||
if (!deal.deal_owner) {
|
||||
deal.deal_owner = getUser().name
|
||||
Object.assign(deal.doc, props.defaults)
|
||||
if (!deal.doc.deal_owner) {
|
||||
deal.doc.deal_owner = getUser().name
|
||||
}
|
||||
if (!deal.status && dealStatuses.value[0].value) {
|
||||
deal.status = dealStatuses.value[0].value
|
||||
if (!deal.doc.status && dealStatuses.value[0].value) {
|
||||
deal.doc.status = dealStatuses.value[0].value
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -4,19 +4,24 @@
|
||||
v-model="showCreateDocumentModal"
|
||||
:doctype="createDocumentDoctype"
|
||||
:data="createDocumentData"
|
||||
@showQuickEntryModal="(dt) => openQuickEntryModal(dt)"
|
||||
@callback="(data) => createDocumentCallback(data)"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
:doctype="quickEntryDoctype"
|
||||
v-bind="quickEntryProps"
|
||||
/>
|
||||
<AddressModal
|
||||
v-if="showAddressModal"
|
||||
v-model="showAddressModal"
|
||||
v-bind="addressProps"
|
||||
/>
|
||||
<AboutModal v-model="showAboutModal" />
|
||||
</template>
|
||||
<script setup>
|
||||
import CreateDocumentModal from '@/components/Modals/CreateDocumentModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import AboutModal from '@/components/Modals/AboutModal.vue'
|
||||
import {
|
||||
showCreateDocumentModal,
|
||||
@ -24,14 +29,11 @@ import {
|
||||
createDocumentData,
|
||||
createDocumentCallback,
|
||||
} from '@/composables/document'
|
||||
import { showAboutModal } from '@/composables/settings'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const showQuickEntryModal = ref(false)
|
||||
const quickEntryDoctype = ref('')
|
||||
|
||||
function openQuickEntryModal(dt) {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryDoctype.value = dt
|
||||
}
|
||||
import {
|
||||
showQuickEntryModal,
|
||||
quickEntryProps,
|
||||
showAddressModal,
|
||||
addressProps,
|
||||
showAboutModal
|
||||
} from '@/composables/modals'
|
||||
</script>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<FieldLayout v-if="tabs.data" :tabs="tabs.data" :data="lead" />
|
||||
<FieldLayout v-if="tabs.data" :tabs="tabs.data" :data="lead.doc" />
|
||||
<ErrorMessage class="mt-4" v-if="error" :message="__(error)" />
|
||||
</div>
|
||||
</div>
|
||||
@ -48,10 +48,12 @@ import { usersStore } from '@/stores/users'
|
||||
import { statusesStore } from '@/stores/statuses'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { capture } from '@/telemetry'
|
||||
import { createResource } from 'frappe-ui'
|
||||
import { useOnboarding } from 'frappe-ui/frappe'
|
||||
import { computed, onMounted, ref, reactive, nextTick } from 'vue'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { computed, onMounted, ref, nextTick } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
@ -68,6 +70,20 @@ const router = useRouter()
|
||||
const error = ref(null)
|
||||
const isLeadCreating = ref(false)
|
||||
|
||||
const { document: lead } = useDocument('CRM Lead')
|
||||
|
||||
if (Object.keys(lead.doc).length != 0) {
|
||||
lead.doc = {}
|
||||
}
|
||||
|
||||
const leadStatuses = computed(() => {
|
||||
let statuses = statusOptions('lead')
|
||||
if (!lead.doc.status) {
|
||||
lead.doc.status = statuses?.[0]?.value
|
||||
}
|
||||
return statuses
|
||||
})
|
||||
|
||||
const tabs = createResource({
|
||||
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_fields_layout',
|
||||
cache: ['QuickEntry', 'CRM Lead'],
|
||||
@ -81,11 +97,11 @@ const tabs = createResource({
|
||||
if (field.fieldname == 'status') {
|
||||
field.fieldtype = 'Select'
|
||||
field.options = leadStatuses.value
|
||||
field.prefix = getLeadStatus(lead.status).color
|
||||
field.prefix = getLeadStatus(lead.doc.status).color
|
||||
}
|
||||
|
||||
if (field.fieldtype === 'Table') {
|
||||
lead[field.fieldname] = []
|
||||
lead.doc[field.fieldname] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -94,23 +110,6 @@ const tabs = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
const lead = reactive({
|
||||
salutation: '',
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
email: '',
|
||||
mobile_no: '',
|
||||
gender: '',
|
||||
organization: '',
|
||||
website: '',
|
||||
no_of_employees: '',
|
||||
territory: '',
|
||||
annual_revenue: '',
|
||||
industry: '',
|
||||
status: '',
|
||||
lead_owner: '',
|
||||
})
|
||||
|
||||
const createLead = createResource({
|
||||
url: 'frappe.client.insert',
|
||||
makeParams(values) {
|
||||
@ -123,43 +122,38 @@ const createLead = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
const leadStatuses = computed(() => {
|
||||
let statuses = statusOptions('lead')
|
||||
if (!lead.status) {
|
||||
lead.status = statuses?.[0]?.value
|
||||
}
|
||||
return statuses
|
||||
})
|
||||
|
||||
function createNewLead() {
|
||||
if (lead.website && !lead.website.startsWith('http')) {
|
||||
lead.website = 'https://' + lead.website
|
||||
if (lead.doc.website && !lead.doc.website.startsWith('http')) {
|
||||
lead.doc.website = 'https://' + lead.doc.website
|
||||
}
|
||||
|
||||
createLead.submit(lead, {
|
||||
createLead.submit(lead.doc, {
|
||||
validate() {
|
||||
error.value = null
|
||||
if (!lead.first_name) {
|
||||
if (!lead.doc.first_name) {
|
||||
error.value = __('First Name is mandatory')
|
||||
return error.value
|
||||
}
|
||||
if (lead.annual_revenue) {
|
||||
if (typeof lead.annual_revenue === 'string') {
|
||||
lead.annual_revenue = lead.annual_revenue.replace(/,/g, '')
|
||||
} else if (isNaN(lead.annual_revenue)) {
|
||||
if (lead.doc.annual_revenue) {
|
||||
if (typeof lead.doc.annual_revenue === 'string') {
|
||||
lead.doc.annual_revenue = lead.doc.annual_revenue.replace(/,/g, '')
|
||||
} else if (isNaN(lead.doc.annual_revenue)) {
|
||||
error.value = __('Annual Revenue should be a number')
|
||||
return error.value
|
||||
}
|
||||
}
|
||||
if (lead.mobile_no && isNaN(lead.mobile_no.replace(/[-+() ]/g, ''))) {
|
||||
if (
|
||||
lead.doc.mobile_no &&
|
||||
isNaN(lead.doc.mobile_no.replace(/[-+() ]/g, ''))
|
||||
) {
|
||||
error.value = __('Mobile No should be a number')
|
||||
return error.value
|
||||
}
|
||||
if (lead.email && !lead.email.includes('@')) {
|
||||
if (lead.doc.email && !lead.doc.email.includes('@')) {
|
||||
error.value = __('Invalid Email')
|
||||
return error.value
|
||||
}
|
||||
if (!lead.status) {
|
||||
if (!lead.doc.status) {
|
||||
error.value = __('Status is required')
|
||||
return error.value
|
||||
}
|
||||
@ -185,22 +179,19 @@ function createNewLead() {
|
||||
})
|
||||
}
|
||||
|
||||
const showQuickEntryModal = defineModel('quickEntry')
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
nextTick(() => {
|
||||
show.value = false
|
||||
})
|
||||
quickEntryProps.value = { doctype: 'CRM Lead' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
Object.assign(lead, props.defaults)
|
||||
if (!lead.lead_owner) {
|
||||
lead.lead_owner = getUser().name
|
||||
Object.assign(lead.doc, props.defaults)
|
||||
if (!lead.doc?.lead_owner) {
|
||||
lead.doc.lead_owner = getUser().name
|
||||
}
|
||||
if (!lead.status && leadStatuses.value[0]?.value) {
|
||||
lead.status = leadStatuses.value[0].value
|
||||
if (!lead.doc?.status && leadStatuses.value[0]?.value) {
|
||||
lead.doc.status = leadStatuses.value[0].value
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -1,34 +1,25 @@
|
||||
<template>
|
||||
<Dialog
|
||||
v-model="show"
|
||||
:options="{
|
||||
size: 'xl',
|
||||
actions: [
|
||||
{
|
||||
label: editMode ? __('Update') : __('Create'),
|
||||
variant: 'solid',
|
||||
onClick: () => updateNote(),
|
||||
},
|
||||
],
|
||||
}"
|
||||
>
|
||||
<Dialog v-model="show" :options="{
|
||||
size: 'xl',
|
||||
actions: [
|
||||
{
|
||||
label: editMode ? __('Update') : __('Create'),
|
||||
variant: 'solid',
|
||||
onClick: () => updateNote(),
|
||||
},
|
||||
],
|
||||
}">
|
||||
<template #body-title>
|
||||
<div class="flex items-center gap-3">
|
||||
<h3 class="text-2xl font-semibold leading-6 text-ink-gray-9">
|
||||
{{ editMode ? __('Edit Note') : __('Create Note') }}
|
||||
</h3>
|
||||
<Button
|
||||
v-if="_note?.reference_docname"
|
||||
size="sm"
|
||||
:label="
|
||||
_note.reference_doctype == 'CRM Deal'
|
||||
? __('Open Deal')
|
||||
: __('Open Lead')
|
||||
"
|
||||
@click="redirect()"
|
||||
>
|
||||
<Button v-if="_note?.reference_docname" size="sm" :label="_note.reference_doctype == 'CRM Deal'
|
||||
? __('Open Deal')
|
||||
: __('Open Lead')
|
||||
" @click="redirect()">
|
||||
<template #suffix>
|
||||
<ArrowUpRightIcon class="h-4 w-4" />
|
||||
<ArrowUpRightIcon class="w-4 h-4" />
|
||||
</template>
|
||||
</Button>
|
||||
</div>
|
||||
@ -36,27 +27,17 @@
|
||||
<template #body-content>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div>
|
||||
<FormControl
|
||||
ref="title"
|
||||
:label="__('Title')"
|
||||
v-model="_note.title"
|
||||
:placeholder="__('Call with John Doe')"
|
||||
/>
|
||||
<FormControl ref="title" :label="__('Title')" v-model="_note.title" :placeholder="__('Call with John Doe')"
|
||||
required />
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-1.5 text-xs text-ink-gray-5">{{ __('Content') }}</div>
|
||||
<TextEditor
|
||||
variant="outline"
|
||||
ref="content"
|
||||
<TextEditor variant="outline" ref="content"
|
||||
editor-class="!prose-sm overflow-auto min-h-[180px] max-h-80 py-1.5 px-2 rounded border border-[--surface-gray-2] bg-surface-gray-2 placeholder-ink-gray-4 hover:border-outline-gray-modals hover:bg-surface-gray-3 hover:shadow-sm focus:bg-surface-white focus:border-outline-gray-4 focus:shadow-sm focus:ring-0 focus-visible:ring-2 focus-visible:ring-outline-gray-3 text-ink-gray-8 transition-colors"
|
||||
:bubbleMenu="true"
|
||||
:content="_note.content"
|
||||
@change="(val) => (_note.content = val)"
|
||||
:placeholder="
|
||||
__('Took a call with John Doe and discussed the new project.')
|
||||
"
|
||||
/>
|
||||
:bubbleMenu="true" :content="_note.content" @change="(val) => (_note.content = val)" :placeholder="__('Took a call with John Doe and discussed the new project.')
|
||||
" />
|
||||
</div>
|
||||
<ErrorMessage class="mt-4" v-if="error" :message="__(error)" />
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
@ -94,17 +75,12 @@ const router = useRouter()
|
||||
|
||||
const { updateOnboardingStep } = useOnboarding('frappecrm')
|
||||
|
||||
const error = ref(null)
|
||||
const title = ref(null)
|
||||
const editMode = ref(false)
|
||||
let _note = ref({})
|
||||
|
||||
async function updateNote() {
|
||||
if (
|
||||
props.note.title === _note.value.title &&
|
||||
props.note.content === _note.value.content
|
||||
)
|
||||
return
|
||||
|
||||
if (_note.value.name) {
|
||||
let d = await call('frappe.client.set_value', {
|
||||
doctype: 'FCRM Note',
|
||||
@ -124,6 +100,12 @@ async function updateNote() {
|
||||
reference_doctype: props.doctype,
|
||||
reference_docname: props.doc || '',
|
||||
},
|
||||
}, {
|
||||
onError: (err) => {
|
||||
if (err.error.exc_type == 'MandatoryError') {
|
||||
error.value = "Title is mandatory"
|
||||
}
|
||||
}
|
||||
})
|
||||
if (d.name) {
|
||||
updateOnboardingStep('create_first_note')
|
||||
|
||||
@ -1,43 +1,28 @@
|
||||
<template>
|
||||
<Dialog v-model="show" :options="{ size: 'xl' }">
|
||||
<template #body>
|
||||
<div class="bg-surface-modal px-4 pb-6 pt-5 sm:px-6">
|
||||
<div class="mb-5 flex items-center justify-between">
|
||||
<div class="px-4 pt-5 pb-6 bg-surface-modal sm:px-6">
|
||||
<div class="flex items-center justify-between mb-5">
|
||||
<div>
|
||||
<h3 class="text-2xl font-semibold leading-6 text-ink-gray-9">
|
||||
{{ __('New Organization') }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<Button
|
||||
v-if="isManager() && !isMobileView"
|
||||
variant="ghost"
|
||||
class="w-7"
|
||||
@click="openQuickEntryModal"
|
||||
>
|
||||
<EditIcon class="h-4 w-4" />
|
||||
<Button v-if="isManager() && !isMobileView" variant="ghost" class="w-7" @click="openQuickEntryModal">
|
||||
<EditIcon class="w-4 h-4" />
|
||||
</Button>
|
||||
<Button variant="ghost" class="w-7" @click="show = false">
|
||||
<FeatherIcon name="x" class="h-4 w-4" />
|
||||
<FeatherIcon name="x" class="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<FieldLayout
|
||||
v-if="tabs.data?.length"
|
||||
:tabs="tabs.data"
|
||||
:data="_organization"
|
||||
doctype="CRM Organization"
|
||||
/>
|
||||
<FieldLayout v-if="tabs.data?.length" :tabs="tabs.data" :data="_organization" doctype="CRM Organization" />
|
||||
<ErrorMessage class="mt-8" v-if="error" :message="__(error)" />
|
||||
</div>
|
||||
<div class="px-4 pb-7 pt-4 sm:px-6">
|
||||
<div class="px-4 pt-4 pb-7 sm:px-6">
|
||||
<div class="space-y-2">
|
||||
<Button
|
||||
class="w-full"
|
||||
variant="solid"
|
||||
:label="__('Create')"
|
||||
:loading="loading"
|
||||
@click="createOrganization"
|
||||
/>
|
||||
<Button class="w-full" variant="solid" :label="__('Create')" :loading="loading" @click="createOrganization" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -49,9 +34,16 @@ import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { isMobileView } from '@/composables/settings'
|
||||
import {
|
||||
showQuickEntryModal,
|
||||
quickEntryProps,
|
||||
showAddressModal,
|
||||
addressProps,
|
||||
} from '@/composables/modals'
|
||||
import { useDocument } from '@/data/document'
|
||||
import { capture } from '@/telemetry'
|
||||
import { call, FeatherIcon, createResource } from 'frappe-ui'
|
||||
import { ref, nextTick, watch } from 'vue'
|
||||
import { ref, nextTick, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
@ -59,13 +51,11 @@ const props = defineProps({
|
||||
type: Object,
|
||||
default: {
|
||||
redirect: true,
|
||||
afterInsert: () => {},
|
||||
afterInsert: () => { },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['openAddressModal'])
|
||||
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const router = useRouter()
|
||||
@ -75,23 +65,32 @@ const organization = defineModel('organization')
|
||||
const loading = ref(false)
|
||||
const title = ref(null)
|
||||
|
||||
let _organization = ref({
|
||||
organization_name: '',
|
||||
website: '',
|
||||
annual_revenue: '',
|
||||
no_of_employees: '1-10',
|
||||
industry: '',
|
||||
})
|
||||
const { document: _organization } = useDocument('CRM Organization')
|
||||
|
||||
if (Object.keys(_organization.doc).length != 0) {
|
||||
_organization.doc = { no_of_employees: '1-10' }
|
||||
}
|
||||
|
||||
let doc = ref({})
|
||||
const error = ref(null)
|
||||
|
||||
async function createOrganization() {
|
||||
const doc = await call('frappe.client.insert', {
|
||||
doc: {
|
||||
doctype: 'CRM Organization',
|
||||
..._organization.value,
|
||||
const doc = await call(
|
||||
'frappe.client.insert',
|
||||
{
|
||||
doc: {
|
||||
doctype: 'CRM Organization',
|
||||
..._organization.doc,
|
||||
},
|
||||
},
|
||||
})
|
||||
{
|
||||
onError: (err) => {
|
||||
if (err.error.exc_type == 'ValidationError') {
|
||||
error.value = err.error?.messages?.[0]
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
loading.value = false
|
||||
if (doc.name) {
|
||||
capture('organization_created')
|
||||
@ -124,17 +123,13 @@ const tabs = createResource({
|
||||
column.fields.forEach((field) => {
|
||||
if (field.fieldname == 'address') {
|
||||
field.create = (value, close) => {
|
||||
_organization.value.address = value
|
||||
emit('openAddressModal')
|
||||
show.value = false
|
||||
_organization.doc.address = value
|
||||
openAddressModal()
|
||||
close()
|
||||
}
|
||||
field.edit = (address) => {
|
||||
emit('openAddressModal', address)
|
||||
show.value = false
|
||||
}
|
||||
field.edit = (address) => openAddressModal(address)
|
||||
} else if (field.fieldtype === 'Table') {
|
||||
_organization.value[field.fieldname] = []
|
||||
_organization.doc[field.fieldname] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -143,23 +138,25 @@ const tabs = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
watch(
|
||||
() => show.value,
|
||||
(value) => {
|
||||
if (!value) return
|
||||
nextTick(() => {
|
||||
// TODO: Issue with FormControl
|
||||
// title.value.el.focus()
|
||||
doc.value = organization.value?.doc || organization.value || {}
|
||||
_organization.value = { ...doc.value }
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
const showQuickEntryModal = defineModel('showQuickEntryModal')
|
||||
onMounted(() => {
|
||||
Object.assign(
|
||||
_organization.doc,
|
||||
organization.value?.doc || organization.value || {},
|
||||
)
|
||||
})
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = { doctype: 'CRM Organization' }
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
nextTick(() => (show.value = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,34 +1,25 @@
|
||||
<template>
|
||||
<Dialog
|
||||
v-model="show"
|
||||
:options="{
|
||||
size: 'xl',
|
||||
actions: [
|
||||
{
|
||||
label: editMode ? __('Update') : __('Create'),
|
||||
variant: 'solid',
|
||||
onClick: () => updateTask(),
|
||||
},
|
||||
],
|
||||
}"
|
||||
>
|
||||
<Dialog v-model="show" :options="{
|
||||
size: 'xl',
|
||||
actions: [
|
||||
{
|
||||
label: editMode ? __('Update') : __('Create'),
|
||||
variant: 'solid',
|
||||
onClick: () => updateTask(),
|
||||
},
|
||||
],
|
||||
}">
|
||||
<template #body-title>
|
||||
<div class="flex items-center gap-3">
|
||||
<h3 class="text-2xl font-semibold leading-6 text-ink-gray-9">
|
||||
{{ editMode ? __('Edit Task') : __('Create Task') }}
|
||||
</h3>
|
||||
<Button
|
||||
v-if="task?.reference_docname"
|
||||
size="sm"
|
||||
:label="
|
||||
task.reference_doctype == 'CRM Deal'
|
||||
? __('Open Deal')
|
||||
: __('Open Lead')
|
||||
"
|
||||
@click="redirect()"
|
||||
>
|
||||
<Button v-if="task?.reference_docname" size="sm" :label="task.reference_doctype == 'CRM Deal'
|
||||
? __('Open Deal')
|
||||
: __('Open Lead')
|
||||
" @click="redirect()">
|
||||
<template #suffix>
|
||||
<ArrowUpRightIcon class="h-4 w-4" />
|
||||
<ArrowUpRightIcon class="w-4 h-4" />
|
||||
</template>
|
||||
</Button>
|
||||
</div>
|
||||
@ -36,74 +27,53 @@
|
||||
<template #body-content>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div>
|
||||
<FormControl
|
||||
ref="title"
|
||||
:label="__('Title')"
|
||||
v-model="_task.title"
|
||||
:placeholder="__('Call with John Doe')"
|
||||
/>
|
||||
<FormControl ref="title" :label="__('Title')" v-model="_task.title" :placeholder="__('Call with John Doe')"
|
||||
required />
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-1.5 text-xs text-ink-gray-5">
|
||||
{{ __('Description') }}
|
||||
</div>
|
||||
<TextEditor
|
||||
variant="outline"
|
||||
ref="description"
|
||||
<TextEditor variant="outline" ref="description"
|
||||
editor-class="!prose-sm overflow-auto min-h-[180px] max-h-80 py-1.5 px-2 rounded border border-[--surface-gray-2] bg-surface-gray-2 placeholder-ink-gray-4 hover:border-outline-gray-modals hover:bg-surface-gray-3 hover:shadow-sm focus:bg-surface-white focus:border-outline-gray-4 focus:shadow-sm focus:ring-0 focus-visible:ring-2 focus-visible:ring-outline-gray-3 text-ink-gray-8 transition-colors"
|
||||
:bubbleMenu="true"
|
||||
:content="_task.description"
|
||||
@change="(val) => (_task.description = val)"
|
||||
:placeholder="
|
||||
__('Took a call with John Doe and discussed the new project.')
|
||||
"
|
||||
/>
|
||||
:bubbleMenu="true" :content="_task.description" @change="(val) => (_task.description = val)" :placeholder="__('Took a call with John Doe and discussed the new project.')
|
||||
" />
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Dropdown :options="taskStatusOptions(updateTaskStatus)">
|
||||
<Button :label="_task.status" class="w-full justify-between">
|
||||
<Button :label="_task.status" class="justify-between w-full">
|
||||
<template #prefix>
|
||||
<TaskStatusIcon :status="_task.status" />
|
||||
</template>
|
||||
</Button>
|
||||
</Dropdown>
|
||||
<Link
|
||||
class="form-control"
|
||||
:value="getUser(_task.assigned_to).full_name"
|
||||
doctype="User"
|
||||
@change="(option) => (_task.assigned_to = option)"
|
||||
:placeholder="__('John Doe')"
|
||||
:hideMe="true"
|
||||
>
|
||||
<template #prefix>
|
||||
<UserAvatar class="mr-2 !h-4 !w-4" :user="_task.assigned_to" />
|
||||
</template>
|
||||
<template #item-prefix="{ option }">
|
||||
<UserAvatar class="mr-2" :user="option.value" size="sm" />
|
||||
</template>
|
||||
<template #item-label="{ option }">
|
||||
<Tooltip :text="option.value">
|
||||
<div class="cursor-pointer text-ink-gray-9">
|
||||
{{ getUser(option.value).full_name }}
|
||||
</div>
|
||||
</Tooltip>
|
||||
</template>
|
||||
<Link class="form-control" :value="getUser(_task.assigned_to).full_name" doctype="User"
|
||||
@change="(option) => (_task.assigned_to = option)" :placeholder="__('John Doe')" :hideMe="true">
|
||||
<template #prefix>
|
||||
<UserAvatar class="mr-2 !h-4 !w-4" :user="_task.assigned_to" />
|
||||
</template>
|
||||
<template #item-prefix="{ option }">
|
||||
<UserAvatar class="mr-2" :user="option.value" size="sm" />
|
||||
</template>
|
||||
<template #item-label="{ option }">
|
||||
<Tooltip :text="option.value">
|
||||
<div class="cursor-pointer text-ink-gray-9">
|
||||
{{ getUser(option.value).full_name }}
|
||||
</div>
|
||||
</Tooltip>
|
||||
</template>
|
||||
</Link>
|
||||
<DateTimePicker
|
||||
class="datepicker w-36"
|
||||
v-model="_task.due_date"
|
||||
:placeholder="__('01/04/2024 11:30 PM')"
|
||||
:formatter="(date) => getFormat(date, '', true, true)"
|
||||
input-class="border-none"
|
||||
/>
|
||||
<DateTimePicker class="datepicker w-36" v-model="_task.due_date" :placeholder="__('01/04/2024 11:30 PM')"
|
||||
:formatter="(date) => getFormat(date, '', true, true)" input-class="border-none" />
|
||||
<Dropdown :options="taskPriorityOptions(updateTaskPriority)">
|
||||
<Button :label="_task.priority" class="w-full justify-between">
|
||||
<Button :label="_task.priority" class="justify-between w-full">
|
||||
<template #prefix>
|
||||
<TaskPriorityIcon :priority="_task.priority" />
|
||||
</template>
|
||||
</Button>
|
||||
</Dropdown>
|
||||
</div>
|
||||
<ErrorMessage class="mt-4" v-if="error" :message="__(error)" />
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
@ -147,6 +117,7 @@ const router = useRouter()
|
||||
const { getUser } = usersStore()
|
||||
const { updateOnboardingStep } = useOnboarding('frappecrm')
|
||||
|
||||
const error = ref(null)
|
||||
const title = ref(null)
|
||||
const editMode = ref(false)
|
||||
const _task = ref({
|
||||
@ -200,6 +171,12 @@ async function updateTask() {
|
||||
reference_docname: props.doc || null,
|
||||
..._task.value,
|
||||
},
|
||||
}, {
|
||||
onError: (err) => {
|
||||
if (err.error.exc_type == 'MandatoryError') {
|
||||
error.value = "Title is mandatory"
|
||||
}
|
||||
}
|
||||
})
|
||||
if (d.name) {
|
||||
updateOnboardingStep('create_first_task')
|
||||
|
||||
@ -55,11 +55,8 @@ import Apps from '@/components/Apps.vue'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import {
|
||||
showSettings,
|
||||
isMobileView,
|
||||
showAboutModal,
|
||||
} from '@/composables/settings'
|
||||
import { showSettings, isMobileView } from '@/composables/settings'
|
||||
import { showAboutModal } from '@/composables/modals'
|
||||
import { confirmLoginToFrappeCloud } from '@/composables/frappecloud'
|
||||
import { Dropdown } from 'frappe-ui'
|
||||
import { theme, toggleTheme } from '@/stores/theme'
|
||||
|
||||
9
frontend/src/composables/modals.js
Normal file
9
frontend/src/composables/modals.js
Normal file
@ -0,0 +1,9 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const showQuickEntryModal = ref(false);
|
||||
export const quickEntryProps = ref({});
|
||||
|
||||
export const showAddressModal = ref(false);
|
||||
export const addressProps = ref({});
|
||||
|
||||
export const showAboutModal = ref(false);
|
||||
@ -42,5 +42,3 @@ export const isMobileView = computed(() => window.innerWidth < 768)
|
||||
|
||||
export const showSettings = ref(false)
|
||||
export const activeSettingsPage = ref('')
|
||||
|
||||
export const showAboutModal = ref(false)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { getScript } from '@/data/script'
|
||||
import { runSequentially } from '@/utils'
|
||||
import { createDocumentResource, toast } from 'frappe-ui'
|
||||
import { reactive } from 'vue'
|
||||
|
||||
const documentsCache = {}
|
||||
const controllersCache = {}
|
||||
@ -10,27 +11,34 @@ export function useDocument(doctype, docname) {
|
||||
|
||||
documentsCache[doctype] = documentsCache[doctype] || {}
|
||||
|
||||
if (!documentsCache[doctype][docname]) {
|
||||
documentsCache[doctype][docname] = createDocumentResource({
|
||||
doctype: doctype,
|
||||
name: docname,
|
||||
onSuccess: async () => await setupFormScript(),
|
||||
setValue: {
|
||||
onSuccess: () => {
|
||||
toast.success(__('Document updated successfully'))
|
||||
if (!documentsCache[doctype][docname || '']) {
|
||||
if (docname) {
|
||||
documentsCache[doctype][docname] = createDocumentResource({
|
||||
doctype: doctype,
|
||||
name: docname,
|
||||
onSuccess: async () => await setupFormScript(),
|
||||
setValue: {
|
||||
onSuccess: () => {
|
||||
toast.success(__('Document updated successfully'))
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(__('Error updating document'))
|
||||
console.error(err)
|
||||
},
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(__('Error updating document'))
|
||||
console.error(err)
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
} else {
|
||||
documentsCache[doctype][''] = reactive({
|
||||
doc: {},
|
||||
})
|
||||
setupFormScript()
|
||||
}
|
||||
}
|
||||
|
||||
async function setupFormScript() {
|
||||
if (
|
||||
controllersCache[doctype] &&
|
||||
typeof controllersCache[doctype][docname] === 'object'
|
||||
typeof controllersCache[doctype][docname || ''] === 'object'
|
||||
) {
|
||||
return
|
||||
}
|
||||
@ -39,9 +47,11 @@ export function useDocument(doctype, docname) {
|
||||
controllersCache[doctype] = {}
|
||||
}
|
||||
|
||||
controllersCache[doctype][docname] = {}
|
||||
controllersCache[doctype][docname || ''] = {}
|
||||
|
||||
const controllersArray = await setupScript(documentsCache[doctype][docname])
|
||||
const controllersArray = await setupScript(
|
||||
documentsCache[doctype][docname || ''],
|
||||
)
|
||||
|
||||
if (!controllersArray || controllersArray.length === 0) return
|
||||
|
||||
@ -53,14 +63,14 @@ export function useDocument(doctype, docname) {
|
||||
}
|
||||
organizedControllers[controllerKey].push(controller)
|
||||
}
|
||||
controllersCache[doctype][docname] = organizedControllers
|
||||
controllersCache[doctype][docname || ''] = organizedControllers
|
||||
}
|
||||
|
||||
function getControllers(row = null) {
|
||||
const _doctype = row?.doctype || doctype
|
||||
const controllerKey = _doctype.replace(/\s+/g, '')
|
||||
|
||||
const docControllers = controllersCache[doctype]?.[docname]
|
||||
const docControllers = controllersCache[doctype]?.[docname || '']
|
||||
|
||||
if (
|
||||
typeof docControllers === 'object' &&
|
||||
@ -86,7 +96,7 @@ export function useDocument(doctype, docname) {
|
||||
this.value = row[fieldname]
|
||||
this.oldValue = getOldValue(fieldname, row)
|
||||
} else {
|
||||
this.value = documentsCache[doctype][docname].doc[fieldname]
|
||||
this.value = documentsCache[doctype][docname || ''].doc[fieldname]
|
||||
this.oldValue = getOldValue(fieldname)
|
||||
}
|
||||
await this[fieldname]?.()
|
||||
@ -151,9 +161,9 @@ export function useDocument(doctype, docname) {
|
||||
}
|
||||
|
||||
function getOldValue(fieldname, row) {
|
||||
if (!documentsCache[doctype][docname]) return ''
|
||||
if (!documentsCache[doctype][docname || '']) return ''
|
||||
|
||||
const document = documentsCache[doctype][docname]
|
||||
const document = documentsCache[doctype][docname || '']
|
||||
const oldDoc = document.originalDoc
|
||||
|
||||
if (row?.name) {
|
||||
@ -166,7 +176,7 @@ export function useDocument(doctype, docname) {
|
||||
}
|
||||
|
||||
return {
|
||||
document: documentsCache[doctype][docname],
|
||||
document: documentsCache[doctype][docname || ''],
|
||||
triggerOnChange,
|
||||
triggerOnRowAdd,
|
||||
triggerOnRowRemove,
|
||||
|
||||
@ -33,7 +33,7 @@ export function getScript(doctype, view = 'Form') {
|
||||
}
|
||||
|
||||
async function setupScript(document, helpers = {}) {
|
||||
await scripts.promise
|
||||
await scripts.list.promise
|
||||
|
||||
let scriptDefs = doctypeScripts[doctype]
|
||||
if (!scriptDefs || Object.keys(scriptDefs).length === 0) return null
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
/>
|
||||
<CallLogModal
|
||||
v-model="showCallLogModal"
|
||||
v-model:callLog="callLog"
|
||||
v-model:callLog="callLog.data"
|
||||
:options="{ afterInsert: () => callLogs.reload() }"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@ -172,7 +172,6 @@
|
||||
:errorTitle="errorTitle"
|
||||
:errorMessage="errorMessage"
|
||||
/>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="_address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -185,8 +184,8 @@ import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
|
||||
import CameraIcon from '@/components/Icons/CameraIcon.vue'
|
||||
import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
||||
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import { formatDate, timeAgo } from '@/utils'
|
||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||
import { getView } from '@/utils/view'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
@ -208,7 +207,6 @@ import {
|
||||
} from 'frappe-ui'
|
||||
import { ref, computed, h } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { errorMessage as _errorMessage } from '../utils'
|
||||
|
||||
const { brand } = getSettings()
|
||||
const { $dialog, makeCall } = globalStore()
|
||||
@ -228,9 +226,7 @@ const props = defineProps({
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const showAddressModal = ref(false)
|
||||
const _contact = ref({})
|
||||
const _address = ref({})
|
||||
|
||||
const errorTitle = ref('')
|
||||
const errorMessage = ref('')
|
||||
@ -493,17 +489,10 @@ function getParsedSections(_sections) {
|
||||
...field,
|
||||
create: (value, close) => {
|
||||
_contact.value.address = value
|
||||
_address.value = {}
|
||||
showAddressModal.value = true
|
||||
openAddressModal()
|
||||
close()
|
||||
},
|
||||
edit: async (addr) => {
|
||||
_address.value = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: addr,
|
||||
})
|
||||
showAddressModal.value = true
|
||||
},
|
||||
edit: (address) => openAddressModal(address),
|
||||
}
|
||||
} else {
|
||||
return field
|
||||
@ -562,18 +551,6 @@ async function deleteOption(doctype, name) {
|
||||
toast.success(__('Contact updated'))
|
||||
}
|
||||
|
||||
async function updateField(fieldname, value) {
|
||||
await call('frappe.client.set_value', {
|
||||
doctype: 'Contact',
|
||||
name: props.contactId,
|
||||
fieldname,
|
||||
value,
|
||||
})
|
||||
toast.success(__('Contact updated'))
|
||||
|
||||
contact.reload()
|
||||
}
|
||||
|
||||
const { getFormattedCurrency } = getMeta('CRM Deal')
|
||||
|
||||
const columns = computed(() => dealColumns)
|
||||
@ -641,4 +618,12 @@ const dealColumns = [
|
||||
width: '8rem',
|
||||
},
|
||||
]
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -63,17 +63,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<ContactModal
|
||||
v-if="showContactModal"
|
||||
v-model="showContactModal"
|
||||
v-model:showQuickEntryModal="showQuickEntryModal"
|
||||
:contact="{}"
|
||||
@openAddressModal="(_address) => openAddressModal(_address)"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="Contact"
|
||||
/>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -82,14 +75,11 @@ import CustomActions from '@/components/CustomActions.vue'
|
||||
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
|
||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||
import ContactModal from '@/components/Modals/ContactModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import ContactsListView from '@/components/ListViews/ContactsListView.vue'
|
||||
import ViewControls from '@/components/ViewControls.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { organizationsStore } from '@/stores/organizations.js'
|
||||
import { formatDate, timeAgo } from '@/utils'
|
||||
import { call } from 'frappe-ui'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||
@ -97,14 +87,11 @@ const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||
const { getOrganization } = organizationsStore()
|
||||
|
||||
const showContactModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
const showAddressModal = ref(false)
|
||||
|
||||
const contactsListView = ref(null)
|
||||
|
||||
// contacts data is loaded in the ViewControls component
|
||||
const contacts = ref({})
|
||||
const address = ref({})
|
||||
const loadMore = ref(1)
|
||||
const triggerResize = ref(1)
|
||||
const updatedPageCount = ref(20)
|
||||
@ -166,15 +153,4 @@ const rows = computed(() => {
|
||||
return _rows
|
||||
})
|
||||
})
|
||||
|
||||
async function openAddressModal(_address) {
|
||||
if (_address) {
|
||||
_address = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: _address,
|
||||
})
|
||||
}
|
||||
showAddressModal.value = true
|
||||
address.value = _address || {}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -280,6 +280,7 @@
|
||||
}"
|
||||
/>
|
||||
<ContactModal
|
||||
v-if="showContactModal"
|
||||
v-model="showContactModal"
|
||||
:contact="_contact"
|
||||
:options="{
|
||||
|
||||
@ -241,7 +241,6 @@
|
||||
<DealModal
|
||||
v-if="showDealModal"
|
||||
v-model="showDealModal"
|
||||
v-model:quickEntry="showQuickEntryModal"
|
||||
:defaults="defaults"
|
||||
/>
|
||||
<NoteModal
|
||||
@ -258,11 +257,6 @@
|
||||
doctype="CRM Deal"
|
||||
:doc="docname"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Deal"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -282,7 +276,6 @@ import KanbanView from '@/components/Kanban/KanbanView.vue'
|
||||
import DealModal from '@/components/Modals/DealModal.vue'
|
||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||
import TaskModal from '@/components/Modals/TaskModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import ViewControls from '@/components/ViewControls.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global'
|
||||
@ -306,7 +299,6 @@ const route = useRoute()
|
||||
|
||||
const dealsListView = ref(null)
|
||||
const showDealModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
const defaults = reactive({})
|
||||
|
||||
|
||||
@ -293,12 +293,6 @@
|
||||
/>
|
||||
</template>
|
||||
</Dialog>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Deal"
|
||||
:onlyRequired="true"
|
||||
/>
|
||||
<FilesUploader
|
||||
v-if="lead.data?.name"
|
||||
v-model="showFilesUploader"
|
||||
@ -339,7 +333,6 @@ import FilesUploader from '@/components/FilesUploader/FilesUploader.vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import FieldLayout from '@/components/FieldLayout/FieldLayout.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import SLASection from '@/components/SLASection.vue'
|
||||
import CustomActions from '@/components/CustomActions.vue'
|
||||
import {
|
||||
@ -348,6 +341,7 @@ import {
|
||||
setupCustomizations,
|
||||
copyToClipboard,
|
||||
} from '@/utils'
|
||||
import { showQuickEntryModal, quickEntryProps } from '@/composables/modals'
|
||||
import { getView } from '@/utils/view'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
@ -709,10 +703,12 @@ const dealTabs = createResource({
|
||||
},
|
||||
})
|
||||
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
function openQuickEntryModal() {
|
||||
showQuickEntryModal.value = true
|
||||
quickEntryProps.value = {
|
||||
doctype: 'CRM Deal',
|
||||
onlyRequired: true,
|
||||
}
|
||||
showConvertToDealModal.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -267,7 +267,6 @@
|
||||
<LeadModal
|
||||
v-if="showLeadModal"
|
||||
v-model="showLeadModal"
|
||||
v-model:quickEntry="showQuickEntryModal"
|
||||
:defaults="defaults"
|
||||
/>
|
||||
<NoteModal
|
||||
@ -284,7 +283,6 @@
|
||||
doctype="CRM Lead"
|
||||
:doc="docname"
|
||||
/>
|
||||
<QuickEntryModal v-if="showQuickEntryModal" v-model="showQuickEntryModal" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -304,7 +302,6 @@ import KanbanView from '@/components/Kanban/KanbanView.vue'
|
||||
import LeadModal from '@/components/Modals/LeadModal.vue'
|
||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||
import TaskModal from '@/components/Modals/TaskModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import ViewControls from '@/components/ViewControls.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global'
|
||||
@ -326,7 +323,6 @@ const route = useRoute()
|
||||
|
||||
const leadsListView = ref(null)
|
||||
const showLeadModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
const defaults = reactive({})
|
||||
|
||||
|
||||
@ -156,7 +156,6 @@
|
||||
</TabPanel>
|
||||
</Tabs>
|
||||
</div>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="_address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -168,9 +167,9 @@ import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
|
||||
import CameraIcon from '@/components/Icons/CameraIcon.vue'
|
||||
import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
||||
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import { formatDate, timeAgo } from '@/utils'
|
||||
import { getView } from '@/utils/view'
|
||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global.js'
|
||||
@ -212,9 +211,7 @@ const props = defineProps({
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const showAddressModal = ref(false)
|
||||
const _contact = ref({})
|
||||
const _address = ref({})
|
||||
|
||||
const contact = createResource({
|
||||
url: 'crm.api.contact.get_contact',
|
||||
@ -467,17 +464,10 @@ function getParsedSections(_sections) {
|
||||
...field,
|
||||
create: (value, close) => {
|
||||
_contact.value.address = value
|
||||
_address.value = {}
|
||||
showAddressModal.value = true
|
||||
openAddressModal()
|
||||
close()
|
||||
},
|
||||
edit: async (addr) => {
|
||||
_address.value = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: addr,
|
||||
})
|
||||
showAddressModal.value = true
|
||||
},
|
||||
edit: (address) => openAddressModal(address),
|
||||
}
|
||||
} else {
|
||||
return field
|
||||
@ -536,18 +526,6 @@ async function deleteOption(doctype, name) {
|
||||
toast.success(__('Contact updated'))
|
||||
}
|
||||
|
||||
async function updateField(fieldname, value) {
|
||||
await call('frappe.client.set_value', {
|
||||
doctype: 'Contact',
|
||||
name: props.contactId,
|
||||
fieldname,
|
||||
value,
|
||||
})
|
||||
toast.success(__('Contact updated'))
|
||||
|
||||
contact.reload()
|
||||
}
|
||||
|
||||
const { getFormattedCurrency } = getMeta('CRM Deal')
|
||||
|
||||
const columns = computed(() => dealColumns)
|
||||
@ -615,4 +593,12 @@ const dealColumns = [
|
||||
width: '8rem',
|
||||
},
|
||||
]
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -222,6 +222,7 @@
|
||||
}"
|
||||
/>
|
||||
<ContactModal
|
||||
v-if="showContactModal"
|
||||
v-model="showContactModal"
|
||||
:contact="_contact"
|
||||
:options="{
|
||||
|
||||
@ -145,20 +145,19 @@
|
||||
</TabPanel>
|
||||
</Tabs>
|
||||
</div>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="_address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import Icon from '@/components/Icon.vue'
|
||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||
import ContactsListView from '@/components/ListViews/ContactsListView.vue'
|
||||
import DetailsIcon from '@/components/Icons/DetailsIcon.vue'
|
||||
import CameraIcon from '@/components/Icons/CameraIcon.vue'
|
||||
import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
||||
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
|
||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global'
|
||||
@ -296,9 +295,7 @@ function openWebsite() {
|
||||
else window.open(organization.doc.website, '_blank')
|
||||
}
|
||||
|
||||
const showAddressModal = ref(false)
|
||||
const _organization = ref({})
|
||||
const _address = ref({})
|
||||
|
||||
const sections = createResource({
|
||||
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_sidepanel_sections',
|
||||
@ -317,17 +314,10 @@ function getParsedSections(_sections) {
|
||||
...field,
|
||||
create: (value, close) => {
|
||||
_organization.value.address = value
|
||||
_address.value = {}
|
||||
showAddressModal.value = true
|
||||
openAddressModal()
|
||||
close()
|
||||
},
|
||||
edit: async (addr) => {
|
||||
_address.value = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: addr,
|
||||
})
|
||||
showAddressModal.value = true
|
||||
},
|
||||
edit: (address) => openAddressModal(address),
|
||||
}
|
||||
} else {
|
||||
return field
|
||||
@ -533,4 +523,12 @@ const contactColumns = [
|
||||
width: '8rem',
|
||||
},
|
||||
]
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -164,12 +164,6 @@
|
||||
:errorTitle="errorTitle"
|
||||
:errorMessage="errorMessage"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Organization"
|
||||
/>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="_address" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -178,14 +172,13 @@ import Resizer from '@/components/Resizer.vue'
|
||||
import SidePanelLayout from '@/components/SidePanelLayout.vue'
|
||||
import Icon from '@/components/Icon.vue'
|
||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import DealsListView from '@/components/ListViews/DealsListView.vue'
|
||||
import ContactsListView from '@/components/ListViews/ContactsListView.vue'
|
||||
import WebsiteIcon from '@/components/Icons/WebsiteIcon.vue'
|
||||
import CameraIcon from '@/components/Icons/CameraIcon.vue'
|
||||
import DealsIcon from '@/components/Icons/DealsIcon.vue'
|
||||
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
|
||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { globalStore } from '@/stores/global'
|
||||
@ -222,7 +215,6 @@ const { getUser } = usersStore()
|
||||
const { $dialog } = globalStore()
|
||||
const { getDealStatus } = statusesStore()
|
||||
const { doctypeMeta } = getMeta('CRM Organization')
|
||||
const showQuickEntryModal = ref(false)
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@ -342,9 +334,7 @@ function openWebsite() {
|
||||
else window.open(organization.doc.website, '_blank')
|
||||
}
|
||||
|
||||
const showAddressModal = ref(false)
|
||||
const _organization = ref({})
|
||||
const _address = ref({})
|
||||
|
||||
const sections = createResource({
|
||||
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_sidepanel_sections',
|
||||
@ -363,17 +353,10 @@ function getParsedSections(_sections) {
|
||||
...field,
|
||||
create: (value, close) => {
|
||||
_organization.value.address = value
|
||||
_address.value = {}
|
||||
showAddressModal.value = true
|
||||
openAddressModal()
|
||||
close()
|
||||
},
|
||||
edit: async (addr) => {
|
||||
_address.value = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: addr,
|
||||
})
|
||||
showAddressModal.value = true
|
||||
},
|
||||
edit: (address) => openAddressModal(address),
|
||||
}
|
||||
} else {
|
||||
return field
|
||||
@ -572,4 +555,12 @@ const contactColumns = [
|
||||
width: '8rem',
|
||||
},
|
||||
]
|
||||
|
||||
function openAddressModal(_address) {
|
||||
showAddressModal.value = true
|
||||
addressProps.value = {
|
||||
doctype: 'Address',
|
||||
address: _address,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -63,16 +63,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<OrganizationModal
|
||||
v-if="showOrganizationModal"
|
||||
v-model="showOrganizationModal"
|
||||
v-model:showQuickEntryModal="showQuickEntryModal"
|
||||
@openAddressModal="(_address) => openAddressModal(_address)"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
v-model="showQuickEntryModal"
|
||||
doctype="CRM Organization"
|
||||
/>
|
||||
<AddressModal v-model="showAddressModal" v-model:address="address" />
|
||||
</template>
|
||||
<script setup>
|
||||
import ViewBreadcrumbs from '@/components/ViewBreadcrumbs.vue'
|
||||
@ -80,8 +73,6 @@ import CustomActions from '@/components/CustomActions.vue'
|
||||
import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue'
|
||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||
import OrganizationModal from '@/components/Modals/OrganizationModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import AddressModal from '@/components/Modals/AddressModal.vue'
|
||||
import OrganizationsListView from '@/components/ListViews/OrganizationsListView.vue'
|
||||
import ViewControls from '@/components/ViewControls.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
@ -94,12 +85,9 @@ const { getFormattedPercent, getFormattedFloat, getFormattedCurrency } =
|
||||
|
||||
const organizationsListView = ref(null)
|
||||
const showOrganizationModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
const showAddressModal = ref(false)
|
||||
|
||||
// organizations data is loaded in the ViewControls component
|
||||
const organizations = ref({})
|
||||
const address = ref({})
|
||||
const loadMore = ref(1)
|
||||
const triggerResize = ref(1)
|
||||
const updatedPageCount = ref(20)
|
||||
@ -162,15 +150,4 @@ const rows = computed(() => {
|
||||
return _rows
|
||||
})
|
||||
})
|
||||
|
||||
async function openAddressModal(_address) {
|
||||
if (_address) {
|
||||
_address = await call('frappe.client.get', {
|
||||
doctype: 'Address',
|
||||
name: _address,
|
||||
})
|
||||
}
|
||||
showAddressModal.value = true
|
||||
address.value = _address || {}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -41,21 +41,14 @@
|
||||
@click="showLeadModal = true"
|
||||
/>
|
||||
</div>
|
||||
<LeadModal
|
||||
v-if="showLeadModal"
|
||||
v-model="showLeadModal"
|
||||
v-model:quickEntry="showQuickEntryModal"
|
||||
/>
|
||||
<QuickEntryModal v-if="showQuickEntryModal" v-model="showQuickEntryModal" />
|
||||
<LeadModal v-if="showLeadModal" v-model="showLeadModal" />
|
||||
</template>
|
||||
<script setup>
|
||||
import AvatarIcon from '@/components/Icons/AvatarIcon.vue'
|
||||
import GoogleIcon from '@/components/Icons/GoogleIcon.vue'
|
||||
import LeadModal from '@/components/Modals/LeadModal.vue'
|
||||
import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
|
||||
import { ref } from 'vue'
|
||||
|
||||
const name = ref('John Doe')
|
||||
const showLeadModal = ref(false)
|
||||
const showQuickEntryModal = ref(false)
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user