feat: added callback to update link field value after creating new
This commit is contained in:
parent
8f79427720
commit
91ba11b565
@ -126,7 +126,9 @@
|
||||
"
|
||||
:filters="field.filters"
|
||||
@change="(v) => fieldChange(v, field, row)"
|
||||
:onCreate="field.create"
|
||||
:onCreate="
|
||||
(value, close) => field.create(v, field, row, close)
|
||||
"
|
||||
/>
|
||||
<Link
|
||||
v-else-if="field.fieldtype === 'User'"
|
||||
@ -407,7 +409,12 @@ const allFields = computed(() => {
|
||||
function getFieldObj(field) {
|
||||
if (field.fieldtype === 'Link' && field.options !== 'User') {
|
||||
if (!field.create) {
|
||||
field.create = (obj, close) => createDocument(field.options, obj, close)
|
||||
field.create = (value, field, row, close) => {
|
||||
const callback = (d) => {
|
||||
if (d) fieldChange(d.name, field, row)
|
||||
}
|
||||
createDocument(field.options, value, close, callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -275,7 +275,12 @@ const field = computed(() => {
|
||||
|
||||
if (field.fieldtype === 'Link' && field.options !== 'User') {
|
||||
if (!field.create) {
|
||||
field.create = (obj, close) => createDocument(field.options, obj, close)
|
||||
field.create = (value, close) => {
|
||||
const callback = (d) => {
|
||||
if (d) fieldChange(d.name, field)
|
||||
}
|
||||
createDocument(field.options, value, close, callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['showQuickEntryModal'])
|
||||
const emit = defineEmits(['showQuickEntryModal', 'callback'])
|
||||
|
||||
const { isManager } = usersStore()
|
||||
|
||||
@ -100,11 +100,11 @@ const tabs = createResource({
|
||||
auto: true,
|
||||
})
|
||||
|
||||
async function create(close) {
|
||||
async function create() {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
|
||||
await call(
|
||||
let doc = await call(
|
||||
'frappe.client.insert',
|
||||
{
|
||||
doc: {
|
||||
@ -124,6 +124,7 @@ async function create(close) {
|
||||
|
||||
loading.value = false
|
||||
show.value = false
|
||||
emit('callback', doc)
|
||||
}
|
||||
|
||||
watch(
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
:doctype="createDocumentDoctype"
|
||||
:data="createDocumentData"
|
||||
@showQuickEntryModal="(dt) => openQuickEntryModal(dt)"
|
||||
@callback="(data) => createDocumentCallback(data)"
|
||||
/>
|
||||
<QuickEntryModal
|
||||
v-if="showQuickEntryModal"
|
||||
@ -19,6 +20,7 @@ import {
|
||||
showCreateDocumentModal,
|
||||
createDocumentDoctype,
|
||||
createDocumentData,
|
||||
createDocumentCallback,
|
||||
} from '@/composables/document'
|
||||
import { ref } from 'vue'
|
||||
|
||||
|
||||
@ -3,12 +3,14 @@ import { ref } from 'vue'
|
||||
export const showCreateDocumentModal = ref(false)
|
||||
export const createDocumentDoctype = ref('')
|
||||
export const createDocumentData = ref({})
|
||||
export const createDocumentCallback = ref(null)
|
||||
|
||||
export function createDocument(doctype, obj, close) {
|
||||
export function createDocument(doctype, obj, close, callback) {
|
||||
if (doctype) {
|
||||
close()
|
||||
close?.()
|
||||
createDocumentDoctype.value = doctype
|
||||
createDocumentData.value = obj || {}
|
||||
createDocumentCallback.value = callback || null
|
||||
showCreateDocumentModal.value = true
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user