mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 06:55:50 +00:00
fix(variable): should show all collection fields (#5310)
This commit is contained in:
parent
63444a10ae
commit
35198b715e
@ -21,9 +21,9 @@ export const useGetFilterOptions = () => {
|
|||||||
const { getCollectionFields } = useCollectionManager_deprecated();
|
const { getCollectionFields } = useCollectionManager_deprecated();
|
||||||
const getFilterFieldOptions = useGetFilterFieldOptions();
|
const getFilterFieldOptions = useGetFilterFieldOptions();
|
||||||
|
|
||||||
return (collectionName, dataSource?: string) => {
|
return (collectionName, dataSource?: string, usedInVariable?: boolean) => {
|
||||||
const fields = getCollectionFields(collectionName, dataSource);
|
const fields = getCollectionFields(collectionName, dataSource);
|
||||||
const options = getFilterFieldOptions(fields);
|
const options = getFilterFieldOptions(fields, usedInVariable);
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -39,18 +39,20 @@ export const useGetFilterFieldOptions = () => {
|
|||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const nonfilterable = fieldSchema?.['x-component-props']?.nonfilterable || [];
|
const nonfilterable = fieldSchema?.['x-component-props']?.nonfilterable || [];
|
||||||
const { getCollectionFields, getInterface } = useCollectionManager_deprecated();
|
const { getCollectionFields, getInterface } = useCollectionManager_deprecated();
|
||||||
const field2option = (field, depth) => {
|
const field2option = (field, depth, usedInVariable?: boolean) => {
|
||||||
if (nonfilterable.length && depth === 1 && nonfilterable.includes(field.name)) {
|
if (nonfilterable.length && depth === 1 && nonfilterable.includes(field.name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!field.interface) {
|
if (!field.interface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldInterface = getInterface(field.interface);
|
const fieldInterface = getInterface(field.interface);
|
||||||
if (!fieldInterface?.filterable) {
|
if (!fieldInterface?.filterable && !usedInVariable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { nested, children, operators } = fieldInterface.filterable;
|
|
||||||
|
const { nested, children, operators } = fieldInterface?.filterable || {};
|
||||||
const option = {
|
const option = {
|
||||||
name: field.name,
|
name: field.name,
|
||||||
type: field.type,
|
type: field.type,
|
||||||
@ -80,17 +82,17 @@ export const useGetFilterFieldOptions = () => {
|
|||||||
}
|
}
|
||||||
return option;
|
return option;
|
||||||
};
|
};
|
||||||
const getOptions = (fields, depth) => {
|
const getOptions = (fields, depth, usedInVariable?: boolean) => {
|
||||||
const options = [];
|
const options = [];
|
||||||
fields.forEach((field) => {
|
fields.forEach((field) => {
|
||||||
const option = field2option(field, depth);
|
const option = field2option(field, depth, usedInVariable);
|
||||||
if (option) {
|
if (option) {
|
||||||
options.push(option);
|
options.push(option);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
return (fields) => getOptions(fields, 1);
|
return (fields, usedInVariable) => getOptions(fields, 1, usedInVariable);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useFilterFieldOptions = (fields) => {
|
export const useFilterFieldOptions = (fields) => {
|
||||||
|
@ -211,8 +211,9 @@ export const useBaseVariable = ({
|
|||||||
const target = option.field.target;
|
const target = option.field.target;
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
const usedInVariable = true;
|
||||||
const children = (
|
const children = (
|
||||||
getChildren(returnFields(getFilterOptions(target, dataSource), option), {
|
getChildren(returnFields(getFilterOptions(target, dataSource, usedInVariable), option), {
|
||||||
collectionField,
|
collectionField,
|
||||||
uiSchema,
|
uiSchema,
|
||||||
targetFieldSchema,
|
targetFieldSchema,
|
||||||
|
Loading…
Reference in New Issue
Block a user