From 8e6da46691331c4e1c49632a1576577b4011d5c3 Mon Sep 17 00:00:00 2001 From: Katherine Date: Thu, 24 Oct 2024 09:51:23 +0800 Subject: [PATCH 1/2] fix: limit editing to current collection form block in non-config mode and hide other block (#5499) --- .../src/block-provider/FormBlockProvider.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/core/client/src/block-provider/FormBlockProvider.tsx b/packages/core/client/src/block-provider/FormBlockProvider.tsx index d2abb74276..fcd16e041a 100644 --- a/packages/core/client/src/block-provider/FormBlockProvider.tsx +++ b/packages/core/client/src/block-provider/FormBlockProvider.tsx @@ -24,6 +24,8 @@ import { useActionContext } from '../schema-component'; import { BlockProvider, useBlockRequestContext } from './BlockProvider'; import { TemplateBlockProvider } from './TemplateBlockProvider'; import { FormActiveFieldsProvider } from './hooks/useFormActiveFields'; +import { useDesignable } from '../schema-component'; +import { useCollectionRecordData } from '../data-source'; export const FormBlockContext = createContext<{ form?: any; @@ -123,6 +125,18 @@ export const useIsDetailBlock = () => { export const FormBlockProvider = withDynamicSchemaProps((props) => { const parentRecordData = useCollectionParentRecordData(); const { parentRecord } = props; + const record = useCollectionRecordData(); + const { association } = props; + const cm = useCollectionManager(); + const { __collection } = record || {}; + const { designable } = useDesignable(); + const collection = props.collection || cm.getCollection(association).name; + + if (!designable && __collection) { + if (__collection !== collection) { + return null; + } + } return ( From 5010a052b5ff1b2baea3153541b693b0433ddb52 Mon Sep 17 00:00:00 2001 From: Katherine Date: Thu, 24 Oct 2024 09:51:35 +0800 Subject: [PATCH 2/2] fix: pagination issue in list block with simple pagination collection (#5500) --- .../src/schema-component/antd/list/List.tsx | 60 +++++++++++++++---- 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/list/List.tsx b/packages/core/client/src/schema-component/antd/list/List.tsx index 1b727d556b..33e75767e7 100644 --- a/packages/core/client/src/schema-component/antd/list/List.tsx +++ b/packages/core/client/src/schema-component/antd/list/List.tsx @@ -28,6 +28,7 @@ const InternalList = (props) => { const fieldSchema = useFieldSchema(); const Designer = useDesigner(); const meta = service?.data?.meta; + const { pageSize, count, hasNext, page } = meta || {}; const field = useField(); const [schemaMap] = useState(new Map()); const { wrapSSR, componentCls, hashId } = useStyles(); @@ -63,7 +64,51 @@ const InternalList = (props) => { }, [run, params], ); - + const usePagination = () => { + if (!count) { + return { + onChange: onPaginationChange, + total: count || field.value?.length < pageSize || !hasNext ? pageSize * page : pageSize * page + 1, + pageSize: pageSize || 10, + current: page || 1, + showSizeChanger: true, + pageSizeOptions, + simple: true, + className: css` + .ant-pagination-simple-pager { + display: none !important; + } + `, + itemRender: (_, type, originalElement) => { + if (type === 'prev') { + return ( +
+ {originalElement}
{page}
+
+ ); + } else { + return originalElement; + } + }, + }; + } + return { + onChange: onPaginationChange, + total: count || 0, + pageSize: pageSize || 10, + current: page || 1, + showSizeChanger: true, + pageSizeOptions, + }; + }; + const paginationProps = usePagination(); return wrapSSR( {
{field.value?.length