Column
@@ -473,7 +476,10 @@ defineExpose({
@apply bg-white;
}
:deep(.template-form-row) > td {
- @apply !pb-0;
+ @apply pa-0 mb-0;
+ .ant-form-item {
+ @apply mb-0;
+ }
}
}
diff --git a/packages/nc-gui-v2/composables/useTableCreate.ts b/packages/nc-gui-v2/composables/useTableCreate.ts
new file mode 100644
index 0000000000..24c7b46943
--- /dev/null
+++ b/packages/nc-gui-v2/composables/useTableCreate.ts
@@ -0,0 +1,66 @@
+import type { TableType } from 'nocodb-sdk'
+import { UITypes } from 'nocodb-sdk'
+import { useProject } from './useProject'
+import { useNuxtApp } from '#app'
+import { useToast } from 'vue-toastification'
+import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
+
+export function useTableCreate(onTableCreate?: (tableMeta: TableType) => void) {
+ const table = reactive<{ title: string; table_name: string; columns: string[] }>({
+ title: '',
+ table_name: '',
+ columns: {
+ id: true,
+ title: true,
+ created_at: true,
+ updated_at: true,
+ },
+ })
+
+ const { sqlUi, project, tables } = useProject()
+
+ const toast = useToast()
+
+ const { $api } = useNuxtApp()
+
+ const createTable = async () => {
+ try {
+ if (!sqlUi?.value) return
+ const columns = sqlUi?.value?.getNewTableColumns().filter((col) => {
+ if (col.column_name === 'id' && table.columns.id_ag) {
+ Object.assign(col, sqlUi?.value?.getDataTypeForUiType({ uidt: UITypes.ID }, 'AG'))
+ col.dtxp = sqlUi?.value?.getDefaultLengthForDatatype(col.dt)
+ col.dtxs = sqlUi?.value?.getDefaultScaleForDatatype(col.dt)
+ return true
+ }
+ return !!table.columns[col.column_name]
+ })
+
+ const tableMeta = await $api.dbTable.create(project?.value?.id as string, {
+ ...table,
+ columns,
+ })
+
+ onTableCreate?.(tableMeta)
+ } catch (e: any) {
+ toast.error(await extractSdkResponseErrorMsg(e))
+ }
+ }
+
+ watch(
+ () => table.title,
+ (title) => {
+ table.table_name = `${project?.value?.prefix || ''}${title}`
+ },
+ )
+
+ const generateUniqueTitle = () => {
+ let c = 1
+ while (tables?.value?.some((t) => t.title === `Sheet${c}`)) {
+ c++
+ }
+ table.title = `Sheet${c}`
+ }
+
+ return { table, createTable, generateUniqueTitle, tables, project }
+}
diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue
index 023742631a..6ff2fa5455 100644
--- a/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue
+++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue
@@ -152,4 +152,14 @@ function openQuickImportDialog(type: string) {
:deep(.ant-tabs-nav) {
@apply !mb-0;
}
+
+:deep(.ant-menu-item-selected) {
+ @apply text-inherit !bg-inherit;
+}
+
+:deep(.ant-menu-horizontal),
+:deep(.ant-menu-item::after),
+:deep(.ant-menu-submenu::after) {
+ @apply !border-none;
+}