Merge pull request #897 from frappe/mergify/bp/main-hotfix/pr-896
This commit is contained in:
commit
62270a478c
@ -75,6 +75,8 @@ export function useDocument(doctype, docname) {
|
|||||||
organizedControllers[controllerKey].push(controller)
|
organizedControllers[controllerKey].push(controller)
|
||||||
}
|
}
|
||||||
controllersCache[doctype][docname || ''] = organizedControllers
|
controllersCache[doctype][docname || ''] = organizedControllers
|
||||||
|
|
||||||
|
triggerOnload()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getControllers(row = null) {
|
function getControllers(row = null) {
|
||||||
@ -93,9 +95,16 @@ export function useDocument(doctype, docname) {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function triggerOnload() {
|
||||||
|
const handler = async function () {
|
||||||
|
await this.onload?.()
|
||||||
|
}
|
||||||
|
await trigger(handler)
|
||||||
|
}
|
||||||
|
|
||||||
async function triggerOnRefresh() {
|
async function triggerOnRefresh() {
|
||||||
const handler = async function () {
|
const handler = async function () {
|
||||||
await this.refresh()
|
await this.refresh?.()
|
||||||
}
|
}
|
||||||
await trigger(handler)
|
await trigger(handler)
|
||||||
}
|
}
|
||||||
@ -189,6 +198,8 @@ export function useDocument(doctype, docname) {
|
|||||||
return {
|
return {
|
||||||
document: documentsCache[doctype][docname || ''],
|
document: documentsCache[doctype][docname || ''],
|
||||||
assignees,
|
assignees,
|
||||||
|
getControllers,
|
||||||
|
triggerOnload,
|
||||||
triggerOnChange,
|
triggerOnChange,
|
||||||
triggerOnRowAdd,
|
triggerOnRowAdd,
|
||||||
triggerOnRowRemove,
|
triggerOnRowRemove,
|
||||||
|
|||||||
@ -116,8 +116,13 @@ export function getScript(doctype, view = 'Form') {
|
|||||||
parentInstance = null,
|
parentInstance = null,
|
||||||
isChildDoctype = false,
|
isChildDoctype = false,
|
||||||
) {
|
) {
|
||||||
|
document.actions = document.actions || []
|
||||||
|
document.statuses = document.statuses || []
|
||||||
|
|
||||||
let instance = new FormClass()
|
let instance = new FormClass()
|
||||||
|
|
||||||
|
// Store the original document context to be used by properties like 'actions'
|
||||||
|
instance._originalDocumentContext = document
|
||||||
instance._isChildDoctype = isChildDoctype
|
instance._isChildDoctype = isChildDoctype
|
||||||
|
|
||||||
for (const key in document) {
|
for (const key in document) {
|
||||||
@ -199,6 +204,76 @@ export function getScript(doctype, view = 'Form') {
|
|||||||
return createDocProxy(row, this)
|
return createDocProxy(row, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(FormClass.prototype, 'actions')) {
|
||||||
|
Object.defineProperty(FormClass.prototype, 'actions', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get() {
|
||||||
|
if (!this._originalDocumentContext) {
|
||||||
|
console.warn(
|
||||||
|
'CRM Script: _originalDocumentContext not found on instance for actions getter.',
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._originalDocumentContext.actions
|
||||||
|
},
|
||||||
|
set(newValue) {
|
||||||
|
if (!this._originalDocumentContext) {
|
||||||
|
console.warn(
|
||||||
|
'CRM Script: _originalDocumentContext not found on instance for actions setter.',
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!Array.isArray(newValue)) {
|
||||||
|
console.warn(
|
||||||
|
'CRM Script: "actions" property must be an array. Value was not set.',
|
||||||
|
newValue,
|
||||||
|
)
|
||||||
|
this._originalDocumentContext.actions = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this._originalDocumentContext.actions = newValue
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!Object.prototype.hasOwnProperty.call(FormClass.prototype, 'statuses')
|
||||||
|
) {
|
||||||
|
Object.defineProperty(FormClass.prototype, 'statuses', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get() {
|
||||||
|
if (!this._originalDocumentContext) {
|
||||||
|
console.warn(
|
||||||
|
'CRM Script: _originalDocumentContext not found on instance for statuses getter.',
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._originalDocumentContext.statuses
|
||||||
|
},
|
||||||
|
set(newValue) {
|
||||||
|
if (!this._originalDocumentContext) {
|
||||||
|
console.warn(
|
||||||
|
'CRM Script: _originalDocumentContext not found on instance for statuses setter.',
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!Array.isArray(newValue)) {
|
||||||
|
console.warn(
|
||||||
|
'CRM Script: "statuses" property must be an array. Value was not set.',
|
||||||
|
newValue,
|
||||||
|
)
|
||||||
|
this._originalDocumentContext.statuses = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this._originalDocumentContext.statuses = newValue
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility function to setup a form controller
|
// utility function to setup a form controller
|
||||||
|
|||||||
@ -12,13 +12,25 @@
|
|||||||
v-if="deal.data._customActions?.length"
|
v-if="deal.data._customActions?.length"
|
||||||
:actions="deal.data._customActions"
|
:actions="deal.data._customActions"
|
||||||
/>
|
/>
|
||||||
|
<CustomActions
|
||||||
|
v-if="document.actions?.length"
|
||||||
|
:actions="document.actions"
|
||||||
|
/>
|
||||||
<AssignTo
|
<AssignTo
|
||||||
v-model="assignees.data"
|
v-model="assignees.data"
|
||||||
:data="document.doc"
|
:data="document.doc"
|
||||||
doctype="CRM Deal"
|
doctype="CRM Deal"
|
||||||
/>
|
/>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
:options="statusOptions('deal', updateField, deal.data._customStatuses)"
|
:options="
|
||||||
|
statusOptions(
|
||||||
|
'deal',
|
||||||
|
updateField,
|
||||||
|
document.statuses?.length
|
||||||
|
? document.statuses
|
||||||
|
: deal.data._customStatuses,
|
||||||
|
)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template #default="{ open }">
|
<template #default="{ open }">
|
||||||
<Button :label="deal.data.status">
|
<Button :label="deal.data.status">
|
||||||
|
|||||||
@ -12,13 +12,25 @@
|
|||||||
v-if="lead.data._customActions?.length"
|
v-if="lead.data._customActions?.length"
|
||||||
:actions="lead.data._customActions"
|
:actions="lead.data._customActions"
|
||||||
/>
|
/>
|
||||||
|
<CustomActions
|
||||||
|
v-if="document.actions?.length"
|
||||||
|
:actions="document.actions"
|
||||||
|
/>
|
||||||
<AssignTo
|
<AssignTo
|
||||||
v-model="assignees.data"
|
v-model="assignees.data"
|
||||||
:data="document.doc"
|
:data="document.doc"
|
||||||
doctype="CRM Lead"
|
doctype="CRM Lead"
|
||||||
/>
|
/>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
:options="statusOptions('lead', updateField, lead.data._customStatuses)"
|
:options="
|
||||||
|
statusOptions(
|
||||||
|
'lead',
|
||||||
|
updateField,
|
||||||
|
document.statuses?.length
|
||||||
|
? document.statuses
|
||||||
|
: lead.data._customStatuses,
|
||||||
|
)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template #default="{ open }">
|
<template #default="{ open }">
|
||||||
<Button :label="lead.data.status">
|
<Button :label="lead.data.status">
|
||||||
|
|||||||
@ -11,7 +11,13 @@
|
|||||||
<div class="absolute right-0">
|
<div class="absolute right-0">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
:options="
|
:options="
|
||||||
statusOptions('deal', updateField, deal.data._customStatuses)
|
statusOptions(
|
||||||
|
'deal',
|
||||||
|
updateField,
|
||||||
|
document.statuses?.length
|
||||||
|
? document.statuses
|
||||||
|
: deal.data._customStatuses,
|
||||||
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template #default="{ open }">
|
<template #default="{ open }">
|
||||||
@ -45,6 +51,10 @@
|
|||||||
v-if="deal.data._customActions?.length"
|
v-if="deal.data._customActions?.length"
|
||||||
:actions="deal.data._customActions"
|
:actions="deal.data._customActions"
|
||||||
/>
|
/>
|
||||||
|
<CustomActions
|
||||||
|
v-if="document.actions?.length"
|
||||||
|
:actions="document.actions"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="deal.data" class="flex h-full overflow-hidden">
|
<div v-if="deal.data" class="flex h-full overflow-hidden">
|
||||||
|
|||||||
@ -11,7 +11,13 @@
|
|||||||
<div class="absolute right-0">
|
<div class="absolute right-0">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
:options="
|
:options="
|
||||||
statusOptions('lead', updateField, lead.data._customStatuses)
|
statusOptions(
|
||||||
|
'lead',
|
||||||
|
updateField,
|
||||||
|
document.statuses?.length
|
||||||
|
? document.statuses
|
||||||
|
: lead.data._customStatuses,
|
||||||
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template #default="{ open }">
|
<template #default="{ open }">
|
||||||
@ -45,6 +51,10 @@
|
|||||||
v-if="lead.data._customActions?.length"
|
v-if="lead.data._customActions?.length"
|
||||||
:actions="lead.data._customActions"
|
:actions="lead.data._customActions"
|
||||||
/>
|
/>
|
||||||
|
<CustomActions
|
||||||
|
v-if="document.actions?.length"
|
||||||
|
:actions="document.actions"
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
:label="__('Convert')"
|
:label="__('Convert')"
|
||||||
variant="solid"
|
variant="solid"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user