|
|
@ -1,5 +1,5 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import { type BaseType, type TableType, type ViewType, ViewTypes } from 'nocodb-sdk' |
|
|
|
import { type BaseType, type TableType, ViewTypes } from 'nocodb-sdk' |
|
|
|
import { toRef } from '@vue/reactivity' |
|
|
|
import { toRef } from '@vue/reactivity' |
|
|
|
import { message } from 'ant-design-vue' |
|
|
|
import { message } from 'ant-design-vue' |
|
|
|
import { storeToRefs } from 'pinia' |
|
|
|
import { storeToRefs } from 'pinia' |
|
|
@ -52,7 +52,7 @@ const { |
|
|
|
duplicateTable: _duplicateTable, |
|
|
|
duplicateTable: _duplicateTable, |
|
|
|
} = inject(TreeViewInj)! |
|
|
|
} = inject(TreeViewInj)! |
|
|
|
|
|
|
|
|
|
|
|
const { loadViews: _loadViews, navigateToView } = useViewsStore() |
|
|
|
const { loadViews: _loadViews, navigateToView, duplicateView } = useViewsStore() |
|
|
|
const { activeView, activeViewTitleOrId, viewsByTable } = storeToRefs(useViewsStore()) |
|
|
|
const { activeView, activeViewTitleOrId, viewsByTable } = storeToRefs(useViewsStore()) |
|
|
|
const { isLeftSidebarOpen } = storeToRefs(useSidebarStore()) |
|
|
|
const { isLeftSidebarOpen } = storeToRefs(useSidebarStore()) |
|
|
|
|
|
|
|
|
|
|
@ -221,35 +221,18 @@ const deleteTable = () => { |
|
|
|
const isOnDuplicateLoading = ref<boolean>(false) |
|
|
|
const isOnDuplicateLoading = ref<boolean>(false) |
|
|
|
|
|
|
|
|
|
|
|
async function onDuplicate() { |
|
|
|
async function onDuplicate() { |
|
|
|
// Load views if not loaded |
|
|
|
|
|
|
|
if (!viewsByTable.value.get(table.value.id as string)) { |
|
|
|
|
|
|
|
isOnDuplicateLoading.value = true |
|
|
|
isOnDuplicateLoading.value = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load views if not loaded |
|
|
|
|
|
|
|
if (!viewsByTable.value.get(table.value.id as string)) { |
|
|
|
await _openTable(table.value, undefined, false) |
|
|
|
await _openTable(table.value, undefined, false) |
|
|
|
|
|
|
|
|
|
|
|
isOnDuplicateLoading.value = false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
isOptionsOpen.value = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const views = viewsByTable.value.get(table.value.id as string) |
|
|
|
const views = viewsByTable.value.get(table.value.id as string) |
|
|
|
const defaultView = views?.find((v) => v.is_default) || views?.[0] |
|
|
|
const defaultView = views?.find((v) => v.is_default) || views?.[0] |
|
|
|
|
|
|
|
|
|
|
|
const isOpen = ref(true) |
|
|
|
if (defaultView) { |
|
|
|
|
|
|
|
const view = await duplicateView(defaultView) |
|
|
|
const { close } = useDialog(resolveComponent('DlgViewCreate'), { |
|
|
|
|
|
|
|
'modelValue': isOpen, |
|
|
|
|
|
|
|
'title': defaultView!.title, |
|
|
|
|
|
|
|
'type': defaultView!.type as ViewTypes, |
|
|
|
|
|
|
|
'tableId': table.value!.id, |
|
|
|
|
|
|
|
'selectedViewId': defaultView!.id, |
|
|
|
|
|
|
|
'groupingFieldColumnId': defaultView!.view!.fk_grp_col_id, |
|
|
|
|
|
|
|
'views': views, |
|
|
|
|
|
|
|
'calendarRange': defaultView!.view!.calendar_range, |
|
|
|
|
|
|
|
'coverImageColumnId': defaultView!.view!.fk_cover_image_col_id, |
|
|
|
|
|
|
|
'onUpdate:modelValue': closeDialog, |
|
|
|
|
|
|
|
'onCreated': async (view: ViewType) => { |
|
|
|
|
|
|
|
closeDialog() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refreshCommandPalette() |
|
|
|
refreshCommandPalette() |
|
|
|
|
|
|
|
|
|
|
@ -258,6 +241,7 @@ async function onDuplicate() { |
|
|
|
tableId: table.value!.id!, |
|
|
|
tableId: table.value!.id!, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (view) { |
|
|
|
navigateToView({ |
|
|
|
navigateToView({ |
|
|
|
view, |
|
|
|
view, |
|
|
|
tableId: table.value!.id!, |
|
|
|
tableId: table.value!.id!, |
|
|
@ -266,14 +250,11 @@ async function onDuplicate() { |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
$e('a:view:create', { view: view.type, sidebar: true }) |
|
|
|
$e('a:view:create', { view: view.type, sidebar: true }) |
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function closeDialog() { |
|
|
|
|
|
|
|
isOpen.value = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
close(1000) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isOnDuplicateLoading.value = false |
|
|
|
|
|
|
|
isOptionsOpen.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Should find a way to render the components without using the `nextTick` function |
|
|
|
// TODO: Should find a way to render the components without using the `nextTick` function |
|
|
|