diff --git a/packages/nc-gui/components/dlg/Record/DeleteAll.vue b/packages/nc-gui/components/dlg/Record/DeleteAll.vue new file mode 100644 index 0000000000..459ed7d1fa --- /dev/null +++ b/packages/nc-gui/components/dlg/Record/DeleteAll.vue @@ -0,0 +1,59 @@ + + + + + + {{ 'Delete all records' }} + + + Are you sure you want to delete all {{ rows }} records present in this view? + + + + This action cannot be undone. + + + + + + {{ $t('labels.cancel') }} + + + + + {{ $t('general.delete') }} + + + + + + + diff --git a/packages/nc-gui/components/dlg/ExpandTable.vue b/packages/nc-gui/components/dlg/Record/Upsert.vue similarity index 100% rename from packages/nc-gui/components/dlg/ExpandTable.vue rename to packages/nc-gui/components/dlg/Record/Upsert.vue diff --git a/packages/nc-gui/components/smartsheet/grid/InfiniteTable.vue b/packages/nc-gui/components/smartsheet/grid/InfiniteTable.vue index f400aa8b59..8ee6663508 100644 --- a/packages/nc-gui/components/smartsheet/grid/InfiniteTable.vue +++ b/packages/nc-gui/components/smartsheet/grid/InfiniteTable.vue @@ -41,6 +41,7 @@ const props = defineProps<{ metas?: { metaValue?: TableType; viewMetaValue?: ViewType }, undo?: boolean, ) => Promise + bulkDeleteAll?: () => Promise bulkUpsertRows?: ( insertRows: Row[], updateRows: [], @@ -57,9 +58,12 @@ const props = defineProps<{ selectedRows: Array chunkStates: Array<'loading' | 'loaded' | undefined> isBulkOperationInProgress: boolean + selectedAllRecords?: boolean }>() -const emits = defineEmits(['bulkUpdateDlg']) +const emits = defineEmits(['bulkUpdateDlg', 'update:selectedAllRecords']) + +const vSelectedAllRecords = useVModel(props, 'selectedAllRecords', emits) const { loadData, @@ -75,6 +79,7 @@ const { removeRowIfNew, clearInvalidRows, applySorting, + bulkDeleteAll, } = props // Injections @@ -660,6 +665,29 @@ const onActiveCellChanged = () => { } } +const isDeleteAllModalIsOpen = ref(false) +async function deleteAllRecords() { + isDeleteAllModalIsOpen.value = true + + function closeDlg() { + isOpen.value = false + close(200) + } + + const { close } = useDialog(resolveComponent('DlgRecordDeleteAll'), { + 'modelValue': isDeleteAllModalIsOpen, + 'rows': totalRows.value, + 'onUpdate:modelValue': closeDlg, + 'onDeleteAll': async () => { + await bulkDeleteAll?.() + closeDlg() + vSelectedAllRecords.value = false + }, + }) + + await until(isDeleteAllModalIsOpen).toBe(false) +} + const isOpen = ref(false) async function expandRows({ newRows, @@ -677,7 +705,7 @@ async function expandRows({ continue: false, expand: true, } - const { close } = useDialog(resolveComponent('DlgExpandTable'), { + const { close } = useDialog(resolveComponent('DlgRecordUpsert'), { 'modelValue': isOpen, 'newRows': newRows, 'newColumns': newColumns, @@ -1746,6 +1774,26 @@ watch( immediate: true, }, ) + +const toggleRowSelection = (row: number) => { + if (vSelectedAllRecords.value) return + const data = cachedRows.value.get(row) + + if (!data) return + data.rowMeta.selected = !data.rowMeta?.selected + cachedRows.value.set(row, data) +} + +watch(vSelectedAllRecords, (selectedAll) => { + if (!selectedAll) { + for (const [row, data] of cachedRows.value.entries()) { + if (data.rowMeta?.selected) { + data.rowMeta.selected = false + cachedRows.value.set(row, data) + } + } + } +}) @@ -1778,7 +1826,7 @@ watch( @@ -1825,7 +1873,29 @@ watch( }" data-testid="grid-id-column" > - # + + + # + + + + + + + + + # + @@ -2143,21 +2213,22 @@ watch( {{ row.rowMeta.rowIndex + 1 }} - @@ -2388,31 +2459,45 @@ watch( - - - - {{ $t('title.updateSelectedRows') }} - - + + + + + {{ $t('title.updateSelectedRows') }} + + + + + + {{ $t('activity.deleteSelectedRow') }} + + + + {{ $t('activity.deleteSelectedRow') }} + + + - + - {{ $t('activity.deleteSelectedRow') }} - - - - {{ $t('activity.deleteSelectedRow') }} + {{ $t('activity.deleteAllRecords') }} + - + { @@ -276,6 +278,7 @@ const { router.currentRoute.value.query as Record) const columnsByAlias = computed(() => { @@ -1142,5 +1144,6 @@ export function useInfiniteData(args: { getExpandedRowIndex, loadAggCommentsCount, navigateToSiblingRow, + selectedAllRecords, } } diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json index 10b7623e36..338311b1ec 100644 --- a/packages/nc-gui/lang/en.json +++ b/packages/nc-gui/lang/en.json @@ -1067,6 +1067,7 @@ "viewHide": "View visibility " }, "activity": { + "deleteAllRecords": "Delete all records", "assignView": "Assign view", "webhookDetails": "Webhook Details", "showSaturdaysAndSundays": "Show Saturdays & Sundays", diff --git a/packages/nocodb/src/controllers/bulk-data-alias.controller.ts b/packages/nocodb/src/controllers/bulk-data-alias.controller.ts index 03dcd013de..6e8226db44 100644 --- a/packages/nocodb/src/controllers/bulk-data-alias.controller.ts +++ b/packages/nocodb/src/controllers/bulk-data-alias.controller.ts @@ -112,6 +112,7 @@ export class BulkDataAliasController { baseName: baseName, tableName: tableName, query: req.query, + viewName: req.query.viewId, }); } diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index 0c2b610329..50be22ce42 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -11708,22 +11708,6 @@ } }, "tags": ["DB Table Row"], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object" - }, - "examples": { - "Example 1": { - "value": { - "Title": "foo" - } - } - } - } - } - }, "description": "Bulk Delete all Table Rows if the condition is true", "parameters": [ {