fix(plugin-workflow): fix assign attachment value in nodes (#2448)

This commit is contained in:
Junyi 2023-08-14 16:11:48 +07:00 committed by GitHub
parent dcafbb10c8
commit 2f6bfa65f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,7 +126,7 @@ export const BaseTypeSets = {
// { type: 'reference', options: { collection: 'attachments', multiple: false } } // { type: 'reference', options: { collection: 'attachments', multiple: false } }
// { type: 'reference', options: { collection: 'myExpressions', entity: false } } // { type: 'reference', options: { collection: 'myExpressions', entity: false } }
function matchFieldType(field, type, appends): boolean { function matchFieldType(field, type, appends?: string[]): boolean {
const inputType = typeof type; const inputType = typeof type;
if (inputType === 'string') { if (inputType === 'string') {
return BaseTypeSets[type]?.has(field.interface); return BaseTypeSets[type]?.has(field.interface);
@ -264,10 +264,11 @@ function getNormalizedFields(collectionName, { compile, getCollectionFields }) {
} }
async function loadChildren(option) { async function loadChildren(option) {
const appends = getNextAppends(option.field, option.appends);
const result = getCollectionFieldOptions({ const result = getCollectionFieldOptions({
collection: option.field.target, collection: option.field.target,
types: option.types, types: option.types,
appends: getNextAppends(option.field, option.appends), appends,
...this, ...this,
}); });
option.loadChildren = null; option.loadChildren = null;
@ -275,7 +276,7 @@ async function loadChildren(option) {
option.children = result; option.children = result;
} else { } else {
option.isLeaf = true; option.isLeaf = true;
const matchingType = option.types?.some((type) => matchFieldType(option.field, type, 0)); const matchingType = option.types ? option.types.some((type) => matchFieldType(option.field, type, appends)) : true;
if (!matchingType) { if (!matchingType) {
option.disabled = true; option.disabled = true;
} }