From 15d7dcf4afdf51fdaa6b206b4f34e9f97ae7f71a Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 29 Aug 2022 14:44:56 +0800 Subject: [PATCH 1/3] fix(gui-v2): add missing fields, sortArrJson & filterArrJson --- .../components/smartsheet-toolbar/ExportSubActions.vue | 6 ++++++ .../nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/packages/nc-gui-v2/components/smartsheet-toolbar/ExportSubActions.vue b/packages/nc-gui-v2/components/smartsheet-toolbar/ExportSubActions.vue index cca5403190..00fa522865 100644 --- a/packages/nc-gui-v2/components/smartsheet-toolbar/ExportSubActions.vue +++ b/packages/nc-gui-v2/components/smartsheet-toolbar/ExportSubActions.vue @@ -5,6 +5,7 @@ import * as XLSX from 'xlsx' import { message } from 'ant-design-vue' const isPublicView = inject(IsPublicInj, ref(false)) + const fields = inject(FieldsInj, ref([])) const { project } = useProject() @@ -15,6 +16,8 @@ const meta = inject(MetaInj) const selectedView = inject(ActiveViewInj) +const { sorts, nestedFilters } = useSmartsheetStoreOrThrow() + const exportFile = async (exportType: ExportTypes) => { let offset = 0 let c = 1 @@ -36,7 +39,10 @@ const exportFile = async (exportType: ExportTypes) => { { responseType, query: { + fields: fields.value.map((field) => field.title), offset, + sortArrJson: JSON.stringify(sorts.value), + filterArrJson: JSON.stringify(nestedFilters.value), }, } as any, ) diff --git a/packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue b/packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue index 28f9e72c18..db7d1efa3a 100644 --- a/packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue +++ b/packages/nc-gui-v2/components/smartsheet-toolbar/MoreActions.vue @@ -33,6 +33,8 @@ const fields = inject(FieldsInj, ref([])) const selectedView = inject(ActiveViewInj) +const { sorts, nestedFilters } = useSmartsheetStoreOrThrow() + const isLocked = inject(IsLockedInj) const showWebhookDrawer = ref(false) @@ -62,7 +64,10 @@ const exportFile = async (exportType: ExportTypes) => { { responseType, query: { + fields: fields.value.map((field) => field.title), offset, + sortArrJson: JSON.stringify(sorts.value), + filterArrJson: JSON.stringify(nestedFilters.value), }, } as any, ) From 1c6e934efa30052854b8ad033c2b0679e2ed59af Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 29 Aug 2022 14:45:23 +0800 Subject: [PATCH 2/3] fix: include fields, sortArr, and filterArr in extractCsvData --- .../src/lib/meta/api/dataApis/helpers.ts | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts b/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts index 968f062265..059d3473bd 100644 --- a/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts +++ b/packages/nocodb/src/lib/meta/api/dataApis/helpers.ts @@ -65,6 +65,7 @@ export async function extractXlsxData(view: View, req: Request) { export async function extractCsvData(view: View, req: Request) { const base = await Base.get(view.base_id); + const fields = req.query.fields; await view.getModelWithInfo(); await view.getColumns(); @@ -87,7 +88,17 @@ export async function extractCsvData(view: View, req: Request) { const data = papaparse.unparse( { - fields: view.model.columns.map((c) => c.title), + fields: view.model.columns + .sort((c1, c2) => + Array.isArray(fields) + ? fields.indexOf(c1.title as any) - fields.indexOf(c2.title as any) + : 0 + ) + .filter( + (c) => + !fields || !Array.isArray(fields) || fields.includes(c.title as any) + ) + .map((c) => c.title), data: dbRows, }, { @@ -107,6 +118,14 @@ async function getDbRows(baseModel, view: View, req: Request) { const startTime = process.hrtime(); let elapsed, temp; + const listArgs: any = { ...req.query }; + try { + listArgs.filterArr = JSON.parse(listArgs.filterArrJson); + } catch (e) {} + try { + listArgs.sortArr = JSON.parse(listArgs.sortArrJson); + } catch (e) {} + for ( elapsed = 0; elapsed < timeout; @@ -121,7 +140,7 @@ async function getDbRows(baseModel, view: View, req: Request) { model: view.model, view, }), - await baseModel.list({ ...req.query, offset, limit }), + await baseModel.list({ ...listArgs, offset, limit }), {}, req.query ); From 9c554267e930221bbef9147ad73b89d7fbad4f65 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 29 Aug 2022 16:18:17 +0800 Subject: [PATCH 3/3] chore: revise preinstall for npm-force-resolutions --- packages/nocodb-sdk/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb-sdk/package.json b/packages/nocodb-sdk/package.json index ee76ae18e3..e8bc6bdb83 100644 --- a/packages/nocodb-sdk/package.json +++ b/packages/nocodb-sdk/package.json @@ -9,7 +9,7 @@ "license": "MIT", "keywords": [], "scripts": { - "preinstall": "npx npm-force-resolutions", + "preinstall": "npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions", "build": "npm run generate:sdk && run-p build:*", "build:main": "tsc -p tsconfig.json", "build:module": "tsc -p tsconfig.module.json",