feat: fix through collections inherits filter (#1394)

* feat: fix  through collections inherits filter

* feat:  foreignkey disabled when collectionfield override
This commit is contained in:
katherinehhh 2023-01-29 00:11:45 +08:00 committed by GitHub
parent 1272523b12
commit 0d30366aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

View File

@ -85,7 +85,7 @@ export const ConfigurationTable = () => {
?.filter((item) => !(item.autoCreate && item.isThrough))
.filter((item) =>
targetScope
? targetScope['template']?.includes(item.template) || targetScope['name']?.includes(item.name)
? targetScope['template']?.includes(item.template) || targetScope[field.props.name]?.includes(item.name)
: true,
)
.map((item: any) => ({

View File

@ -128,23 +128,26 @@ const getIsOverriding = (currentFields, record) => {
};
export const OverridingFieldAction = (props) => {
const { scope, getContainer, item: record, children, currentCollection } = props;
const { target } = record;
const { target, through } = record;
const { getInterface, getCurrentCollectionFields, getChildrenCollections } = useCollectionManager();
const [visible, setVisible] = useState(false);
const [schema, setSchema] = useState({});
const api = useAPIClient();
const { t } = useTranslation();
const compile = useCompile();
const childCollections =
target &&
getChildrenCollections(target)
?.map((v) => v.name)
.concat([target]);
const getFilterCollections = (filterKey) => {
const childCollections =
filterKey &&
getChildrenCollections(filterKey)
?.map((v) => v.name)
.concat([filterKey]);
return childCollections;
};
const [data, setData] = useState<any>({});
const currentFields = getCurrentCollectionFields(currentCollection);
const disabled = getIsOverriding(currentFields, record);
return (
<RecordProvider record={record}>
<RecordProvider record={{ ...record, collectionName: record.__parent.name }}>
<ActionContext.Provider value={{ visible, setVisible }}>
<a
//@ts-ignore
@ -189,8 +192,9 @@ export const OverridingFieldAction = (props) => {
useCancelAction,
showReverseFieldConfig: !data?.reverseField,
createOnly: true,
override: true,
isOverride: true,
targetScope: { name: childCollections },
targetScope: { target: getFilterCollections(target), through: getFilterCollections(through) },
...scope,
}}
/>

View File

@ -190,7 +190,7 @@ export const m2m: IField = {
'x-decorator': 'FormItem',
'x-component': 'Input',
'x-validator': 'uid',
'x-disabled': '{{ !createOnly }}',
'x-disabled': '{{ !createOnly||override }}',
},
},
},
@ -224,7 +224,7 @@ export const m2m: IField = {
'x-decorator': 'FormItem',
'x-component': 'Input',
'x-validator': 'uid',
'x-disabled': '{{ !createOnly }}',
'x-disabled': '{{ !createOnly||override }}',
},
},
},