mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-04 13:18:55 +08:00
fix(plugin-acl): missing pagination parameters #394
This commit is contained in:
parent
4cc162d1c1
commit
b44753d528
@ -196,7 +196,10 @@ export const ActionDesigner = (props) => {
|
||||
{isValid(fieldSchema?.['x-action-settings']?.['onSuccess']) && (
|
||||
<SchemaSettings.ModalItem
|
||||
title={
|
||||
compile(fieldSchema?.['x-action-settings']?.['onSuccess']?.['title']) ?? t('After successful submission')
|
||||
{
|
||||
'customize:save': t('After successful save'),
|
||||
'customize:update': t('After successful update'),
|
||||
}[actionType]
|
||||
}
|
||||
initialValues={fieldSchema?.['x-action-settings']?.['onSuccess']}
|
||||
schema={
|
||||
|
@ -2,18 +2,24 @@ import { Database } from '@nocobase/database';
|
||||
|
||||
type UsingConfigType = 'strategy' | 'resourceAction';
|
||||
|
||||
function totalPage(total, pageSize): number {
|
||||
return Math.ceil(total / pageSize);
|
||||
}
|
||||
|
||||
const roleCollectionsResource = {
|
||||
name: 'roles.collections',
|
||||
actions: {
|
||||
async list(ctx, next) {
|
||||
const role = ctx.action.params.associatedIndex;
|
||||
const { page = 1, pageSize = 20 } = ctx.action.params;
|
||||
|
||||
const db: Database = ctx.db;
|
||||
const collectionRepository = db.getRepository('collections');
|
||||
|
||||
// all collections
|
||||
const collections = await collectionRepository.find({
|
||||
const [collections, count] = await collectionRepository.findAndCount({
|
||||
filter: ctx.action.params.filter,
|
||||
sort: 'sort',
|
||||
});
|
||||
|
||||
// role collections
|
||||
@ -29,8 +35,9 @@ const roleCollectionsResource = {
|
||||
.filter((roleResources) => roleResources.get('usingActionsConfig'))
|
||||
.map((roleResources) => roleResources.get('name'));
|
||||
|
||||
ctx.body = collections
|
||||
.map((collection) => {
|
||||
ctx.body = {
|
||||
count,
|
||||
rows: collections.map((collection) => {
|
||||
const exists = roleResourcesNames.includes(collection.get('name'));
|
||||
|
||||
const usingConfig: UsingConfigType = roleResourceActionResourceNames.includes(collection.get('name'))
|
||||
@ -44,8 +51,11 @@ const roleCollectionsResource = {
|
||||
usingConfig,
|
||||
exists,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => (a.name > b.name ? 1 : -1));
|
||||
}),
|
||||
page: Number(page),
|
||||
pageSize: Number(pageSize),
|
||||
totalPage: totalPage(count, pageSize),
|
||||
};
|
||||
|
||||
await next();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user