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"
|
:filters="field.filters"
|
||||||
@change="(v) => fieldChange(v, field, row)"
|
@change="(v) => fieldChange(v, field, row)"
|
||||||
:onCreate="field.create"
|
:onCreate="
|
||||||
|
(value, close) => field.create(v, field, row, close)
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<Link
|
<Link
|
||||||
v-else-if="field.fieldtype === 'User'"
|
v-else-if="field.fieldtype === 'User'"
|
||||||
@ -407,7 +409,12 @@ const allFields = computed(() => {
|
|||||||
function getFieldObj(field) {
|
function getFieldObj(field) {
|
||||||
if (field.fieldtype === 'Link' && field.options !== 'User') {
|
if (field.fieldtype === 'Link' && field.options !== 'User') {
|
||||||
if (!field.create) {
|
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.fieldtype === 'Link' && field.options !== 'User') {
|
||||||
if (!field.create) {
|
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()
|
const { isManager } = usersStore()
|
||||||
|
|
||||||
@ -100,11 +100,11 @@ const tabs = createResource({
|
|||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
async function create(close) {
|
async function create() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
error.value = null
|
error.value = null
|
||||||
|
|
||||||
await call(
|
let doc = await call(
|
||||||
'frappe.client.insert',
|
'frappe.client.insert',
|
||||||
{
|
{
|
||||||
doc: {
|
doc: {
|
||||||
@ -124,6 +124,7 @@ async function create(close) {
|
|||||||
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
show.value = false
|
show.value = false
|
||||||
|
emit('callback', doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
:doctype="createDocumentDoctype"
|
:doctype="createDocumentDoctype"
|
||||||
:data="createDocumentData"
|
:data="createDocumentData"
|
||||||
@showQuickEntryModal="(dt) => openQuickEntryModal(dt)"
|
@showQuickEntryModal="(dt) => openQuickEntryModal(dt)"
|
||||||
|
@callback="(data) => createDocumentCallback(data)"
|
||||||
/>
|
/>
|
||||||
<QuickEntryModal
|
<QuickEntryModal
|
||||||
v-if="showQuickEntryModal"
|
v-if="showQuickEntryModal"
|
||||||
@ -19,6 +20,7 @@ import {
|
|||||||
showCreateDocumentModal,
|
showCreateDocumentModal,
|
||||||
createDocumentDoctype,
|
createDocumentDoctype,
|
||||||
createDocumentData,
|
createDocumentData,
|
||||||
|
createDocumentCallback,
|
||||||
} from '@/composables/document'
|
} from '@/composables/document'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
|||||||
@ -3,12 +3,14 @@ import { ref } from 'vue'
|
|||||||
export const showCreateDocumentModal = ref(false)
|
export const showCreateDocumentModal = ref(false)
|
||||||
export const createDocumentDoctype = ref('')
|
export const createDocumentDoctype = ref('')
|
||||||
export const createDocumentData = 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) {
|
if (doctype) {
|
||||||
close()
|
close?.()
|
||||||
createDocumentDoctype.value = doctype
|
createDocumentDoctype.value = doctype
|
||||||
createDocumentData.value = obj || {}
|
createDocumentData.value = obj || {}
|
||||||
|
createDocumentCallback.value = callback || null
|
||||||
showCreateDocumentModal.value = true
|
showCreateDocumentModal.value = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user