identity-admin 1.23.0 → 1.23.1
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.
|
@@ -348,6 +348,7 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
348
348
|
const recordId = req.params.id;
|
|
349
349
|
const resource = (_a = this.resource) !== null && _a !== void 0 ? _a : (0, ResourceUtils_1.getResource)(modelName, (_b = this.resources) !== null && _b !== void 0 ? _b : []);
|
|
350
350
|
const currentUser = req.user;
|
|
351
|
+
const model = resource === null || resource === void 0 ? void 0 : resource.properties.resource;
|
|
351
352
|
if (!resource) {
|
|
352
353
|
return ResponseUtils_1.default.notFound(res, "Resource not found", []);
|
|
353
354
|
}
|
|
@@ -379,7 +380,21 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
379
380
|
if (afterMethod && record) {
|
|
380
381
|
extras = yield afterMethod(req, record);
|
|
381
382
|
}
|
|
382
|
-
|
|
383
|
+
const sortBy = modifiedResource.properties.defaultOrderBy;
|
|
384
|
+
const nextQuery = {};
|
|
385
|
+
const prevQuery = {};
|
|
386
|
+
const nextSortQuery = {};
|
|
387
|
+
const prevSortQuery = {};
|
|
388
|
+
nextQuery[sortBy] = { $gt: record[sortBy] };
|
|
389
|
+
prevQuery[sortBy] = { $lt: record[sortBy] };
|
|
390
|
+
nextSortQuery[sortBy] = 1;
|
|
391
|
+
prevSortQuery[sortBy] = -1;
|
|
392
|
+
const next = yield (model === null || model === void 0 ? void 0 : model.findOne(nextQuery).sort(nextSortQuery).limit(1));
|
|
393
|
+
const previous = yield (model === null || model === void 0 ? void 0 : model.findOne(prevQuery).sort(prevSortQuery).limit(1));
|
|
394
|
+
const hasNext = record && next && next._id ? true : false;
|
|
395
|
+
const hasPrevious = record && previous && previous._id ? true : false;
|
|
396
|
+
return ResponseUtils_1.default.ok(res, Object.assign(Object.assign({}, extras), { record: record ? record : null, hasNext,
|
|
397
|
+
hasPrevious, nextId: hasNext ? next === null || next === void 0 ? void 0 : next._id : undefined, previousId: hasPrevious ? previous === null || previous === void 0 ? void 0 : previous._id : undefined }));
|
|
383
398
|
});
|
|
384
399
|
}
|
|
385
400
|
deleteAll(req, res) {
|