feat: fix through collections inherits filter (#1394)
* feat: fix through collections inherits filter * feat: foreignkey disabled when collectionfield override
This commit is contained in:
parent
1272523b12
commit
0d30366aba
@ -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) => ({
|
||||
|
@ -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,
|
||||
}}
|
||||
/>
|
||||
|
@ -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 }}',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user