mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-09 15:39:24 +08:00
* refactor: support simple Paginate * chore: simple paginate * refactor: simplePaginate * fix: test * refactor: usePaginationProps * refactor: simplePaginate * fix: bug --------- Co-authored-by: Chareice <chareice@live.com>
62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
/**
|
|
* 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();
|
|
}}
|
|
/>
|
|
);
|
|
}
|