feat(table): hidden pagination when only one page is available (#1614)

* feat(table): hidden pagination when only one page is available

* feat: remove console

* fix(table): add new button for edit button color does not work

* fix: don't support edit type and icon in Link

* feat: danger property first

* fix: reset shadow of danger button

* perf: remove unused logic
This commit is contained in:
Dunqing 2023-03-29 17:56:05 +08:00 committed by GitHub
parent 6747331529
commit 5752edd5d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 7 deletions

View File

@ -52,6 +52,7 @@ export const ActionDesigner = (props) => {
const isLinkageAction = Object.keys(useFormBlockContext()).length > 0 && Object.keys(useRecord()).length > 0;
const isChildCollectionAction = getChildrenCollections(name).length > 0 && fieldSchema['x-action'] === 'create';
const isSupportEditButton = fieldSchema['x-action'] !== 'expandAll';
const isLink = fieldSchema['x-component'] === 'Action.Link';
useEffect(() => {
const schemaUid = uid();
const schema: ISchema = {
@ -96,7 +97,7 @@ export const ActionDesigner = (props) => {
title: t('Button icon'),
default: fieldSchema?.['x-component-props']?.icon,
'x-component-props': {},
'x-visible': isSupportEditButton,
'x-visible': isSupportEditButton && !isLink,
// description: `原字段标题:${collectionField?.uiSchema?.title}`,
},
type: {
@ -113,6 +114,7 @@ export const ActionDesigner = (props) => {
{ value: 'primary', label: '{{t("Highlight")}}' },
{ value: 'danger', label: '{{t("Danger red")}}' },
],
'x-visible': !isLink,
},
},
} as ISchema

View File

@ -1,3 +1,8 @@
.ant-btn.ant-btn-danger {
text-shadow: none;
box-shadow: none;
}
.ant-formily-item-label {
color: #000000d9;
font-weight:600;
@ -21,4 +26,4 @@
.m24 {
margin: 16px !important;
}
}
}

View File

@ -125,12 +125,14 @@ const usePaginationProps = (pagination1, pagination2) => {
if (!pagination2 && pagination1 === false) {
return false;
}
return {
const result = {
showTotal: (total) => t('Total {{count}} items', { count: total }),
showSizeChanger: true,
...pagination1,
...pagination2,
};
return result.total < result.pageSize ? false : result;
};
const useValidator = (validator: (value: any) => string) => {

View File

@ -56,7 +56,7 @@ SchemaInitializer.Button = observer((props: SchemaInitializerButtonProps) => {
return <Menu.Divider key={item.key || `item-${indexA}`} />;
}
if (item.type === 'item' && item.component) {
const Component = typeof item.component === 'string' ? findComponent(item.component) : item.component;
const Component = findComponent(item.component);
item.key = `${item.key || item.title}-${indexA}`;
return (
Component && (

View File

@ -84,6 +84,7 @@ export const CreateRecordAction = observer((props) => {
const fieldSchema = useFieldSchema();
const enableChildren = fieldSchema['x-enable-children'] || [];
const field = useField();
const componentType = field.componentProps.type || 'primary';
const { getChildrenCollections } = useCollectionManager();
const totalChildCollections = getChildrenCollections(collection.name);
const inheritsCollections = enableChildren
@ -97,7 +98,7 @@ export const CreateRecordAction = observer((props) => {
}
return {
...childCollection,
title: k.title||childCollection.title,
title: k.title || childCollection.title,
};
})
.filter((v) => {
@ -128,7 +129,7 @@ export const CreateRecordAction = observer((props) => {
<ActionContext.Provider value={{ ...ctx, visible, setVisible }}>
{inheritsCollections?.length > 0 ? (
<Dropdown.Button
type="primary"
type={componentType}
icon={<DownOutlined />}
buttonsRender={([leftButton, rightButton]) => [
leftButton,
@ -145,7 +146,8 @@ export const CreateRecordAction = observer((props) => {
</Dropdown.Button>
) : (
<Button
type={'primary'}
type={componentType}
danger={componentType === 'danger'}
icon={<PlusOutlined />}
onClick={(info) => {
setVisible(true);

View File

@ -11,6 +11,7 @@ export const CreateActionInitializer = (props) => {
'x-decorator': 'ACLActionProvider',
'x-component-props': {
openMode: 'drawer',
type: 'primary',
component: 'CreateRecordAction',
},
properties: {