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:
parent
6747331529
commit
5752edd5d5
@ -52,6 +52,7 @@ export const ActionDesigner = (props) => {
|
|||||||
const isLinkageAction = Object.keys(useFormBlockContext()).length > 0 && Object.keys(useRecord()).length > 0;
|
const isLinkageAction = Object.keys(useFormBlockContext()).length > 0 && Object.keys(useRecord()).length > 0;
|
||||||
const isChildCollectionAction = getChildrenCollections(name).length > 0 && fieldSchema['x-action'] === 'create';
|
const isChildCollectionAction = getChildrenCollections(name).length > 0 && fieldSchema['x-action'] === 'create';
|
||||||
const isSupportEditButton = fieldSchema['x-action'] !== 'expandAll';
|
const isSupportEditButton = fieldSchema['x-action'] !== 'expandAll';
|
||||||
|
const isLink = fieldSchema['x-component'] === 'Action.Link';
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const schemaUid = uid();
|
const schemaUid = uid();
|
||||||
const schema: ISchema = {
|
const schema: ISchema = {
|
||||||
@ -96,7 +97,7 @@ export const ActionDesigner = (props) => {
|
|||||||
title: t('Button icon'),
|
title: t('Button icon'),
|
||||||
default: fieldSchema?.['x-component-props']?.icon,
|
default: fieldSchema?.['x-component-props']?.icon,
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
'x-visible': isSupportEditButton,
|
'x-visible': isSupportEditButton && !isLink,
|
||||||
// description: `原字段标题:${collectionField?.uiSchema?.title}`,
|
// description: `原字段标题:${collectionField?.uiSchema?.title}`,
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
@ -113,6 +114,7 @@ export const ActionDesigner = (props) => {
|
|||||||
{ value: 'primary', label: '{{t("Highlight")}}' },
|
{ value: 'primary', label: '{{t("Highlight")}}' },
|
||||||
{ value: 'danger', label: '{{t("Danger red")}}' },
|
{ value: 'danger', label: '{{t("Danger red")}}' },
|
||||||
],
|
],
|
||||||
|
'x-visible': !isLink,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as ISchema
|
} as ISchema
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
.ant-btn.ant-btn-danger {
|
||||||
|
text-shadow: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
.ant-formily-item-label {
|
.ant-formily-item-label {
|
||||||
color: #000000d9;
|
color: #000000d9;
|
||||||
font-weight:600;
|
font-weight:600;
|
||||||
|
@ -125,12 +125,14 @@ const usePaginationProps = (pagination1, pagination2) => {
|
|||||||
if (!pagination2 && pagination1 === false) {
|
if (!pagination2 && pagination1 === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return {
|
|
||||||
|
const result = {
|
||||||
showTotal: (total) => t('Total {{count}} items', { count: total }),
|
showTotal: (total) => t('Total {{count}} items', { count: total }),
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
...pagination1,
|
...pagination1,
|
||||||
...pagination2,
|
...pagination2,
|
||||||
};
|
};
|
||||||
|
return result.total < result.pageSize ? false : result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useValidator = (validator: (value: any) => string) => {
|
const useValidator = (validator: (value: any) => string) => {
|
||||||
|
@ -56,7 +56,7 @@ SchemaInitializer.Button = observer((props: SchemaInitializerButtonProps) => {
|
|||||||
return <Menu.Divider key={item.key || `item-${indexA}`} />;
|
return <Menu.Divider key={item.key || `item-${indexA}`} />;
|
||||||
}
|
}
|
||||||
if (item.type === 'item' && item.component) {
|
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}`;
|
item.key = `${item.key || item.title}-${indexA}`;
|
||||||
return (
|
return (
|
||||||
Component && (
|
Component && (
|
||||||
|
@ -84,6 +84,7 @@ export const CreateRecordAction = observer((props) => {
|
|||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const enableChildren = fieldSchema['x-enable-children'] || [];
|
const enableChildren = fieldSchema['x-enable-children'] || [];
|
||||||
const field = useField();
|
const field = useField();
|
||||||
|
const componentType = field.componentProps.type || 'primary';
|
||||||
const { getChildrenCollections } = useCollectionManager();
|
const { getChildrenCollections } = useCollectionManager();
|
||||||
const totalChildCollections = getChildrenCollections(collection.name);
|
const totalChildCollections = getChildrenCollections(collection.name);
|
||||||
const inheritsCollections = enableChildren
|
const inheritsCollections = enableChildren
|
||||||
@ -97,7 +98,7 @@ export const CreateRecordAction = observer((props) => {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...childCollection,
|
...childCollection,
|
||||||
title: k.title||childCollection.title,
|
title: k.title || childCollection.title,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter((v) => {
|
.filter((v) => {
|
||||||
@ -128,7 +129,7 @@ export const CreateRecordAction = observer((props) => {
|
|||||||
<ActionContext.Provider value={{ ...ctx, visible, setVisible }}>
|
<ActionContext.Provider value={{ ...ctx, visible, setVisible }}>
|
||||||
{inheritsCollections?.length > 0 ? (
|
{inheritsCollections?.length > 0 ? (
|
||||||
<Dropdown.Button
|
<Dropdown.Button
|
||||||
type="primary"
|
type={componentType}
|
||||||
icon={<DownOutlined />}
|
icon={<DownOutlined />}
|
||||||
buttonsRender={([leftButton, rightButton]) => [
|
buttonsRender={([leftButton, rightButton]) => [
|
||||||
leftButton,
|
leftButton,
|
||||||
@ -145,7 +146,8 @@ export const CreateRecordAction = observer((props) => {
|
|||||||
</Dropdown.Button>
|
</Dropdown.Button>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
type={'primary'}
|
type={componentType}
|
||||||
|
danger={componentType === 'danger'}
|
||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
onClick={(info) => {
|
onClick={(info) => {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
@ -11,6 +11,7 @@ export const CreateActionInitializer = (props) => {
|
|||||||
'x-decorator': 'ACLActionProvider',
|
'x-decorator': 'ACLActionProvider',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
openMode: 'drawer',
|
openMode: 'drawer',
|
||||||
|
type: 'primary',
|
||||||
component: 'CreateRecordAction',
|
component: 'CreateRecordAction',
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
|
Loading…
Reference in New Issue
Block a user