From ae252a4045eabd20c1028857ed48a2c1697030fc Mon Sep 17 00:00:00 2001 From: mertmit Date: Tue, 20 Jun 2023 02:04:41 +0300 Subject: [PATCH] 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,