From 10633df624346a07ab0fc1b1bc10677253e45279 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 12:24:05 +0800 Subject: [PATCH 01/21] fix(nc-gui): include kanban grouping field --- packages/nc-gui/composables/useSharedView.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/composables/useSharedView.ts b/packages/nc-gui/composables/useSharedView.ts index 89ee00b4b6..d349a7c38f 100644 --- a/packages/nc-gui/composables/useSharedView.ts +++ b/packages/nc-gui/composables/useSharedView.ts @@ -9,7 +9,7 @@ import type { TableType, ViewType, } from 'nocodb-sdk' -import { UITypes } from 'nocodb-sdk' +import { UITypes, ViewTypes } from 'nocodb-sdk' import { computed, useGlobal, useMetas, useNuxtApp, useState } from '#imports' export function useSharedView() { @@ -70,8 +70,17 @@ export function useSharedView() { meta.value = { ...viewMeta.model } let order = 1 + + // include kanban grouping field column to share view + // even it is unselected in Fields + // so that it won't break kanban share view + let kanbanGroupingFieldId = '' + if (viewMeta.type === ViewTypes.KANBAN) { + kanbanGroupingFieldId = (await $api.dbView.kanbanRead(viewMeta.id)).fk_grp_col_id! + } + meta.value!.columns = [...viewMeta.model.columns] - .filter((c) => c.show) + .filter((c) => c.show || (viewMeta.type === ViewTypes.KANBAN && c.id === kanbanGroupingFieldId)) .map((c) => ({ ...c, order: order++ })) .sort((a, b) => a.order - b.order) From a09068ecd64d81452e0bdfeea53b9436435fadf8 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 12:24:13 +0800 Subject: [PATCH 02/21] fix(nocodb): include kanban grouping field --- .../src/lib/meta/api/publicApis/publicMetaApis.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts b/packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts index cac3f8a8cb..a57e65f2ee 100644 --- a/packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts +++ b/packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts @@ -7,9 +7,11 @@ import { LinkToAnotherRecordType, RelationTypes, UITypes, + ViewTypes, } from 'nocodb-sdk'; import Column from '../../../models/Column'; import Base from '../../../models/Base'; +import KanbanView from '../../../models/KanbanView'; import Project from '../../../models/Project'; import LinkToAnotherRecordColumn from '../../../models/LinkToAnotherRecordColumn'; @@ -39,13 +41,21 @@ export async function viewMetaGet(req: Request, res: Response) { // todo: return only required props delete view['password']; - // const columnsById = c; + // include kanban grouping field column to share view + // even it is unselected in Fields + // so that it won't break kanban share view + let kanbanGroupingFieldId; + if (view.type === ViewTypes.KANBAN) { + kanbanGroupingFieldId = (await KanbanView.get(view.id)).fk_grp_col_id; + } view.model.columns = view.columns .filter((c) => { const column = view.model.columnsById[c.fk_column_id]; return ( c.show || + (view.type === ViewTypes.KANBAN && + c.fk_column_id === kanbanGroupingFieldId) || (column.rqd && !column.cdf && !column.ai) || column.pk || view.model.columns.some( From 0d847375178ed7922a1530d7f2c3d7b0d37a3183 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 14:23:48 +0800 Subject: [PATCH 03/21] feat(sdk): add column get api --- .../nocodb/src/lib/meta/api/columnApis.ts | 14 +++++++++ scripts/sdk/swagger.json | 31 ++++++++++++------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/columnApis.ts b/packages/nocodb/src/lib/meta/api/columnApis.ts index aaec69a65e..f16b8d3f8c 100644 --- a/packages/nocodb/src/lib/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/meta/api/columnApis.ts @@ -101,6 +101,10 @@ async function createHmAndBtColumn( } } +export async function columnGet(req: Request, res: Response) { + res.json(await Column.get({ colId: req.params.columnId })); +} + export async function columnAdd( req: Request, res: Response @@ -1811,21 +1815,31 @@ async function createColumnIndex({ } const router = Router({ mergeParams: true }); + router.post( '/api/v1/db/meta/tables/:tableId/columns/', metaApiMetrics, ncMetaAclMw(columnAdd, 'columnAdd') ); + router.patch( '/api/v1/db/meta/columns/:columnId', metaApiMetrics, ncMetaAclMw(columnUpdate, 'columnUpdate') ); + router.delete( '/api/v1/db/meta/columns/:columnId', metaApiMetrics, ncMetaAclMw(columnDelete, 'columnDelete') ); + +router.get( + '/api/v1/db/meta/columns/:columnId', + metaApiMetrics, + ncMetaAclMw(columnGet, 'columnGet') +); + router.post( '/api/v1/db/meta/columns/:columnId/primary', metaApiMetrics, diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index 9bc4fc64f2..bc6b326c92 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -1972,8 +1972,7 @@ "project_id": { "type": "string" }, - "meta": { - } + "meta": {} } } } @@ -2105,7 +2104,7 @@ ] }, "delete": { - "summary": "", + "summary": "Column Delete", "operationId": "db-table-column-delete", "responses": { "200": { @@ -2115,6 +2114,18 @@ "tags": [ "DB table column" ] + }, + "get": { + "summary": "Column Get", + "operationId": "db-table-column-get", + "responses": { + "200": { + "description": "OK" + } + }, + "tags": [ + "DB Table Column" + ] } }, "/api/v1/db/meta/columns/{columnId}/primary": { @@ -2194,8 +2205,7 @@ "order": { "type": "number" }, - "meta": { - }, + "meta": {}, "title": { "type": "string" }, @@ -7492,8 +7502,7 @@ "number" ] }, - "meta": { - } + "meta": {} }, "required": [ "table_name", @@ -7591,8 +7600,7 @@ "uuid": { "type": "string" }, - "meta": { - }, + "meta": {}, "show_system_fields": { "type": "boolean" }, @@ -7835,8 +7843,7 @@ "$ref": "#/components/schemas/Column" } }, - "meta": { - } + "meta": {} }, "required": [ "table_name", @@ -10042,4 +10049,4 @@ } } } -} +} \ No newline at end of file From 07bf406c77f704e11aa3538d98b17f117a4ccb02 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 14:24:05 +0800 Subject: [PATCH 04/21] feat(sdk): add column get api --- packages/nocodb-sdk/src/lib/Api.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 0b94ec37fe..2dc2830f19 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -2264,6 +2264,7 @@ export class Api< * * @tags DB table column * @name Delete + * @summary Column Delete * @request DELETE:/api/v1/db/meta/columns/{columnId} * @response `200` `void` OK */ @@ -2274,6 +2275,22 @@ export class Api< ...params, }), + /** + * No description + * + * @tags DB Table Column + * @name Get + * @summary Column Get + * @request GET:/api/v1/db/meta/columns/{columnId} + * @response `200` `void` OK + */ + get: (columnId: string, params: RequestParams = {}) => + this.request({ + path: `/api/v1/db/meta/columns/${columnId}`, + method: 'GET', + ...params, + }), + /** * No description * From 2adbc68fce88e4592b8d269937e321cebad4c988 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 14:28:22 +0800 Subject: [PATCH 05/21] fix(nc-gui): get groupingFieldColumn logic --- packages/nc-gui/composables/useKanbanViewStore.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/composables/useKanbanViewStore.ts b/packages/nc-gui/composables/useKanbanViewStore.ts index e75351e669..4beaf05004 100644 --- a/packages/nc-gui/composables/useKanbanViewStore.ts +++ b/packages/nc-gui/composables/useKanbanViewStore.ts @@ -145,7 +145,8 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), where, }) - : await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value }) + : // TODO: add range + await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value }) formattedData.value.set(stackTitle, [...formattedData.value.get(stackTitle)!, ...formatData(response.list)]) } @@ -155,9 +156,11 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( kanbanMetaData.value = isPublic.value ? (sharedView.value?.view as KanbanType) : await $api.dbView.kanbanRead(viewMeta.value.id) + // set groupingField - groupingFieldColumn.value = - (meta.value.columns as ColumnType[]).filter((f) => f.id === kanbanMetaData.value.fk_grp_col_id)[0] || {} + // avoid getting from meta.value.columns + // it would be undefiend as grouping field can be unselected before passing to share view + groupingFieldColumn.value = (await $api.dbTableColumn.get(kanbanMetaData.value.fk_grp_col_id!))! as ColumnType groupingField.value = groupingFieldColumn.value.title! From b9935d14cb14ddccd39bc4713fa6c8d27f1fa128 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 14:48:31 +0800 Subject: [PATCH 06/21] fix(nc-gui): exclude kanban fk_grp_col_id from meta.value.columns --- packages/nc-gui/composables/useSharedView.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/nc-gui/composables/useSharedView.ts b/packages/nc-gui/composables/useSharedView.ts index d349a7c38f..93477fadbc 100644 --- a/packages/nc-gui/composables/useSharedView.ts +++ b/packages/nc-gui/composables/useSharedView.ts @@ -9,7 +9,7 @@ import type { TableType, ViewType, } from 'nocodb-sdk' -import { UITypes, ViewTypes } from 'nocodb-sdk' +import { UITypes } from 'nocodb-sdk' import { computed, useGlobal, useMetas, useNuxtApp, useState } from '#imports' export function useSharedView() { @@ -71,16 +71,8 @@ export function useSharedView() { let order = 1 - // include kanban grouping field column to share view - // even it is unselected in Fields - // so that it won't break kanban share view - let kanbanGroupingFieldId = '' - if (viewMeta.type === ViewTypes.KANBAN) { - kanbanGroupingFieldId = (await $api.dbView.kanbanRead(viewMeta.id)).fk_grp_col_id! - } - meta.value!.columns = [...viewMeta.model.columns] - .filter((c) => c.show || (viewMeta.type === ViewTypes.KANBAN && c.id === kanbanGroupingFieldId)) + .filter((c) => c.show) .map((c) => ({ ...c, order: order++ })) .sort((a, b) => a.order - b.order) From 00dbc6ecd5e6e76c242e4db785fe8ef9a1399c7b Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 14:48:37 +0800 Subject: [PATCH 07/21] fix(nocodb): exclude kanban fk_grp_col_id from meta.value.columns --- .../src/lib/meta/api/publicApis/publicMetaApis.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts b/packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts index a57e65f2ee..9bb4aaf946 100644 --- a/packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts +++ b/packages/nocodb/src/lib/meta/api/publicApis/publicMetaApis.ts @@ -7,11 +7,9 @@ import { LinkToAnotherRecordType, RelationTypes, UITypes, - ViewTypes, } from 'nocodb-sdk'; import Column from '../../../models/Column'; import Base from '../../../models/Base'; -import KanbanView from '../../../models/KanbanView'; import Project from '../../../models/Project'; import LinkToAnotherRecordColumn from '../../../models/LinkToAnotherRecordColumn'; @@ -41,21 +39,11 @@ export async function viewMetaGet(req: Request, res: Response) { // todo: return only required props delete view['password']; - // include kanban grouping field column to share view - // even it is unselected in Fields - // so that it won't break kanban share view - let kanbanGroupingFieldId; - if (view.type === ViewTypes.KANBAN) { - kanbanGroupingFieldId = (await KanbanView.get(view.id)).fk_grp_col_id; - } - view.model.columns = view.columns .filter((c) => { const column = view.model.columnsById[c.fk_column_id]; return ( c.show || - (view.type === ViewTypes.KANBAN && - c.fk_column_id === kanbanGroupingFieldId) || (column.rqd && !column.cdf && !column.ai) || column.pk || view.model.columns.some( From 653312773dca96705ca7f21a979810e87d7c6fcb Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 14:49:34 +0800 Subject: [PATCH 08/21] fix(nc-gui): prohibit to display unshared cover image column --- .../smartsheet/toolbar/FieldsMenu.vue | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue index d2b6eda8cb..8a3f66dada 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue @@ -84,11 +84,31 @@ const onMove = (_event: { moved: { newIndex: number } }) => { $e('a:fields:reorder') } +const coverOptions = computed(() => { + const filterFields = + fields.value + ?.filter((el) => el.fk_column_id && metaColumnById.value[el.fk_column_id].uidt === UITypes.Attachment) + .map((field) => { + return { + value: field.fk_column_id, + label: field.title, + } + }) ?? [] + return [{ value: null, label: 'No Image' }, ...filterFields] +}) + const coverImageColumnId = computed({ - get: () => - (activeView.value?.type === ViewTypes.GALLERY || activeView.value?.type === ViewTypes.KANBAN) && activeView.value?.view - ? (activeView.value?.view as GalleryType).fk_cover_image_col_id - : undefined, + get: () => { + const fk_cover_image_col_id = + (activeView.value?.type === ViewTypes.GALLERY || activeView.value?.type === ViewTypes.KANBAN) && activeView.value?.view + ? (activeView.value?.view as GalleryType).fk_cover_image_col_id + : undefined + // check if `fk_cover_image_col_id` is in `coverOptions` + // e.g. in share view, users may not share the cover image column + if (coverOptions.value?.find((o) => o.value === fk_cover_image_col_id)) return fk_cover_image_col_id + // set to `No Image` + return null + }, set: async (val) => { if ( (activeView.value?.type === ViewTypes.GALLERY || activeView.value?.type === ViewTypes.KANBAN) && @@ -113,19 +133,6 @@ const coverImageColumnId = computed({ }, }) -const coverOptions = computed(() => { - const filterFields = - fields.value - ?.filter((el) => el.fk_column_id && metaColumnById.value[el.fk_column_id].uidt === UITypes.Attachment) - .map((field) => { - return { - value: field.fk_column_id, - label: field.title, - } - }) ?? [] - return [{ value: null, label: 'No Image' }, ...filterFields] -}) - const getIcon = (c: ColumnType) => h(isVirtualCol(c) ? resolveComponent('SmartsheetHeaderVirtualCellIcon') : resolveComponent('SmartsheetHeaderCellIcon'), { columnMeta: c, From 10421b8370d19d740b6f1c433ff854cf15d6f7be Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 17:16:41 +0800 Subject: [PATCH 09/21] feat(sdk): add offset to list --- packages/nocodb-sdk/src/lib/Api.ts | 1 + scripts/sdk/swagger.json | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 2dc2830f19..7b619c0d85 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -3593,6 +3593,7 @@ export class Api< where?: string; /** Query params for nested data */ nested?: any; + offset?: number; }, params: RequestParams = {} ) => diff --git a/scripts/sdk/swagger.json b/scripts/sdk/swagger.json index bc6b326c92..62fb7a6df3 100644 --- a/scripts/sdk/swagger.json +++ b/scripts/sdk/swagger.json @@ -3887,6 +3887,13 @@ "in": "query", "name": "nested", "description": "Query params for nested data" + }, + { + "schema": { + "type": "number" + }, + "in": "query", + "name": "offset" } ], "responses": { From 8b84a76bcb26884695d5bf8ca831f38d35f6cc07 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 16 Jan 2023 17:22:00 +0800 Subject: [PATCH 10/21] fix(nc-gui): include offset in fetchSharedViewData --- .../nc-gui/composables/useKanbanViewStore.ts | 3 +-- packages/nc-gui/composables/useSharedView.ts | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/composables/useKanbanViewStore.ts b/packages/nc-gui/composables/useKanbanViewStore.ts index 4beaf05004..dcd4110e6b 100644 --- a/packages/nc-gui/composables/useKanbanViewStore.ts +++ b/packages/nc-gui/composables/useKanbanViewStore.ts @@ -145,8 +145,7 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), where, }) - : // TODO: add range - await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value }) + : await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value, offset: params.offset }) formattedData.value.set(stackTitle, [...formattedData.value.get(stackTitle)!, ...formatData(response.list)]) } diff --git a/packages/nc-gui/composables/useSharedView.ts b/packages/nc-gui/composables/useSharedView.ts index 93477fadbc..c3129a95a0 100644 --- a/packages/nc-gui/composables/useSharedView.ts +++ b/packages/nc-gui/composables/useSharedView.ts @@ -93,16 +93,27 @@ export function useSharedView() { Object.keys(relatedMetas).forEach((key) => setMeta(relatedMetas[key])) } - const fetchSharedViewData = async ({ sortsArr, filtersArr }: { sortsArr: SortType[]; filtersArr: FilterType[] }) => { + const fetchSharedViewData = async ({ + sortsArr, + filtersArr, + offset, + }: { + sortsArr: SortType[] + filtersArr: FilterType[] + offset?: number + }) => { if (!sharedView.value) return - const page = paginationData.value.page || 1 - const pageSize = paginationData.value.pageSize || appInfoDefaultLimit + if (!offset) { + const page = paginationData.value.page || 1 + const pageSize = paginationData.value.pageSize || appInfoDefaultLimit + offset = (page - 1) * pageSize + } const { data } = await $api.public.dataList( sharedView.value.uuid!, { - offset: (page - 1) * pageSize, + offset, filterArrJson: JSON.stringify(filtersArr ?? nestedFilters.value), sortArrJson: JSON.stringify(sortsArr ?? sorts.value), } as any, From a0e2deacf3cadb7d1c7543cf2c20f8c4de50c84b Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Tue, 17 Jan 2023 17:47:01 +0530 Subject: [PATCH 11/21] test: kanban shared view access after sign-off Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/tests/viewKanban.spec.ts | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/playwright/tests/viewKanban.spec.ts b/tests/playwright/tests/viewKanban.spec.ts index 0fe4ab45f7..bca3777179 100644 --- a/tests/playwright/tests/viewKanban.spec.ts +++ b/tests/playwright/tests/viewKanban.spec.ts @@ -301,4 +301,30 @@ test.describe('View', () => { count: [1, 25, 25, 25, 25, 25], }); }); + + test('Kanban shared view operations', async ({ page }) => { + test.slow(); + + await dashboard.viewSidebar.createKanbanView({ + title: 'Film Kanban', + }); + await dashboard.viewSidebar.verifyView({ + title: 'Film Kanban', + index: 1, + }); + + // Share view + await toolbar.fields.toggle({ title: 'Rating' }); + await toolbar.clickShareView(); + const sharedLink = await toolbar.shareView.getShareLink(); + await toolbar.shareView.close(); + + // sign-out + await dashboard.signOut(); + + // Open shared view & verify stack count + await page.goto(sharedLink); + const kanban = dashboard.kanban; + await kanban.verifyStackCount({ count: 6 }); + }); }); From 01df8ec6f79820d8d61e2a71f8f309d7dcb90987 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 18 Jan 2023 00:10:17 +0800 Subject: [PATCH 12/21] feat(nc-gui): pass groupingFieldColumn to share view --- .../components/smartsheet/toolbar/ShareView.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/toolbar/ShareView.vue b/packages/nc-gui/components/smartsheet/toolbar/ShareView.vue index 36805106e5..48e80c1cab 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ShareView.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ShareView.vue @@ -86,10 +86,17 @@ const genShareLink = async () => { if (!view.value?.id) return const response = (await $api.dbViewShare.create(view.value.id)) as SharedView + const meta = isString(response.meta) ? JSON.parse(response.meta) : response.meta shared.value = { ...response, meta } + if (shared.value.type === ViewTypes.KANBAN) { + const { groupingFieldColumn } = useKanbanViewStoreOrThrow() + shared.value.meta = { ...shared.value.meta, groupingFieldColumn: groupingFieldColumn.value } + await updateSharedViewMeta(true) + } + passwordProtected.value = !!shared.value.password && shared.value.password !== '' showShareModel = true @@ -133,7 +140,7 @@ async function saveTheme() { // const saveTransitionDuration = useDebounceFn(updateSharedViewMeta, 1000, { maxWait: 2000 }) -async function updateSharedViewMeta() { +async function updateSharedViewMeta(silentMessage = false) { try { const meta = shared.value.meta && isString(shared.value.meta) ? JSON.parse(shared.value.meta) : shared.value.meta @@ -141,7 +148,7 @@ async function updateSharedViewMeta() { meta, }) - message.success(t('msg.success.updated')) + if (!silentMessage) message.success(t('msg.success.updated')) } catch (e: any) { message.error(await extractSdkResponseErrorMsg(e)) } From b39f16d7606e864f149a45d340eef646a8d322be Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 18 Jan 2023 00:10:45 +0800 Subject: [PATCH 13/21] fix(nc-gui): revise groupingFieldColumn in share view --- packages/nc-gui/composables/useKanbanViewStore.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/composables/useKanbanViewStore.ts b/packages/nc-gui/composables/useKanbanViewStore.ts index dcd4110e6b..3413b4ffe1 100644 --- a/packages/nc-gui/composables/useKanbanViewStore.ts +++ b/packages/nc-gui/composables/useKanbanViewStore.ts @@ -157,9 +157,10 @@ const [useProvideKanbanViewStore, useKanbanViewStore] = useInjectionState( : await $api.dbView.kanbanRead(viewMeta.value.id) // set groupingField - // avoid getting from meta.value.columns - // it would be undefiend as grouping field can be unselected before passing to share view - groupingFieldColumn.value = (await $api.dbTableColumn.get(kanbanMetaData.value.fk_grp_col_id!))! as ColumnType + groupingFieldColumn.value = !isPublic.value + ? (meta.value.columns as ColumnType[]).filter((f) => f.id === kanbanMetaData.value.fk_grp_col_id)[0] || {} + : ((typeof sharedView.value?.meta === 'string' ? JSON.parse(sharedView.value?.meta) : sharedView.value?.meta) + .groupingFieldColumn! as ColumnType) groupingField.value = groupingFieldColumn.value.title! From 0a3effcbcc0fdcc178a85fe17ec3b552d4c03569 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 18 Jan 2023 14:40:01 +0800 Subject: [PATCH 14/21] fix(nocodb): show the field data only for share view --- .../lib/meta/api/publicApis/publicDataExportApis.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts b/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts index 530504c9b7..6141d9ce67 100644 --- a/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts +++ b/packages/nocodb/src/lib/meta/api/publicApis/publicDataExportApis.ts @@ -28,16 +28,26 @@ async function exportExcel(req: Request, res: Response) { } const model = await view.getModelWithInfo(); + await view.getColumns(); const { offset, dbRows, elapsed } = await getDbRows(model, view, req); const fields = req.query.fields as string[]; - const data = XLSX.utils.json_to_sheet(dbRows, { header: fields }); + const data = XLSX.utils.json_to_sheet( + dbRows.map((o: Record) => + Object.fromEntries(fields.map((f) => [f, o[f]])) + ), + { header: fields } + ); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, data, view.title); + const buf = XLSX.write(wb, { type: 'base64', bookType: 'xlsx' }); + res.set({ 'Access-Control-Expose-Headers': 'nc-export-offset', 'nc-export-offset': offset, From 1ca6eacd9ed2fd1a95af7592d8ec782e3f4fc040 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 18 Jan 2023 16:37:20 +0800 Subject: [PATCH 15/21] fix(nc-gui): share view version --- packages/nc-gui/layouts/shared-view.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/layouts/shared-view.vue b/packages/nc-gui/layouts/shared-view.vue index 7452ddf963..080de199db 100644 --- a/packages/nc-gui/layouts/shared-view.vue +++ b/packages/nc-gui/layouts/shared-view.vue @@ -1,7 +1,10 @@