fix: table configuration delete button problem (#1764)

* fix: table configuration delete button problem

* fix: change copy

* refactor: optimize code

---------

Co-authored-by: Rairn <958414905@qq.com>
This commit is contained in:
Jack 2023-05-05 11:30:10 +08:00 committed by GitHub
parent 7feeda4906
commit d0edc6ce3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -161,10 +161,9 @@ const CurrentFields = (props) => {
type: 'checkbox',
onChange: (selectedRowKeys) => {
setState((state) => {
const result = [...(state.selectedRowKeys || []), ...selectedRowKeys];
return {
...state,
selectedRowKeys: result,
selectedRowKeys,
};
});
},
@ -312,7 +311,6 @@ export const CollectionFields = (props) => {
];
const fields = getCurrentCollectionFields(name);
const groups = {
pf: [],
association: [],
@ -357,7 +355,6 @@ export const CollectionFields = (props) => {
fields: groups.system,
},
];
dataSource.push(
...inherits
.map((key) => {
@ -408,7 +405,6 @@ export const CollectionFields = (props) => {
);
const addProps = { type: 'primary' };
const syncProps = { type: 'primary' };
return (
<ResourceActionProvider {...resourceActionProps}>
<FormContext.Provider value={form}>

View File

@ -2,6 +2,7 @@ import { useField, useForm } from '@formily/react';
import { message } from 'antd';
import omit from 'lodash/omit';
import { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useCollection, useCollectionManager } from '.';
import { useCompile } from '..';
import { useRequest } from '../api-client';
@ -378,8 +379,12 @@ export const useDestroyAction = () => {
export const useBulkDestroyAction = () => {
const { state, setState, refresh } = useResourceActionContext();
const { resource } = useResourceContext();
const { t } = useTranslation();
return {
async run() {
if (!state?.selectedRowKeys?.length) {
return message.error(t('Please select the records you want to delete'));
}
await resource.destroy({
filterByTk: state?.selectedRowKeys || [],
});

View File

@ -217,6 +217,7 @@ export default {
"Edit collection": "编辑数据表",
"Configure fields": "配置字段",
"Configure columns": "配置字段",
"Please select the records you want to delete": "请选择要删除的记录",
"Edit field": "编辑字段",
"Override": "重写",
"Override field": "重写字段",