From 478b5c01163bd5aa6a6e2acd276d9d47a89b4f0c Mon Sep 17 00:00:00 2001 From: MenahemOwlytics <91820209+MenahemOwlytics@users.noreply.github.com> Date: Thu, 29 Dec 2022 12:13:06 +0200 Subject: [PATCH] fix: parse Json --- lib/components/ExportComponent.jsx | 2 +- lib/importExportFeature.js | 4 ++-- lib/utils.js | 2 +- src/utils.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/components/ExportComponent.jsx b/lib/components/ExportComponent.jsx index 39d191a..ac7a0e4 100644 --- a/lib/components/ExportComponent.jsx +++ b/lib/components/ExportComponent.jsx @@ -35,7 +35,7 @@ const ExportComponent = ({ resource }) => { actionName: 'export', params: { type, - filter + filter, }, }); const blob = new Blob([exportedData], { type: exports.mimeTypes[type] }); diff --git a/lib/importExportFeature.js b/lib/importExportFeature.js index 61496bd..6795b78 100644 --- a/lib/importExportFeature.js +++ b/lib/importExportFeature.js @@ -13,13 +13,13 @@ const importExportFeature = () => { handler: (0, utils_1.postActionHandler)(export_handler_1.exportHandler), component: EXPORT_COMPONENT, actionType: 'resource', - showFilter: true + showFilter: true, }, import: { handler: (0, utils_1.postActionHandler)(import_handler_1.importHandler), component: IMPORT_COMPONENT, actionType: 'resource', - showFilter: true + showFilter: true, }, }, }); diff --git a/lib/utils.js b/lib/utils.js index e8c7972..04a0628 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -54,7 +54,7 @@ const getRecords = async (context, request) => { .properties() .find(p => p.isId())) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.call(_a); const titleProperty = (_d = (_c = context.resource.decorate().titleProperty()) === null || _c === void 0 ? void 0 : _c.name) === null || _d === void 0 ? void 0 : _d.call(_c); - return context.resource.find(new adminjs_1.Filter(((_e = request === null || request === void 0 ? void 0 : request.query) === null || _e === void 0 ? void 0 : _e.filter) ? JSON.stringify((_f = request === null || request === void 0 ? void 0 : request.query) === null || _f === void 0 ? void 0 : _f.filter) : {}, context.resource), { + return context.resource.find(new adminjs_1.Filter(((_e = request === null || request === void 0 ? void 0 : request.query) === null || _e === void 0 ? void 0 : _e.filter) ? JSON.parse((_f = request === null || request === void 0 ? void 0 : request.query) === null || _f === void 0 ? void 0 : _f.filter) : {}, context.resource), { limit: Number.MAX_SAFE_INTEGER, sort: { sortBy: idProperty !== null && idProperty !== void 0 ? idProperty : titleProperty, diff --git a/src/utils.ts b/src/utils.ts index bcc6cf2..03a6c75 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -77,7 +77,7 @@ export const getRecords = async ( return context.resource.find( new Filter( - request?.query?.filter ? JSON.stringify(request?.query?.filter) : {}, + request?.query?.filter ? JSON.parse(request?.query?.filter) : {}, context.resource ), {