From b4d06d3a94ec212a2557f7adff3195a384412820 Mon Sep 17 00:00:00 2001 From: mertmit Date: Mon, 19 Jun 2023 21:54:58 +0300 Subject: [PATCH 01/58] fix: add undo after api call Signed-off-by: mertmit --- packages/nc-gui/composables/useViewData.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/composables/useViewData.ts b/packages/nc-gui/composables/useViewData.ts index 34bb78db9b..6f3540774a 100644 --- a/packages/nc-gui/composables/useViewData.ts +++ b/packages/nc-gui/composables/useViewData.ts @@ -481,6 +481,8 @@ export function useViewData( updateArray.push({ ...updateData, ...pk }) } + await $api.dbTableRow.bulkUpdate(NOCO, metaValue?.project_id as string, metaValue?.id as string, updateArray) + if (!undo) { addUndo({ redo: { @@ -537,8 +539,6 @@ export function useViewData( }) } - await $api.dbTableRow.bulkUpdate(NOCO, metaValue?.project_id as string, metaValue?.id as string, updateArray) - for (const row of rows) { if (!undo) { /** update row data(to sync formula and other related columns) From 1b21cad9b51db04277baae77ecac7ebcb308e593 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 20 Jun 2023 02:03:40 +0300 Subject: [PATCH 02/58] feat: bulkUpdateAll using viewId Signed-off-by: mertmit --- packages/nocodb-sdk/src/lib/Api.ts | 2 ++ packages/nocodb/src/db/BaseModelSqlv2.ts | 36 +++++++++++++++--------- packages/nocodb/src/schema/swagger.json | 7 +++++ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index 122abbfcf9..b35b8e5267 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -7249,6 +7249,7 @@ export class Api< data: object, query?: { where?: string; + viewId?: string; }, params: RequestParams = {} ) => @@ -7289,6 +7290,7 @@ export class Api< data: object, query?: { where?: string; + viewId?: string; }, params: RequestParams = {} ) => diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index b15aa4b355..8226e529d5 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -2378,7 +2378,7 @@ class BaseModelSqlv2 { } async bulkUpdateAll( - args: { where?: string; filterArr?: Filter[] } = {}, + args: { where?: string; filterArr?: Filter[]; viewId?: string } = {}, data, { cookie }: { cookie?: any } = {}, ) { @@ -2400,22 +2400,30 @@ class BaseModelSqlv2 { const aliasColObjMap = await this.model.getAliasColObjMap(); const filterObj = extractFilterFromXwhere(where, aliasColObjMap); - await conditionV2( - [ - new Filter({ - children: args.filterArr || [], - is_group: true, - logical_op: 'and', - }), + const conditionObj = [ + new Filter({ + children: args.filterArr || [], + is_group: true, + logical_op: 'and', + }), + new Filter({ + children: filterObj, + is_group: true, + logical_op: 'and', + }), + ]; + + if (args.viewId) { + conditionObj.push( new Filter({ - children: filterObj, + children: + (await Filter.rootFilterList({ viewId: args.viewId })) || [], is_group: true, - logical_op: 'and', }), - ], - qb, - this.dbDriver, - ); + ); + } + + await conditionV2(conditionObj, qb, this.dbDriver); qb.update(updateData); diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index 84d509f0ef..5be2b7ddb3 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -10059,6 +10059,13 @@ }, "in": "query", "name": "where" + }, + { + "schema": { + "type": "string" + }, + "in": "query", + "name": "viewId" } ], "patch": { From ae252a4045eabd20c1028857ed48a2c1697030fc Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 20 Jun 2023 02:04:41 +0300 Subject: [PATCH 03/58] feat(nc-gui): bulk update records Signed-off-by: mertmit --- packages/nc-gui/components/dlg/BulkUpdate.vue | 444 ++++++++++++++++++ .../nc-gui/components/smartsheet/Grid.vue | 38 +- packages/nc-gui/composables/useViewData.ts | 14 + 3 files changed, 494 insertions(+), 2 deletions(-) create mode 100644 packages/nc-gui/components/dlg/BulkUpdate.vue diff --git a/packages/nc-gui/components/dlg/BulkUpdate.vue b/packages/nc-gui/components/dlg/BulkUpdate.vue new file mode 100644 index 0000000000..ac12b9ea65 --- /dev/null +++ b/packages/nc-gui/components/dlg/BulkUpdate.vue @@ -0,0 +1,444 @@ + + + + + diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index 5a4595e7bb..25bccad050 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -99,6 +99,8 @@ const contextMenu = computed({ }) const contextMenuClosing = ref(false) +const bulkUpdateDlg = ref(false) + const routeQuery = $computed(() => route.query as Record) const contextMenuTarget = ref<{ row: number; col: number } | null>(null) const expandedFormDlg = ref(false) @@ -128,6 +130,7 @@ const { getExpandedRowIndex, deleteRangeOfRows, bulkUpdateRows, + bulkUpdateView, } = useViewData(meta, view, xWhere) const { getMeta } = useMetas() @@ -977,7 +980,12 @@ function addEmptyRow(row?: number) { :style="{ height: rowHeight ? `${rowHeight * 1.8}rem` : `1.8rem` }" :data-testid="`grid-row-${rowIndex}`" > - +
- +
{{ $t('activity.deleteSelectedRow') }} @@ -1158,6 +1169,16 @@ function addEmptyRow(row?: number) { {{ $t('general.copy') }}
+ + +
+ + Bulk Update +
+
@@ -1208,6 +1229,19 @@ function addEmptyRow(row?: number) { @prev="navigateToSiblingRow(NavigateDir.PREV)" /> + + + +
diff --git a/packages/nc-gui/composables/useViewData.ts b/packages/nc-gui/composables/useViewData.ts index 6f3540774a..c55c7e39fb 100644 --- a/packages/nc-gui/composables/useViewData.ts +++ b/packages/nc-gui/composables/useViewData.ts @@ -566,6 +566,19 @@ export function useViewData( } } + async function bulkUpdateView( + data: Record[], + { metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, + ) { + if (!viewMetaValue) return + + await $api.dbTableRow.bulkUpdateAll(NOCO, metaValue?.project_id as string, metaValue?.id as string, data, { + viewId: viewMetaValue.id, + }) + + await loadData() + } + async function changePage(page: number) { paginationData.value.page = page await loadData({ @@ -926,6 +939,7 @@ export function useViewData( deleteRangeOfRows, updateOrSaveRow, bulkUpdateRows, + bulkUpdateView, selectedAllRecords, syncCount, syncPagination, From 5f14e11db06a4bde3e978fb656731b8ccd2aa3b8 Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 20 Jun 2023 12:23:34 +0300 Subject: [PATCH 04/58] fix: PR requested changes Signed-off-by: mertmit --- packages/nc-gui/components/dlg/BulkUpdate.vue | 48 +++++-------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/packages/nc-gui/components/dlg/BulkUpdate.vue b/packages/nc-gui/components/dlg/BulkUpdate.vue index ac12b9ea65..a0d81a9bab 100644 --- a/packages/nc-gui/components/dlg/BulkUpdate.vue +++ b/packages/nc-gui/components/dlg/BulkUpdate.vue @@ -59,8 +59,8 @@ const fields = computed(() => { const paginatedData = inject(PaginationDataInj)! const editCount = computed(() => { - if (updateMode.value === BulkUpdateMode.SELECTED && props.rows) { - return props.rows.length + if (updateMode.value === BulkUpdateMode.SELECTED) { + return props.rows!.length } else { return paginatedData.value?.totalRows ?? Infinity } @@ -182,50 +182,22 @@ onMounted(() => { - +
: Bulk Update ({{ editCount }} records)
- - +
+ Bulk Update All
- +
+ Bulk Update Selected
@@ -333,13 +305,17 @@ onMounted(() => {
-
Editable Columns
+
+ + Editable Columns +
Date: Tue, 20 Jun 2023 12:33:58 +0300 Subject: [PATCH 05/58] fix: bulk modal overflowing columns Signed-off-by: mertmit --- packages/nc-gui/components/dlg/BulkUpdate.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/components/dlg/BulkUpdate.vue b/packages/nc-gui/components/dlg/BulkUpdate.vue index a0d81a9bab..999430fafe 100644 --- a/packages/nc-gui/components/dlg/BulkUpdate.vue +++ b/packages/nc-gui/components/dlg/BulkUpdate.vue @@ -203,7 +203,7 @@ onMounted(() => {
-
+
Date: Wed, 21 Jun 2023 12:18:07 +0530 Subject: [PATCH 06/58] test: pg-meta-db for pw Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .github/workflows/playwright-test-workflow.yml | 7 +++++++ packages/nocodb/package.json | 1 + 2 files changed, 8 insertions(+) diff --git a/.github/workflows/playwright-test-workflow.yml b/.github/workflows/playwright-test-workflow.yml index c9e8244c8f..fef81cebcf 100644 --- a/.github/workflows/playwright-test-workflow.yml +++ b/.github/workflows/playwright-test-workflow.yml @@ -69,10 +69,17 @@ jobs: working-directory: ./packages/nc-gui run: npm run ci:run - name: Run backend + if: ${{ inputs.db != 'pg' }} working-directory: ./packages/nocodb run: | npm install npm run watch:run:playwright > ${{ inputs.db }}_${{ inputs.shard }}_test_backend.log & + - name: Run backend:pg + if: ${{ inputs.db == 'pg' }} + working-directory: ./packages/nocodb + run: | + npm install + npm run watch:run:playwright:pg > ${{ inputs.db }}_${{ inputs.shard }}_test_backend.log & - name: Cache playwright npm modules uses: actions/cache@v3 id: playwright-cache diff --git a/packages/nocodb/package.json b/packages/nocodb/package.json index cad93f1793..f431bd9ac9 100644 --- a/packages/nocodb/package.json +++ b/packages/nocodb/package.json @@ -34,6 +34,7 @@ "watch:run": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"", "watch:run:mysql": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunMysql --log-error --project tsconfig.json\"", "watch:run:pg": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG --log-error --project tsconfig.json\"", + "watch:run:playwright:pg": "rm -f ./test_noco.db; cross-env NC_DB=pg://localhost:5432?u=postgres&p=password&d=pw_ncdb PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"", "watch:run:playwright": "rm -f ./test_noco.db; cross-env DATABASE_URL=sqlite:./test_noco.db PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"", "watch:run:playwright:quick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env DATABASE_URL=sqlite:./test_noco.db NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"", "watch:run:playwright:pg:cyquick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG_CyQuick.ts --log-error --project tsconfig.json\"", From 2d70128d6ba6ea2302fd861c5aadd19df6229c08 Mon Sep 17 00:00:00 2001 From: mertmit Date: Wed, 21 Jun 2023 11:56:06 +0300 Subject: [PATCH 07/58] fix: editable columns css Signed-off-by: mertmit --- packages/nc-gui/components/dlg/BulkUpdate.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/dlg/BulkUpdate.vue b/packages/nc-gui/components/dlg/BulkUpdate.vue index 999430fafe..174aa393ce 100644 --- a/packages/nc-gui/components/dlg/BulkUpdate.vue +++ b/packages/nc-gui/components/dlg/BulkUpdate.vue @@ -311,8 +311,8 @@ onMounted(() => {
-
-
+
+
Editable Columns
@@ -322,7 +322,7 @@ onMounted(() => { item-key="id" draggable=".item" group="form-inputs" - class="flex flex-col gap-2" + class="flex flex-col gap-2 flex-1" @start="drag = true" @end="drag = false" > From 5596870f304bc9500e5a3549e81ead4cbbd7680e Mon Sep 17 00:00:00 2001 From: mertmit Date: Wed, 21 Jun 2023 12:22:04 +0300 Subject: [PATCH 08/58] fix: bulk update after enabling filter Signed-off-by: mertmit --- packages/nc-gui/components/dlg/BulkUpdate.vue | 9 ++++++++- packages/nc-gui/components/smartsheet/Grid.vue | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/dlg/BulkUpdate.vue b/packages/nc-gui/components/dlg/BulkUpdate.vue index 174aa393ce..8ac50ef414 100644 --- a/packages/nc-gui/components/dlg/BulkUpdate.vue +++ b/packages/nc-gui/components/dlg/BulkUpdate.vue @@ -45,6 +45,14 @@ const drag = ref(false) const editColumns = ref[]>([]) +const tempRow = ref({ + row: {}, + oldRow: {}, + rowMeta: {}, +}) + +useProvideSmartsheetRowStore(meta, tempRow) + const fields = computed(() => { return (meta.value.columns ?? []).filter( (col) => @@ -262,7 +270,6 @@ onMounted(() => { >