mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 12:06:47 +00: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']) && (
|
{isValid(fieldSchema?.['x-action-settings']?.['onSuccess']) && (
|
||||||
<SchemaSettings.ModalItem
|
<SchemaSettings.ModalItem
|
||||||
title={
|
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']}
|
initialValues={fieldSchema?.['x-action-settings']?.['onSuccess']}
|
||||||
schema={
|
schema={
|
||||||
|
@ -2,18 +2,24 @@ import { Database } from '@nocobase/database';
|
|||||||
|
|
||||||
type UsingConfigType = 'strategy' | 'resourceAction';
|
type UsingConfigType = 'strategy' | 'resourceAction';
|
||||||
|
|
||||||
|
function totalPage(total, pageSize): number {
|
||||||
|
return Math.ceil(total / pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
const roleCollectionsResource = {
|
const roleCollectionsResource = {
|
||||||
name: 'roles.collections',
|
name: 'roles.collections',
|
||||||
actions: {
|
actions: {
|
||||||
async list(ctx, next) {
|
async list(ctx, next) {
|
||||||
const role = ctx.action.params.associatedIndex;
|
const role = ctx.action.params.associatedIndex;
|
||||||
|
const { page = 1, pageSize = 20 } = ctx.action.params;
|
||||||
|
|
||||||
const db: Database = ctx.db;
|
const db: Database = ctx.db;
|
||||||
const collectionRepository = db.getRepository('collections');
|
const collectionRepository = db.getRepository('collections');
|
||||||
|
|
||||||
// all collections
|
// all collections
|
||||||
const collections = await collectionRepository.find({
|
const [collections, count] = await collectionRepository.findAndCount({
|
||||||
filter: ctx.action.params.filter,
|
filter: ctx.action.params.filter,
|
||||||
|
sort: 'sort',
|
||||||
});
|
});
|
||||||
|
|
||||||
// role collections
|
// role collections
|
||||||
@ -29,8 +35,9 @@ const roleCollectionsResource = {
|
|||||||
.filter((roleResources) => roleResources.get('usingActionsConfig'))
|
.filter((roleResources) => roleResources.get('usingActionsConfig'))
|
||||||
.map((roleResources) => roleResources.get('name'));
|
.map((roleResources) => roleResources.get('name'));
|
||||||
|
|
||||||
ctx.body = collections
|
ctx.body = {
|
||||||
.map((collection) => {
|
count,
|
||||||
|
rows: collections.map((collection) => {
|
||||||
const exists = roleResourcesNames.includes(collection.get('name'));
|
const exists = roleResourcesNames.includes(collection.get('name'));
|
||||||
|
|
||||||
const usingConfig: UsingConfigType = roleResourceActionResourceNames.includes(collection.get('name'))
|
const usingConfig: UsingConfigType = roleResourceActionResourceNames.includes(collection.get('name'))
|
||||||
@ -44,8 +51,11 @@ const roleCollectionsResource = {
|
|||||||
usingConfig,
|
usingConfig,
|
||||||
exists,
|
exists,
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
.sort((a, b) => (a.name > b.name ? 1 : -1));
|
page: Number(page),
|
||||||
|
pageSize: Number(pageSize),
|
||||||
|
totalPage: totalPage(count, pageSize),
|
||||||
|
};
|
||||||
|
|
||||||
await next();
|
await next();
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user