feat: table action add reload button (#630)

* feat: table action add reload button

* feat: reload => refresh

* feat: reload icon
This commit is contained in:
Ayden 2022-07-14 20:58:21 +08:00 committed by GitHub
parent c9dfc2682c
commit 205c23b656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 1 deletions

View File

@ -415,6 +415,15 @@ export const useBulkDestroyActionProps = () => {
};
};
export const useRefreshActionProps = () => {
const { service } = useBlockRequestContext();
return {
async onClick() {
service?.refresh?.();
},
};
}
export const useDetailsPaginationProps = () => {
const ctx = useDetailsBlockContext();
const count = ctx.service?.data?.meta?.count || 0;

View File

@ -98,6 +98,7 @@ export default {
"Update": "Update",
"View": "View",
"View record": "View record",
"Refresh": "Refresh",
"Data changes": "Data changes",
"Field name": "Field name",
"Before change": "Before change",

View File

@ -99,6 +99,7 @@ export default {
"Update": "更新",
"View": "查看",
"View record": "查看数据",
"Refresh": "刷新",
"Data changes": "数据变更",
"Field name": "字段标识",

View File

@ -42,6 +42,18 @@ export const TableActionInitializers = {
},
},
},
{
type: 'item',
title: "{{t('Refresh')}}",
component: 'RefreshActionInitializer',
schema: {
'x-align': 'right',
'x-decorator': 'ACLActionProvider',
'x-acl-action-props': {
skipScopeCheck: true,
},
},
},
],
},
],

View File

@ -538,6 +538,20 @@ export const BulkDestroyActionInitializer = (props) => {
return <ActionInitializer {...props} schema={schema} />;
};
export const RefreshActionInitializer = (props) => {
const schema = {
title: '{{ t("Refresh") }}',
'x-action': 'refresh',
'x-component': 'Action',
'x-designer': 'Action.Designer',
'x-component-props': {
icon: 'ReloadOutlined',
useProps: '{{ useRefreshActionProps }}',
},
};
return <ActionInitializer {...props} schema={schema} />;
};
export const SubmitActionInitializer = (props) => {
const schema = {
title: '{{ t("Submit") }}',