mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-04 21:28:34 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
e1c45a5edf
@ -38,7 +38,7 @@ function findArgs(ctx: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function listWithPagination(ctx: Context) {
|
async function listWithPagination(ctx: Context) {
|
||||||
const { page = DEFAULT_PAGE, pageSize = DEFAULT_PER_PAGE } = ctx.action.params;
|
const { page = DEFAULT_PAGE, pageSize = DEFAULT_PER_PAGE, simplePaginate } = ctx.action.params;
|
||||||
|
|
||||||
const repository = getRepositoryFromParams(ctx);
|
const repository = getRepositoryFromParams(ctx);
|
||||||
|
|
||||||
@ -54,15 +54,24 @@ async function listWithPagination(ctx: Context) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const [rows, count] = await repository.findAndCount(options);
|
if (simplePaginate) {
|
||||||
|
const rows = await repository.find(options);
|
||||||
|
ctx.body = {
|
||||||
|
rows,
|
||||||
|
page: Number(page),
|
||||||
|
pageSize: Number(pageSize),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const [rows, count] = await repository.findAndCount(options);
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
count,
|
count,
|
||||||
rows,
|
rows,
|
||||||
page: Number(page),
|
page: Number(page),
|
||||||
pageSize: Number(pageSize),
|
pageSize: Number(pageSize),
|
||||||
totalPage: totalPage(count, pageSize),
|
totalPage: totalPage(count, pageSize),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listWithNonPaged(ctx: Context) {
|
async function listWithNonPaged(ctx: Context) {
|
||||||
|
@ -147,7 +147,7 @@ export const TableBlockProvider = withDynamicSchemaProps((props) => {
|
|||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { getCollection, getCollectionField } = useCollectionManager_deprecated(props.dataSource);
|
const { getCollection, getCollectionField } = useCollectionManager_deprecated(props.dataSource);
|
||||||
const collection = getCollection(props.collection, props.dataSource);
|
const collection = getCollection(props.collection, props.dataSource);
|
||||||
const { treeTable } = fieldSchema?.['x-decorator-props'] || {};
|
const { treeTable, pagingMode } = fieldSchema?.['x-decorator-props'] || {};
|
||||||
const { params, parseVariableLoading } = useTableBlockParamsCompat(props);
|
const { params, parseVariableLoading } = useTableBlockParamsCompat(props);
|
||||||
let childrenColumnName = 'children';
|
let childrenColumnName = 'children';
|
||||||
|
|
||||||
@ -166,6 +166,11 @@ export const TableBlockProvider = withDynamicSchemaProps((props) => {
|
|||||||
params['tree'] = true;
|
params['tree'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pagingMode === 'simplePaginate') {
|
||||||
|
params['simplePaginate'] = true;
|
||||||
|
} else {
|
||||||
|
delete params?.['simplePaginate'];
|
||||||
|
}
|
||||||
const form = useMemo(() => createForm(), [treeTable]);
|
const form = useMemo(() => createForm(), [treeTable]);
|
||||||
|
|
||||||
// 在解析变量的时候不渲染,避免因为重复请求数据导致的资源浪费
|
// 在解析变量的时候不渲染,避免因为重复请求数据导致的资源浪费
|
||||||
|
@ -966,6 +966,8 @@
|
|||||||
"Search": "搜索",
|
"Search": "搜索",
|
||||||
"Clear default value": "清除默认值",
|
"Clear default value": "清除默认值",
|
||||||
"Open in new window": "新窗口打开",
|
"Open in new window": "新窗口打开",
|
||||||
|
"Paging mode": "分页模式",
|
||||||
|
"Simple Paginate": "简单分页",
|
||||||
"Sorry, the page you visited does not exist.": "抱歉,你访问的页面不存在。",
|
"Sorry, the page you visited does not exist.": "抱歉,你访问的页面不存在。",
|
||||||
"Set Template Engine": "设置模板引擎"
|
"Set Template Engine": "设置模板引擎"
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import { setDefaultSortingRulesSchemaSettingsItem } from '../../../../schema-set
|
|||||||
import { setTheDataScopeSchemaSettingsItem } from '../../../../schema-settings/setTheDataScopeSchemaSettingsItem';
|
import { setTheDataScopeSchemaSettingsItem } from '../../../../schema-settings/setTheDataScopeSchemaSettingsItem';
|
||||||
import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider';
|
import { useBlockTemplateContext } from '../../../../schema-templates/BlockTemplateProvider';
|
||||||
import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem';
|
import { setDataLoadingModeSettingsItem } from '../details-multi/setDataLoadingModeSettingsItem';
|
||||||
|
import { SchemaSettingsPagingMode } from '../../../../schema-settings/SchemaSettingsPagingMode';
|
||||||
|
|
||||||
export const tableBlockSettings = new SchemaSettings({
|
export const tableBlockSettings = new SchemaSettings({
|
||||||
name: 'blockSettings:table',
|
name: 'blockSettings:table',
|
||||||
@ -186,6 +187,10 @@ export const tableBlockSettings = new SchemaSettings({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'pagingMode',
|
||||||
|
Component: SchemaSettingsPagingMode,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'ConnectDataBlocks',
|
name: 'ConnectDataBlocks',
|
||||||
Component: SchemaSettingsConnectDataBlocks,
|
Component: SchemaSettingsConnectDataBlocks,
|
||||||
|
@ -264,6 +264,7 @@ const TableIndex = (props) => {
|
|||||||
const usePaginationProps = (pagination1, pagination2) => {
|
const usePaginationProps = (pagination1, pagination2) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const field: any = useField();
|
const field: any = useField();
|
||||||
|
const { token } = useToken();
|
||||||
const pagination = useMemo(
|
const pagination = useMemo(
|
||||||
() => ({ ...pagination1, ...pagination2 }),
|
() => ({ ...pagination1, ...pagination2 }),
|
||||||
[JSON.stringify({ ...pagination1, ...pagination2 })],
|
[JSON.stringify({ ...pagination1, ...pagination2 })],
|
||||||
@ -285,7 +286,7 @@ const usePaginationProps = (pagination1, pagination2) => {
|
|||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
showTotal: false,
|
showTotal: false,
|
||||||
simple: { readOnly: true },
|
simple: true,
|
||||||
showTitle: false,
|
showTitle: false,
|
||||||
showSizeChanger: true,
|
showSizeChanger: true,
|
||||||
hideOnSinglePage: false,
|
hideOnSinglePage: false,
|
||||||
@ -296,6 +297,24 @@ const usePaginationProps = (pagination1, pagination2) => {
|
|||||||
display: none !important;
|
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' }}>{current}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return originalElement;
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [pagination, t, showTotal]);
|
}, [pagination, t, showTotal]);
|
||||||
|
@ -30,7 +30,7 @@ import {
|
|||||||
} from '../../../schema-settings';
|
} from '../../../schema-settings';
|
||||||
import { SchemaSettingsBlockHeightItem } from '../../../schema-settings/SchemaSettingsBlockHeightItem';
|
import { SchemaSettingsBlockHeightItem } from '../../../schema-settings/SchemaSettingsBlockHeightItem';
|
||||||
import { SchemaSettingsBlockTitleItem } from '../../../schema-settings/SchemaSettingsBlockTitleItem';
|
import { SchemaSettingsBlockTitleItem } from '../../../schema-settings/SchemaSettingsBlockTitleItem';
|
||||||
|
import { SchemaSettingsPagingMode } from '../../../schema-settings/SchemaSettingsPagingMode';
|
||||||
import { SchemaSettingsConnectDataBlocks } from '../../../schema-settings/SchemaSettingsConnectDataBlocks';
|
import { SchemaSettingsConnectDataBlocks } from '../../../schema-settings/SchemaSettingsConnectDataBlocks';
|
||||||
import { SchemaSettingsDataScope } from '../../../schema-settings/SchemaSettingsDataScope';
|
import { SchemaSettingsDataScope } from '../../../schema-settings/SchemaSettingsDataScope';
|
||||||
import { SchemaSettingsTemplate } from '../../../schema-settings/SchemaSettingsTemplate';
|
import { SchemaSettingsTemplate } from '../../../schema-settings/SchemaSettingsTemplate';
|
||||||
@ -303,6 +303,7 @@ export const TableBlockDesigner = () => {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<SchemaSettingsPagingMode />
|
||||||
<SchemaSettingsConnectDataBlocks type={FilterBlockType.TABLE} emptyDescription={t('No blocks to connect')} />
|
<SchemaSettingsConnectDataBlocks type={FilterBlockType.TABLE} emptyDescription={t('No blocks to connect')} />
|
||||||
{supportTemplate && <SchemaSettingsDivider />}
|
{supportTemplate && <SchemaSettingsDivider />}
|
||||||
{supportTemplate && (
|
{supportTemplate && (
|
||||||
|
@ -219,6 +219,10 @@ describe('Table.settings', () => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Paging mode',
|
||||||
|
type: 'select',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'Save as template',
|
title: 'Save as template',
|
||||||
type: 'modal',
|
type: 'modal',
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* This file is part of the NocoBase (R) project.
|
||||||
|
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
||||||
|
* Authors: NocoBase Team.
|
||||||
|
*
|
||||||
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||||
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Field } from '@formily/core';
|
||||||
|
import { useField, useFieldSchema } from '@formily/react';
|
||||||
|
import React from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useTableBlockContext } from '../block-provider';
|
||||||
|
import { useDesignable } from '../schema-component/hooks/useDesignable';
|
||||||
|
import { SchemaSettingsSelectItem } from './SchemaSettings';
|
||||||
|
|
||||||
|
export function SchemaSettingsPagingMode() {
|
||||||
|
const field = useField<Field>();
|
||||||
|
const fieldSchema = useFieldSchema();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { dn } = useDesignable();
|
||||||
|
const { service } = useTableBlockContext();
|
||||||
|
const options = [
|
||||||
|
{
|
||||||
|
value: 'default',
|
||||||
|
label: t('Default'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'simplePaginate',
|
||||||
|
label: t('Simple Paginate'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SchemaSettingsSelectItem
|
||||||
|
key="paging-mode"
|
||||||
|
title={t('Paging mode')}
|
||||||
|
options={options}
|
||||||
|
value={field.decoratorProps.pagingMode || 'default'}
|
||||||
|
onChange={(pagingMode) => {
|
||||||
|
fieldSchema['x-decorator-props'].pagingMode = pagingMode;
|
||||||
|
const params = { ...service.params?.[0] };
|
||||||
|
if (pagingMode === 'simplePaginate') {
|
||||||
|
params['simplePaginate'] = true;
|
||||||
|
} else {
|
||||||
|
delete params['simplePaginate'];
|
||||||
|
}
|
||||||
|
service.run({ params });
|
||||||
|
field.decoratorProps.pagingMode = pagingMode;
|
||||||
|
dn.emit('patch', {
|
||||||
|
schema: {
|
||||||
|
['x-uid']: fieldSchema['x-uid'],
|
||||||
|
'x-decorator-props': fieldSchema['x-decorator-props'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
dn.refresh();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
@ -21,6 +21,7 @@ export * from './SchemaSettingsSortingRule';
|
|||||||
export * from './SchemaSettingsTemplate';
|
export * from './SchemaSettingsTemplate';
|
||||||
export * from './SchemaSettingsBlockHeightItem';
|
export * from './SchemaSettingsBlockHeightItem';
|
||||||
export * from './setDefaultSortingRulesSchemaSettingsItem';
|
export * from './setDefaultSortingRulesSchemaSettingsItem';
|
||||||
|
export * from './SchemaSettingsPagingMode';
|
||||||
export * from './setTheDataScopeSchemaSettingsItem';
|
export * from './setTheDataScopeSchemaSettingsItem';
|
||||||
export * from './SchemaSettingsRenderEngine';
|
export * from './SchemaSettingsRenderEngine';
|
||||||
export * from './hooks/useGetAriaLabelOfDesigner';
|
export * from './hooks/useGetAriaLabelOfDesigner';
|
||||||
|
@ -38,7 +38,7 @@ function findArgs(ctx: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function listWithPagination(ctx: Context) {
|
async function listWithPagination(ctx: Context) {
|
||||||
const { page = 1, pageSize = 50 } = ctx.action.params;
|
const { page = 1, pageSize = 50, simplePaginate } = ctx.action.params;
|
||||||
|
|
||||||
const repository = ctx.getCurrentRepository();
|
const repository = ctx.getCurrentRepository();
|
||||||
|
|
||||||
@ -54,15 +54,24 @@ async function listWithPagination(ctx: Context) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const [rows, count] = await repository.findAndCount(options);
|
if (simplePaginate) {
|
||||||
|
const rows = await repository.find(options);
|
||||||
|
ctx.body = {
|
||||||
|
rows,
|
||||||
|
page: Number(page),
|
||||||
|
pageSize: Number(pageSize),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const [rows, count] = await repository.findAndCount(options);
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
count,
|
count,
|
||||||
rows,
|
rows,
|
||||||
page: Number(page),
|
page: Number(page),
|
||||||
pageSize: Number(pageSize),
|
pageSize: Number(pageSize),
|
||||||
totalPage: totalPage(count, pageSize),
|
totalPage: totalPage(count, pageSize),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listWithNonPaged(ctx: Context) {
|
async function listWithNonPaged(ctx: Context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user