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

View File

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

View File

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