Browse Source

feat(gui-v2): open table tab after table creation

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2716/head
Pranav C 2 years ago
parent
commit
109a7f7026
  1. 15
      packages/nc-gui-v2/components/dlg/TableCreate.vue
  2. 7
      packages/nc-gui-v2/composables/useTableCreate.ts

15
packages/nc-gui-v2/components/dlg/TableCreate.vue

@ -1,6 +1,8 @@
<script setup lang="ts">
import { onMounted } from '@vue/runtime-core'
import useTableCreate from '../../composables/useTableCreate'
import useProject from '~/composables/useProject'
import useTabs from '~/composables/useTabs'
import { validateTableName } from '~/utils/validation'
const { modelValue = false } = defineProps<{ modelValue?: boolean }>()
@ -24,7 +26,18 @@ const dialogShow = computed({
const valid = ref(false)
const isIdToggleAllowed = ref(false)
const isAdvanceOptVisible = ref(false)
const { table, createTable, generateUniqueTitle, tables, project } = useTableCreate()
const { addTab } = useTabs()
const { loadTables } = useProject()
const { table, createTable, generateUniqueTitle, tables, project } = useTableCreate(async (table) => {
await loadTables()
addTab({
id: table.id as string,
title: table.title,
type: 'table',
})
dialogShow.value = false
})
const prefix = computed(() => project?.value?.prefix || '')

7
packages/nc-gui-v2/composables/useTableCreate.ts

@ -1,7 +1,8 @@
import type { TableType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk'
import { useNuxtApp } from '#app'
export default (onTableCreate?: (tableMeta: any) => void) => {
export default (onTableCreate?: (tableMeta: TableType) => void) => {
const table = reactive<{ title: string; table_name: string; columns: string[] }>({
title: '',
table_name: '',
@ -23,12 +24,12 @@ export default (onTableCreate?: (tableMeta: any) => void) => {
return table.columns.includes(col.column_name)
})
await $api.dbTable.create(project?.value?.id as string, {
const tableMeta = await $api.dbTable.create(project?.value?.id as string, {
...table,
columns,
})
onTableCreate?.({})
onTableCreate?.(tableMeta)
}
watch(

Loading…
Cancel
Save