mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
faaaf2e6d3
@ -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 (
|
||||
<TemplateBlockProvider>
|
||||
|
@ -30,6 +30,7 @@ const InternalList = (props) => {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const Designer = useDesigner();
|
||||
const meta = service?.data?.meta;
|
||||
const { pageSize, count, hasNext, page } = meta || {};
|
||||
const field = useField<ArrayField>();
|
||||
const [schemaMap] = useState(new Map());
|
||||
const { wrapSSR, componentCls, hashId } = useStyles();
|
||||
@ -67,7 +68,51 @@ const InternalList = (props) => {
|
||||
);
|
||||
const cardItemSchema = getCardItemSchema?.(fieldSchema);
|
||||
const { layout = 'vertical' } = cardItemSchema?.['x-component-props'] || {};
|
||||
|
||||
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 (
|
||||
<div
|
||||
style={{ display: 'flex' }}
|
||||
className={css`
|
||||
.ant-pagination-item-link {
|
||||
min-width: ${token.controlHeight}px;
|
||||
}
|
||||
`}
|
||||
>
|
||||
{originalElement} <div style={{ marginLeft: '7px' }}>{page}</div>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return originalElement;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
onChange: onPaginationChange,
|
||||
total: count || 0,
|
||||
pageSize: pageSize || 10,
|
||||
current: page || 1,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions,
|
||||
};
|
||||
};
|
||||
const paginationProps = usePagination();
|
||||
return wrapSSR(
|
||||
<SchemaComponentOptions
|
||||
scope={{
|
||||
@ -96,18 +141,7 @@ const InternalList = (props) => {
|
||||
<FormLayout layout={layout}>
|
||||
<AntdList
|
||||
{...props}
|
||||
pagination={
|
||||
!meta || !field.value?.length
|
||||
? false
|
||||
: {
|
||||
onChange: onPaginationChange,
|
||||
total: meta?.count || 0,
|
||||
pageSize: meta?.pageSize || 10,
|
||||
current: meta?.page || 1,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions,
|
||||
}
|
||||
}
|
||||
pagination={!meta || !field.value?.length ? false : paginationProps}
|
||||
loading={service?.loading}
|
||||
>
|
||||
{field.value?.length
|
||||
|
Loading…
x
Reference in New Issue
Block a user