Merge pull request #165 from shariquerik/lead-deal-creation-bug

fix: Bug while creating Lead
This commit is contained in:
Shariq Ansari 2024-04-30 21:18:27 +05:30 committed by GitHub
commit c15c738614
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 3 deletions

View File

@ -207,7 +207,7 @@ const sections = computed(() => {
label: 'Status', label: 'Status',
name: 'status', name: 'status',
type: 'select', type: 'select',
options: statusOptions('deal'), options: dealStatuses.value,
prefix: getDealStatus(deal.status).iconColorClass, prefix: getDealStatus(deal.status).iconColorClass,
}, },
{ {
@ -222,6 +222,14 @@ const sections = computed(() => {
return fields return fields
}) })
const dealStatuses = computed(() => {
let statuses = statusOptions('deal')
if (!deal.status) {
deal.status = statuses[0].value
}
return statuses
})
function createDeal() { function createDeal() {
createResource({ createResource({
url: 'crm.fcrm.doctype.crm_deal.crm_deal.create_deal', url: 'crm.fcrm.doctype.crm_deal.crm_deal.create_deal',

View File

@ -12,7 +12,12 @@
</template> </template>
<template #actions> <template #actions>
<div class="flex flex-row-reverse gap-2"> <div class="flex flex-row-reverse gap-2">
<Button variant="solid" :label="__('Save')" @click="createNewLead" /> <Button
variant="solid"
:label="__('Create')"
:loading="isLeadCreating"
@click="createNewLead"
/>
</div> </div>
</template> </template>
</Dialog> </Dialog>
@ -158,7 +163,7 @@ const sections = computed(() => {
label: 'Status', label: 'Status',
name: 'status', name: 'status',
type: 'select', type: 'select',
options: statusOptions('lead'), options: leadStatuses.value,
prefix: getLeadStatus(lead.status).iconColorClass, prefix: getLeadStatus(lead.status).iconColorClass,
}, },
{ {
@ -185,6 +190,14 @@ const createLead = createResource({
}, },
}) })
const leadStatuses = computed(() => {
let statuses = statusOptions('lead')
if (!lead.status) {
lead.status = statuses[0].value
}
return statuses
})
function createNewLead() { function createNewLead() {
createLead.submit(lead, { createLead.submit(lead, {
validate() { validate() {

View File

@ -97,6 +97,7 @@ export const statusesStore = defineStore('crm-statuses', () => {
for (const status in statusesByName) { for (const status in statusesByName) {
options.push({ options.push({
label: statusesByName[status].name, label: statusesByName[status].name,
value: statusesByName[status].name,
icon: () => icon: () =>
h(IndicatorIcon, { h(IndicatorIcon, {
class: statusesByName[status].iconColorClass, class: statusesByName[status].iconColorClass,