mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 11:12:20 +08:00
fix: sub-table support allowAddNew setting (#4498)
This commit is contained in:
parent
518249602f
commit
02ebede15a
@ -21,6 +21,7 @@ import {
|
|||||||
} from '../../../../schema-component';
|
} from '../../../../schema-component';
|
||||||
import { isSubMode } from '../../../../schema-component/antd/association-field/util';
|
import { isSubMode } from '../../../../schema-component/antd/association-field/util';
|
||||||
import { useCollectionManager_deprecated, useSortFields } from '../../../../collection-manager';
|
import { useCollectionManager_deprecated, useSortFields } from '../../../../collection-manager';
|
||||||
|
import { useIsAssociationField } from '../../../../schema-component/antd/form-item';
|
||||||
|
|
||||||
const fieldComponent: any = {
|
const fieldComponent: any = {
|
||||||
name: 'fieldComponent',
|
name: 'fieldComponent',
|
||||||
@ -219,7 +220,40 @@ export const setDefaultSortingRules = {
|
|||||||
return readPretty && ['m2m', 'o2m'].includes(targetInterface);
|
return readPretty && ['m2m', 'o2m'].includes(targetInterface);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const allowAddNewData = {
|
||||||
|
name: 'allowAddNewData',
|
||||||
|
type: 'switch',
|
||||||
|
useVisible() {
|
||||||
|
const readPretty = useIsFieldReadPretty();
|
||||||
|
const isAssociationField = useIsAssociationField();
|
||||||
|
return !readPretty && isAssociationField;
|
||||||
|
},
|
||||||
|
useComponentProps() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const field = useField<Field>();
|
||||||
|
const fieldSchema = useFieldSchema();
|
||||||
|
const { dn, refresh } = useDesignable();
|
||||||
|
return {
|
||||||
|
title: t('Allow add new'),
|
||||||
|
checked: fieldSchema['x-component-props']?.allowAddnew !== (false as boolean),
|
||||||
|
onChange(value) {
|
||||||
|
const schema = {
|
||||||
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
|
};
|
||||||
|
field.componentProps.allowAddnew = value;
|
||||||
|
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||||
|
fieldSchema['x-component-props'].allowAddnew = value;
|
||||||
|
schema['x-component-props'] = fieldSchema['x-component-props'];
|
||||||
|
dn.emit('patch', {
|
||||||
|
schema,
|
||||||
|
});
|
||||||
|
refresh();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
export const subTablePopoverComponentFieldSettings = new SchemaSettings({
|
export const subTablePopoverComponentFieldSettings = new SchemaSettings({
|
||||||
name: 'fieldSettings:component:SubTable',
|
name: 'fieldSettings:component:SubTable',
|
||||||
items: [fieldComponent, allowSelectExistingRecord, setDefaultSortingRules],
|
items: [fieldComponent, allowAddNewData, allowSelectExistingRecord, setDefaultSortingRules],
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user