mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 12:54:05 +00:00
fix(plugin-workflow): fix foreignkey in variable (#1740)
This commit is contained in:
parent
673c246eed
commit
5d2724583c
@ -108,7 +108,7 @@ export function filterTypedFields(fields, types, depth = 1) {
|
|||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
return fields.filter((field) => {
|
return fields.filter((field) => {
|
||||||
if (isAssociationField(field) && depth && filterTypedFields(useNormallizedFields(field.target), types, depth - 1).length) {
|
if (isAssociationField(field) && depth && filterTypedFields(useNormalizedFields(field.target), types, depth - 1).length) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return types.some((type) => matchFieldType(field, type));
|
return types.some((type) => matchFieldType(field, type));
|
||||||
@ -130,7 +130,7 @@ export function useWorkflowVariableOptions(types?) {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function useNormallizedFields(collectionName) {
|
function useNormalizedFields(collectionName) {
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const { getCollection } = useCollectionManager();
|
const { getCollection } = useCollectionManager();
|
||||||
const collection = getCollection(collectionName);
|
const collection = getCollection(collectionName);
|
||||||
@ -153,6 +153,7 @@ function useNormallizedFields(collectionName) {
|
|||||||
const foreignKeyField = foreignKeyFields.find(f => f.name === field.foreignKey);
|
const foreignKeyField = foreignKeyFields.find(f => f.name === field.foreignKey);
|
||||||
if (foreignKeyField) {
|
if (foreignKeyField) {
|
||||||
otherFields.splice(i, 0, {
|
otherFields.splice(i, 0, {
|
||||||
|
...field,
|
||||||
...foreignKeyField,
|
...foreignKeyField,
|
||||||
uiSchema: {
|
uiSchema: {
|
||||||
...field.uiSchema,
|
...field.uiSchema,
|
||||||
@ -192,7 +193,7 @@ function useNormallizedFields(collectionName) {
|
|||||||
export function useCollectionFieldOptions(options): VariableOption[] {
|
export function useCollectionFieldOptions(options): VariableOption[] {
|
||||||
const { fields, collection, types, depth = 1 } = options;
|
const { fields, collection, types, depth = 1 } = options;
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const normalizedFields = fields ?? useNormallizedFields(collection);
|
const normalizedFields = fields ?? useNormalizedFields(collection);
|
||||||
const result: VariableOption[] = filterTypedFields(normalizedFields, types, depth)
|
const result: VariableOption[] = filterTypedFields(normalizedFields, types, depth)
|
||||||
.filter(field => !isAssociationField(field) || depth)
|
.filter(field => !isAssociationField(field) || depth)
|
||||||
.map(field => {
|
.map(field => {
|
||||||
|
Loading…
Reference in New Issue
Block a user