@@ -265,6 +265,20 @@ export const addFieldStatePromise = async ({
|
||||
break
|
||||
}
|
||||
|
||||
case 'relationship':
|
||||
case 'upload': {
|
||||
const relationshipValue =
|
||||
valueWithDefault && typeof valueWithDefault === 'object' && 'id' in valueWithDefault
|
||||
? valueWithDefault.id
|
||||
: valueWithDefault
|
||||
fieldState.value = relationshipValue
|
||||
fieldState.initialValue = relationshipValue
|
||||
|
||||
state[`${path}${field.name}`] = fieldState
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
fieldState.value = valueWithDefault
|
||||
fieldState.initialValue = valueWithDefault
|
||||
|
||||
@@ -105,7 +105,7 @@ const GlobalView: React.FC<IndexProps> = (props) => {
|
||||
CustomComponent={CustomEdit}
|
||||
DefaultComponent={DefaultGlobal}
|
||||
componentProps={{
|
||||
action: `${serverURL}${api}/globals/${slug}?locale=${locale}&depth=0&fallback-locale=null`,
|
||||
action: `${serverURL}${api}/globals/${slug}?locale=${locale}&fallback-locale=null`,
|
||||
apiURL: `${serverURL}${api}/globals/${slug}?locale=${locale}${
|
||||
global.versions?.drafts ? '&draft=true' : ''
|
||||
}`,
|
||||
|
||||
@@ -112,7 +112,7 @@ const EditView: React.FC<IndexProps> = (props) => {
|
||||
}`
|
||||
const action = `${serverURL}${api}/${slug}${
|
||||
isEditing ? `/${id}` : ''
|
||||
}?locale=${locale}&depth=0&fallback-locale=null`
|
||||
}?locale=${locale}&fallback-locale=null`
|
||||
const hasSavePermission =
|
||||
(isEditing && docPermissions?.update?.permission) ||
|
||||
(!isEditing && (docPermissions as CollectionPermission)?.create?.permission)
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
import type { CollectionConfig } from '../../../../packages/payload/src/collections/config/types'
|
||||
import type { PayloadRequest } from '../../../../packages/payload/src/types'
|
||||
|
||||
import payload from '../../../../packages/payload/src'
|
||||
|
||||
export const contextHooksSlug = 'context-hooks'
|
||||
const ContextHooks: CollectionConfig = {
|
||||
slug: contextHooksSlug,
|
||||
@@ -47,12 +45,12 @@ const ContextHooks: CollectionConfig = {
|
||||
},
|
||||
],
|
||||
afterChange: [
|
||||
async ({ context, doc }) => {
|
||||
async ({ context, doc, req }) => {
|
||||
if (context.triggerAfterChange === false) {
|
||||
// Make sure we don't trigger afterChange again and again in an infinite loop
|
||||
return
|
||||
}
|
||||
await payload.update({
|
||||
await req.payload.update({
|
||||
collection: contextHooksSlug,
|
||||
id: doc.id,
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user