Merge pull request #891 from shariquerik/fixes-2

This commit is contained in:
Shariq Ansari 2025-06-05 16:14:38 +05:30 committed by GitHub
commit 9780a6b63e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 50 additions and 62 deletions

View File

@ -320,7 +320,7 @@
{{ startCase(__(activity.type)) }}
</span>
<span
v-if="activity.data.old_value"
v-if="activity.data?.old_value"
class="max-w-xs font-medium text-ink-gray-8"
>
<div
@ -336,7 +336,7 @@
</span>
<span v-if="activity.to">{{ __('to') }}</span>
<span
v-if="activity.data.value"
v-if="activity.data?.value"
class="max-w-xs font-medium text-ink-gray-8"
>
<div

View File

@ -16,8 +16,9 @@
@after="redirect('notes')"
/>
<CallLogModal
v-if="showCallLogModal"
v-model="showCallLogModal"
v-model:callLog="callLog"
:data="callLog"
:options="{ afterInsert: () => activities.reload() }"
/>
</template>

View File

@ -97,7 +97,11 @@
v-model:callLogModal="showCallLogModal"
v-model:callLog="callLog"
/>
<CallLogModal v-model="showCallLogModal" v-model:callLog="callLog.data" />
<CallLogModal
v-if="showCallLogModal"
v-model="showCallLogModal"
:data="callLog.data"
/>
</div>
</template>
<script setup>

View File

@ -58,9 +58,13 @@ import { getRandom } from '@/utils'
import { capture } from '@/telemetry'
import { useDocument } from '@/data/document'
import { FeatherIcon, createResource, ErrorMessage, Badge } from 'frappe-ui'
import { ref, nextTick, watch, computed } from 'vue'
import { ref, nextTick, computed, onMounted } from 'vue'
const props = defineProps({
data: {
type: Object,
default: () => ({}),
},
options: {
type: Object,
default: {
@ -72,14 +76,15 @@ const props = defineProps({
const { isManager } = usersStore()
const show = defineModel()
const _callLog = defineModel('callLog')
const loading = ref(false)
const error = ref(null)
const title = ref(null)
const editMode = ref(false)
const callLog = ref(null)
const { document: callLog } = useDocument(
'CRM Call Log',
props.data?.name || '',
)
const dialogOptions = computed(() => {
let title = !editMode.value ? __('New Call Log') : __('Edit Call Log')
@ -123,7 +128,7 @@ const callBacks = {
async function updateCallLog() {
loading.value = true
await callLog.value.save.submit(null, callBacks)
await callLog.save.submit(null, callBacks)
}
const createCallLog = createResource({
@ -134,7 +139,7 @@ const createCallLog = createResource({
doctype: 'CRM Call Log',
id: getRandom(6),
telephony_medium: 'Manual',
...callLog.value.doc,
...callLog.doc,
},
}
},
@ -155,23 +160,13 @@ function handleCallLogUpdate(doc) {
props.options.afterInsert && props.options.afterInsert(doc)
}
watch(
() => show.value,
(value) => {
if (!value) return
editMode.value = false
onMounted(() => {
editMode.value = props.data?.name ? true : false
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 }
}
},
)
if (!props.data?.name) {
callLog.doc = { ...props.data }
}
})
function openQuickEntryModal() {
showQuickEntryModal.value = true

View File

@ -84,10 +84,6 @@ const loading = ref(false)
const { document: _contact } = useDocument('Contact')
if (Object.keys(_contact.doc).length != 0) {
_contact.doc = {}
}
async function createContact() {
if (_contact.doc.email_id) {
_contact.doc.email_ids = [{ email_id: _contact.doc.email_id }]
@ -155,7 +151,8 @@ const tabs = createResource({
})
onMounted(() => {
Object.assign(_contact.doc, props.contact.data || props.contact || {})
_contact.doc = {}
Object.assign(_contact.doc, props.contact.data || props.contact)
})
function openQuickEntryModal() {

View File

@ -96,10 +96,6 @@ const error = ref(null)
const { document: deal } = useDocument('CRM Deal')
if (Object.keys(deal.doc).length != 0) {
deal.doc = {}
}
const hasOrganizationSections = ref(true)
const hasContactSections = ref(true)
@ -241,7 +237,9 @@ function openQuickEntryModal() {
}
onMounted(() => {
deal.doc = { no_of_employees: '1-10' }
Object.assign(deal.doc, props.defaults)
if (!deal.doc.deal_owner) {
deal.doc.deal_owner = getUser().name
}

View File

@ -72,10 +72,6 @@ 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) {
@ -186,7 +182,9 @@ function openQuickEntryModal() {
}
onMounted(() => {
lead.doc = { no_of_employees: '1-10' }
Object.assign(lead.doc, props.defaults)
if (!lead.doc?.lead_owner) {
lead.doc.lead_owner = getUser().name
}

View File

@ -25,7 +25,7 @@
<FieldLayout
v-if="tabs.data?.length"
:tabs="tabs.data"
:data="_organization.doc"
:data="organization.doc"
doctype="CRM Organization"
/>
<ErrorMessage class="mt-8" v-if="error" :message="__(error)" />
@ -63,6 +63,10 @@ import { ref, nextTick, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({
data: {
type: Object,
default: () => ({}),
},
options: {
type: Object,
default: {
@ -76,27 +80,19 @@ const { isManager } = usersStore()
const router = useRouter()
const show = defineModel()
const organization = defineModel('organization')
const loading = ref(false)
const title = ref(null)
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)
const { document: organization } = useDocument('CRM Organization')
async function createOrganization() {
const doc = await call(
'frappe.client.insert',
{
doc: {
doctype: 'CRM Organization',
..._organization.doc,
...organization.doc,
},
},
{
@ -120,8 +116,6 @@ function handleOrganizationUpdate(doc) {
name: 'Organization',
params: { organizationId: doc.name },
})
} else {
organization.value?.reload?.()
}
show.value = false
props.options.afterInsert && props.options.afterInsert(doc)
@ -139,13 +133,13 @@ const tabs = createResource({
column.fields.forEach((field) => {
if (field.fieldname == 'address') {
field.create = (value, close) => {
_organization.doc.address = value
organization.doc.address = value
openAddressModal()
close()
}
field.edit = (address) => openAddressModal(address)
} else if (field.fieldtype === 'Table') {
_organization.doc[field.fieldname] = []
organization.doc[field.fieldname] = []
}
})
})
@ -155,10 +149,8 @@ const tabs = createResource({
})
onMounted(() => {
Object.assign(
_organization.doc,
organization.value?.doc || organization.value || {},
)
organization.doc = { no_of_employees: '1-10' }
Object.assign(organization.doc, props.data)
})
function openQuickEntryModal() {

View File

@ -62,8 +62,9 @@
v-model:callLog="callLog"
/>
<CallLogModal
v-if="showCallLogModal"
v-model="showCallLogModal"
v-model:callLog="callLog.data"
:data="callLog.data"
:options="{ afterInsert: () => callLogs.reload() }"
/>
</template>

View File

@ -272,8 +272,9 @@
:errorMessage="errorMessage"
/>
<OrganizationModal
v-if="showOrganizationModal"
v-model="showOrganizationModal"
v-model:organization="_organization"
:data="_organization"
:options="{
redirect: false,
afterInsert: (doc) => updateField('organization', doc.name),

View File

@ -214,8 +214,9 @@
</Tabs>
</div>
<OrganizationModal
v-if="showOrganizationModal"
v-model="showOrganizationModal"
v-model:organization="_organization"
:data="_organization"
:options="{
redirect: false,
afterInsert: (doc) => updateField('organization', doc.name),