@nocobase/actions 1.3.26-beta → 1.3.28-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions/list.js +7 -5
- package/package.json +5 -5
package/lib/actions/list.js
CHANGED
|
@@ -30,7 +30,7 @@ __export(list_exports, {
|
|
|
30
30
|
list: () => list
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(list_exports);
|
|
33
|
-
var
|
|
33
|
+
var import_utils = require("../utils");
|
|
34
34
|
var import_constants = require("../constants");
|
|
35
35
|
function totalPage(total, pageSize) {
|
|
36
36
|
return Math.ceil(total / pageSize);
|
|
@@ -51,12 +51,12 @@ __name(findArgs, "findArgs");
|
|
|
51
51
|
async function listWithPagination(ctx) {
|
|
52
52
|
var _a;
|
|
53
53
|
const { page = import_constants.DEFAULT_PAGE, pageSize = import_constants.DEFAULT_PER_PAGE } = ctx.action.params;
|
|
54
|
-
const repository = (0,
|
|
54
|
+
const repository = (0, import_utils.getRepositoryFromParams)(ctx);
|
|
55
55
|
const { simplePaginate } = ((_a = repository.collection) == null ? void 0 : _a.options) || {};
|
|
56
56
|
const options = {
|
|
57
57
|
context: ctx,
|
|
58
58
|
...findArgs(ctx),
|
|
59
|
-
...(0,
|
|
59
|
+
...(0, import_utils.pageArgsToLimitArgs)(parseInt(String(page)), parseInt(String(pageSize)))
|
|
60
60
|
};
|
|
61
61
|
Object.keys(options).forEach((key) => {
|
|
62
62
|
if (options[key] === void 0) {
|
|
@@ -64,9 +64,11 @@ async function listWithPagination(ctx) {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
if (simplePaginate) {
|
|
67
|
+
options.limit = options.limit + 1;
|
|
67
68
|
const rows = await repository.find(options);
|
|
68
69
|
ctx.body = {
|
|
69
|
-
rows,
|
|
70
|
+
rows: rows.slice(0, pageSize),
|
|
71
|
+
hasNext: rows.length > pageSize,
|
|
70
72
|
page: Number(page),
|
|
71
73
|
pageSize: Number(pageSize)
|
|
72
74
|
};
|
|
@@ -83,7 +85,7 @@ async function listWithPagination(ctx) {
|
|
|
83
85
|
}
|
|
84
86
|
__name(listWithPagination, "listWithPagination");
|
|
85
87
|
async function listWithNonPaged(ctx) {
|
|
86
|
-
const repository = (0,
|
|
88
|
+
const repository = (0, import_utils.getRepositoryFromParams)(ctx);
|
|
87
89
|
const rows = await repository.find({ context: ctx, ...findArgs(ctx) });
|
|
88
90
|
ctx.body = rows;
|
|
89
91
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/actions",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.28-beta",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/cache": "1.3.
|
|
10
|
-
"@nocobase/database": "1.3.
|
|
11
|
-
"@nocobase/resourcer": "1.3.
|
|
9
|
+
"@nocobase/cache": "1.3.28-beta",
|
|
10
|
+
"@nocobase/database": "1.3.28-beta",
|
|
11
|
+
"@nocobase/resourcer": "1.3.28-beta"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
16
16
|
"directory": "packages/actions"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "d8edc9ed826c02e3a147c18a918f675b277784f7"
|
|
19
19
|
}
|