mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 03:25:57 +00:00
fix(plugin-workflow): fix missed fields in variable (#5187)
This commit is contained in:
parent
b8acdc1477
commit
5cb4fb5096
@ -383,7 +383,7 @@ function getNormalizedFields(collectionName, { compile, getCollectionFields }) {
|
|||||||
const fkFields: any[] = [];
|
const fkFields: any[] = [];
|
||||||
const result: any[] = [];
|
const result: any[] = [];
|
||||||
fields.forEach((field) => {
|
fields.forEach((field) => {
|
||||||
if (field.isForeignKey) {
|
if (field.isForeignKey && !field.primaryKey) {
|
||||||
fkFields.push(field);
|
fkFields.push(field);
|
||||||
} else {
|
} else {
|
||||||
const fkField = fields.find((f) => f.name === field.foreignKey);
|
const fkField = fields.find((f) => f.name === field.foreignKey);
|
||||||
@ -394,11 +394,13 @@ function getNormalizedFields(collectionName, { compile, getCollectionFields }) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const foreignKeyFields = uniqBy(fkFields, 'name');
|
const foreignKeyFields = uniqBy(fkFields, 'name');
|
||||||
|
// NOTE: for all foreignKey fields
|
||||||
for (let i = result.length - 1; i >= 0; i--) {
|
for (let i = result.length - 1; i >= 0; i--) {
|
||||||
const field = result[i];
|
const field = result[i];
|
||||||
if (field.type === 'belongsTo') {
|
if (field.type === 'belongsTo') {
|
||||||
const foreignKeyField = foreignKeyFields.find((f) => f.name === field.foreignKey);
|
const foreignKeyFieldIndex = foreignKeyFields.findIndex((f) => f.name === field.foreignKey);
|
||||||
if (foreignKeyField) {
|
if (foreignKeyFieldIndex > -1) {
|
||||||
|
const foreignKeyField = foreignKeyFields[foreignKeyFieldIndex];
|
||||||
result.splice(i, 0, {
|
result.splice(i, 0, {
|
||||||
...field,
|
...field,
|
||||||
...foreignKeyField,
|
...foreignKeyField,
|
||||||
@ -407,6 +409,7 @@ function getNormalizedFields(collectionName, { compile, getCollectionFields }) {
|
|||||||
title: foreignKeyField.uiSchema?.title ? compile(foreignKeyField.uiSchema?.title) : foreignKeyField.name,
|
title: foreignKeyField.uiSchema?.title ? compile(foreignKeyField.uiSchema?.title) : foreignKeyField.name,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
foreignKeyFields.splice(foreignKeyFieldIndex, 1);
|
||||||
} else {
|
} else {
|
||||||
result.splice(i, 0, {
|
result.splice(i, 0, {
|
||||||
...field,
|
...field,
|
||||||
@ -424,6 +427,7 @@ function getNormalizedFields(collectionName, { compile, getCollectionFields }) {
|
|||||||
result.splice(i, 1);
|
result.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result.push(...foreignKeyFields);
|
||||||
|
|
||||||
return uniqBy(result, 'name').filter((field) => field.interface && !field.hidden);
|
return uniqBy(result, 'name').filter((field) => field.interface && !field.hidden);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user