From b0480494ffbf0fb6c0535e00df8ac3a04e50f575 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Mon, 11 May 2026 01:38:24 +0800 Subject: [PATCH] feat: add MongoDB table view with inline editing support - Add document/table view toggle to MongoDocBrowser - Convert MongoDB documents to DataGrid format (union of all top-level keys) - Add customSave prop to DataGrid for pluggable save backends - MongoDB grid save converts dirty rows to mongoUpdateDocument calls - Enable transaction-mode toolbar (commit/rollback) for customSave --- src/components/grid/DataGrid.vue | 14 +- src/components/mongo/MongoDocBrowser.vue | 345 +++++++++++++++-------- src/composables/useDataGridEditor.ts | 54 +++- src/i18n/locales/en.ts | 2 + src/i18n/locales/zh-CN.ts | 2 + 5 files changed, 299 insertions(+), 118 deletions(-) diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue index 715226f32d..258594071b 100644 --- a/src/components/grid/DataGrid.vue +++ b/src/components/grid/DataGrid.vue @@ -88,6 +88,13 @@ const props = defineProps<{ }; loading?: boolean; onExecuteSql?: (sql: string) => Promise; + customSave?: (changes: { + dirtyRows: Map>; + newRows: (string | number | boolean | null)[][]; + deletedRows: Set; + columns: string[]; + rows: (string | number | boolean | null)[][]; + }) => Promise; }>(); const emit = defineEmits<{ @@ -804,6 +811,7 @@ const editor = useDataGridEditor({ database: computed(() => props.database), tableMeta: computed(() => props.tableMeta), onExecuteSql: computed(() => props.onExecuteSql), + customSave: computed(() => props.customSave), sql: computed(() => props.sql), searchText, whereFilterInput, @@ -1747,7 +1755,7 @@ defineExpose({ {{ t("grid.refresh") }}