refactor: organization modal code refactor
(cherry picked from commit 93629972464163a41063317c4337b77b24aaf166) # Conflicts: # frontend/src/components/Modals/OrganizationModal.vue
This commit is contained in:
parent
e623e0628f
commit
985c538044
@ -17,7 +17,16 @@
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<<<<<<< HEAD
|
||||
<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.doc"
|
||||
doctype="CRM Organization"
|
||||
/>
|
||||
>>>>>>> 9362997 (refactor: organization modal code refactor)
|
||||
<ErrorMessage class="mt-8" v-if="error" :message="__(error)" />
|
||||
</div>
|
||||
<div class="px-4 pt-4 pb-7 sm:px-6">
|
||||
@ -47,6 +56,10 @@ import { ref, nextTick, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
options: {
|
||||
type: Object,
|
||||
default: {
|
||||
@ -60,27 +73,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,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -104,8 +109,6 @@ function handleOrganizationUpdate(doc) {
|
||||
name: 'Organization',
|
||||
params: { organizationId: doc.name },
|
||||
})
|
||||
} else {
|
||||
organization.value?.reload?.()
|
||||
}
|
||||
show.value = false
|
||||
props.options.afterInsert && props.options.afterInsert(doc)
|
||||
@ -123,13 +126,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] = []
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -139,10 +142,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() {
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user