feat: improvements to rte upload
This commit is contained in:
@@ -7,6 +7,7 @@ import { PayloadRequest } from '../../express/types';
|
||||
type Arguments = {
|
||||
data: unknown
|
||||
overrideAccess?: boolean
|
||||
key: string | number
|
||||
depth: number
|
||||
currentDepth?: number
|
||||
payload: Payload
|
||||
@@ -19,6 +20,7 @@ export const populate = async ({
|
||||
id,
|
||||
collection,
|
||||
data,
|
||||
key,
|
||||
overrideAccess,
|
||||
depth,
|
||||
currentDepth,
|
||||
@@ -30,7 +32,7 @@ export const populate = async ({
|
||||
field: Field
|
||||
collection: Collection
|
||||
}): Promise<void> => {
|
||||
let dataRef = data as Record<string, unknown>;
|
||||
const dataRef = data as Record<string, unknown>;
|
||||
|
||||
const doc = await payload.operations.collections.findByID({
|
||||
req: {
|
||||
@@ -47,8 +49,8 @@ export const populate = async ({
|
||||
});
|
||||
|
||||
if (doc) {
|
||||
dataRef = doc;
|
||||
dataRef[key] = doc;
|
||||
} else {
|
||||
dataRef = null;
|
||||
dataRef[key] = null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,7 +40,8 @@ export const recurseNestedFields = ({
|
||||
id: value,
|
||||
field,
|
||||
collection,
|
||||
data: data[field.name][i],
|
||||
data: data[field.name],
|
||||
key: i,
|
||||
overrideAccess,
|
||||
depth,
|
||||
currentDepth,
|
||||
@@ -58,7 +59,8 @@ export const recurseNestedFields = ({
|
||||
id,
|
||||
field,
|
||||
collection,
|
||||
data: data[field.name][i],
|
||||
data: data[field.name],
|
||||
key: i,
|
||||
overrideAccess,
|
||||
depth,
|
||||
currentDepth,
|
||||
@@ -75,7 +77,8 @@ export const recurseNestedFields = ({
|
||||
id: data[field.name].value,
|
||||
field,
|
||||
collection,
|
||||
data: data[field.name].value,
|
||||
data: data[field.name],
|
||||
key: 'value',
|
||||
overrideAccess,
|
||||
depth,
|
||||
currentDepth,
|
||||
@@ -90,7 +93,8 @@ export const recurseNestedFields = ({
|
||||
id: data[field.name],
|
||||
field,
|
||||
collection,
|
||||
data: data[field.name],
|
||||
data,
|
||||
key: field.name,
|
||||
overrideAccess,
|
||||
depth,
|
||||
currentDepth,
|
||||
|
||||
@@ -62,7 +62,8 @@ export const recurseRichText = ({
|
||||
promises.push(populate({
|
||||
req,
|
||||
id: element.value.id,
|
||||
data: element.value,
|
||||
data: element,
|
||||
key: 'value',
|
||||
overrideAccess,
|
||||
depth,
|
||||
currentDepth,
|
||||
|
||||
0
src/fields/tests/richText.spec.ts
Normal file
0
src/fields/tests/richText.spec.ts
Normal file
Reference in New Issue
Block a user