fix: added this.meta

This commit is contained in:
Shariq Ansari 2025-05-07 12:13:56 +05:30
parent 6f04b85663
commit 5fcd447bc8

View File

@ -1,4 +1,5 @@
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { getMeta } from '@/stores/meta'
import { createToast } from '@/utils' import { createToast } from '@/utils'
import { call, createListResource } from 'frappe-ui' import { call, createListResource } from 'frappe-ui'
import { reactive } from 'vue' import { reactive } from 'vue'
@ -79,6 +80,8 @@ export function getScript(doctype, view = 'Form') {
let parentInstance = null let parentInstance = null
let doctypeName = doctype.replace(/\s+/g, '') let doctypeName = doctype.replace(/\s+/g, '')
let { doctypeMeta } = getMeta(doctype)
// if className is not doctype name, then it is a child doctype // if className is not doctype name, then it is a child doctype
let isChildDoctype = className !== doctypeName let isChildDoctype = className !== doctypeName
if (isChildDoctype) { if (isChildDoctype) {
@ -87,6 +90,7 @@ export function getScript(doctype, view = 'Form') {
controllers[className] = setupFormController( controllers[className] = setupFormController(
FormClass, FormClass,
doctypeMeta,
document, document,
parentInstance, parentInstance,
isChildDoctype, isChildDoctype,
@ -102,6 +106,7 @@ export function getScript(doctype, view = 'Form') {
function setupFormController( function setupFormController(
FormClass, FormClass,
meta,
document, document,
parentInstance = null, parentInstance = null,
isChildDoctype = false, isChildDoctype = false,
@ -114,6 +119,14 @@ export function getScript(doctype, view = 'Form') {
} }
} }
instance.getMeta = async (doctype) => {
if (!meta[doctype]) {
await getMeta(doctype)
return meta[doctype]
}
return meta[doctype]
}
if (isChildDoctype) { if (isChildDoctype) {
setupHelperMethods(FormClass, instance, document) setupHelperMethods(FormClass, instance, document)
instance.doc = createDocProxy(document.doc, parentInstance) instance.doc = createDocProxy(document.doc, parentInstance)