fix: set default status in newlead/deal dialog

This commit is contained in:
Shariq Ansari 2023-12-13 21:00:30 +05:30
parent 71bc3d9fb2
commit dd93342601
2 changed files with 160 additions and 140 deletions

View File

@ -8,7 +8,7 @@
v-if="field.type === 'select'" v-if="field.type === 'select'"
type="select" type="select"
:options="field.options" :options="field.options"
v-model="field.value" v-model="newDeal[field.name]"
> >
<template v-if="field.prefix" #prefix> <template v-if="field.prefix" #prefix>
<IndicatorIcon :class="field.prefix" /> <IndicatorIcon :class="field.prefix" />
@ -71,7 +71,7 @@ import OrganizationModal from '@/components/Modals/OrganizationModal.vue'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
import { statusesStore } from '@/stores/statuses' import { statusesStore } from '@/stores/statuses'
import { FormControl, Tooltip } from 'frappe-ui' import { FormControl, Tooltip } from 'frappe-ui'
import { ref } from 'vue' import { computed, onMounted, ref } from 'vue'
const { getUser } = usersStore() const { getUser } = usersStore()
const { getDealStatus, statusOptions } = statusesStore() const { getDealStatus, statusOptions } = statusesStore()
@ -86,7 +86,8 @@ const props = defineProps({
const showOrganizationModal = ref(false) const showOrganizationModal = ref(false)
const _organization = ref({}) const _organization = ref({})
const allFields = [ const allFields = computed(() => {
return [
{ {
section: 'Deal Details', section: 'Deal Details',
fields: [ fields: [
@ -140,8 +141,10 @@ const allFields = [
label: 'Status', label: 'Status',
name: 'status', name: 'status',
type: 'select', type: 'select',
options: statusOptions('deal'), options: statusOptions(
value: props.newDeal.status || getDealStatus(props.newDeal.status).name, 'deal',
(field, value) => (props.newDeal[field] = value)
),
prefix: getDealStatus(props.newDeal.status).iconColorClass, prefix: getDealStatus(props.newDeal.status).iconColorClass,
}, },
{ {
@ -155,4 +158,11 @@ const allFields = [
], ],
}, },
] ]
})
onMounted(() => {
if (!props.newDeal.status) {
props.newDeal.status = getDealStatus(props.newDeal.status).name
}
})
</script> </script>

View File

@ -8,7 +8,7 @@
v-if="field.type === 'select'" v-if="field.type === 'select'"
type="select" type="select"
:options="field.options" :options="field.options"
v-model="field.value" v-model="newLead[field.name]"
> >
<template v-if="field.prefix" #prefix> <template v-if="field.prefix" #prefix>
<IndicatorIcon :class="field.prefix" /> <IndicatorIcon :class="field.prefix" />
@ -71,7 +71,7 @@ import Link from '@/components/Controls/Link.vue'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
import { statusesStore } from '@/stores/statuses' import { statusesStore } from '@/stores/statuses'
import { FormControl, Tooltip } from 'frappe-ui' import { FormControl, Tooltip } from 'frappe-ui'
import { ref } from 'vue' import { computed, onMounted, ref } from 'vue'
const { getUser } = usersStore() const { getUser } = usersStore()
const { getLeadStatus, statusOptions } = statusesStore() const { getLeadStatus, statusOptions } = statusesStore()
@ -86,7 +86,8 @@ const props = defineProps({
const showOrganizationModal = ref(false) const showOrganizationModal = ref(false)
const _organization = ref({}) const _organization = ref({})
const allFields = [ const allFields = computed(() => {
return [
{ {
section: 'Lead Details', section: 'Lead Details',
fields: [ fields: [
@ -140,8 +141,10 @@ const allFields = [
label: 'Status', label: 'Status',
name: 'status', name: 'status',
type: 'select', type: 'select',
options: statusOptions('lead'), options: statusOptions(
value: props.newLead.status || getLeadStatus(props.newLead.status).name, 'lead',
(field, value) => (props.newLead[field] = value)
),
prefix: getLeadStatus(props.newLead.status).iconColorClass, prefix: getLeadStatus(props.newLead.status).iconColorClass,
}, },
{ {
@ -155,4 +158,11 @@ const allFields = [
], ],
}, },
] ]
})
onMounted(() => {
if (!props.newLead.status) {
props.newLead.status = getLeadStatus(props.newLead.status).name
}
})
</script> </script>