Files
klz-cables.com/.pnpm-store/v10/files/14/ef293904bc49a854c4e51277ca32eead6d00b8e20a792b3979f430cf5c0df87d90a191c8a907cffe0ce1473e76e8e727586770b1b44a0aa228f568b9a355c1
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

124 lines
2.7 KiB
Plaintext

import { stripUnselectedFields } from 'payload';
import { getFieldPaths } from 'payload/shared';
import { addFieldStatePromise } from './addFieldStatePromise.js';
/**
* Flattens the fields schema and fields data
*/
export const iterateFields = async ({
id,
addErrorPathToParent: addErrorPathToParentArg,
anyParentLocalized = false,
blockData,
clientFieldSchemaMap,
collectionSlug,
data,
fields,
fieldSchemaMap,
filter,
forceFullValue = false,
fullData,
includeSchema = false,
mockRSCs,
omitParents = false,
operation,
parentIndexPath,
parentPassesCondition = true,
parentPath,
parentSchemaPath,
permissions,
preferences,
previousFormState,
readOnly,
renderAllFields,
renderFieldFn: renderFieldFn,
req,
select,
selectMode,
skipConditionChecks = false,
skipValidation = false,
state = {}
}) => {
const promises = [];
fields.forEach((field, fieldIndex) => {
let passesCondition = true;
const {
indexPath,
path,
schemaPath
} = getFieldPaths({
field,
index: fieldIndex,
parentIndexPath,
parentPath,
parentSchemaPath
});
if (path !== 'id') {
const shouldContinue = stripUnselectedFields({
field,
select,
selectMode,
siblingDoc: data
});
if (!shouldContinue) {
return;
}
}
const pathSegments = path ? path.split('.') : [];
if (!skipConditionChecks) {
try {
passesCondition = Boolean((field?.admin?.condition ? Boolean(field.admin.condition(fullData || {}, data || {}, {
blockData,
operation,
path: pathSegments,
user: req.user
})) : true) && parentPassesCondition);
} catch (err) {
passesCondition = false;
req.payload.logger.error({
err,
msg: `Error evaluating field condition at path: ${path}`
});
}
}
promises.push(addFieldStatePromise({
id,
addErrorPathToParent: addErrorPathToParentArg,
anyParentLocalized,
blockData,
clientFieldSchemaMap,
collectionSlug,
data,
field,
fieldIndex,
fieldSchemaMap,
filter,
forceFullValue,
fullData,
includeSchema,
indexPath,
mockRSCs,
omitParents,
operation,
parentIndexPath,
parentPath,
parentPermissions: permissions,
parentSchemaPath,
passesCondition,
path,
preferences,
previousFormState,
readOnly,
renderAllFields,
renderFieldFn,
req,
schemaPath,
select,
selectMode,
skipConditionChecks,
skipValidation,
state
}));
});
await Promise.all(promises);
};
//# sourceMappingURL=iterateFields.js.map