|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
<script lang="ts" setup> |
|
|
|
|
import type { BaseType, TableType } from 'nocodb-sdk' |
|
|
|
|
import { type BaseType, type TableType, type ViewType, ViewTypes } from 'nocodb-sdk' |
|
|
|
|
import { toRef } from '@vue/reactivity' |
|
|
|
|
import { message } from 'ant-design-vue' |
|
|
|
|
import { storeToRefs } from 'pinia' |
|
|
|
@ -47,10 +47,14 @@ provide(SidebarTableInj, table)
|
|
|
|
|
|
|
|
|
|
const { setMenuContext, openRenameTableDialog: _openRenameTableDialog, duplicateTable: _duplicateTable } = inject(TreeViewInj)! |
|
|
|
|
|
|
|
|
|
const { loadViews: _loadViews } = useViewsStore() |
|
|
|
|
const { loadViews: _loadViews, navigateToView } = useViewsStore() |
|
|
|
|
const { activeView, activeViewTitleOrId, viewsByTable } = storeToRefs(useViewsStore()) |
|
|
|
|
const { isLeftSidebarOpen } = storeToRefs(useSidebarStore()) |
|
|
|
|
|
|
|
|
|
const views = computed(() => viewsByTable.value.get(table.value.id!)) |
|
|
|
|
|
|
|
|
|
const { refreshCommandPalette } = useCommandPalette() |
|
|
|
|
|
|
|
|
|
// todo: temp |
|
|
|
|
const { baseTables } = storeToRefs(useTablesStore()) |
|
|
|
|
const tables = computed(() => baseTables.value.get(base.value.id!) ?? []) |
|
|
|
@ -207,6 +211,50 @@ const deleteTable = () => {
|
|
|
|
|
isTableDeleteDialogVisible.value = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onDuplicate() { |
|
|
|
|
isOptionsOpen.value = false |
|
|
|
|
|
|
|
|
|
const isOpen = ref(true) |
|
|
|
|
|
|
|
|
|
const { close } = useDialog(resolveComponent('DlgViewCreate'), { |
|
|
|
|
'modelValue': isOpen, |
|
|
|
|
'title': activeView.value!.title, |
|
|
|
|
'type': activeView.value!.type as ViewTypes, |
|
|
|
|
'tableId': table.value!.id, |
|
|
|
|
'selectedViewId': activeView.value!.id, |
|
|
|
|
'groupingFieldColumnId': activeView.value!.view!.fk_grp_col_id, |
|
|
|
|
'views': views, |
|
|
|
|
'calendarRange': activeView.value!.view!.calendar_range, |
|
|
|
|
'coverImageColumnId': activeView.value!.view!.fk_cover_image_col_id, |
|
|
|
|
'onUpdate:modelValue': closeDialog, |
|
|
|
|
'onCreated': async (view: ViewType) => { |
|
|
|
|
closeDialog() |
|
|
|
|
|
|
|
|
|
refreshCommandPalette() |
|
|
|
|
|
|
|
|
|
await _loadViews({ |
|
|
|
|
force: true, |
|
|
|
|
tableId: table.value!.id!, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
navigateToView({ |
|
|
|
|
view, |
|
|
|
|
tableId: table.value!.id!, |
|
|
|
|
baseId: base.value.id!, |
|
|
|
|
hardReload: view.type === ViewTypes.FORM, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
$e('a:view:create', { view: view.type, sidebar: true }) |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
function closeDialog() { |
|
|
|
|
isOpen.value = false |
|
|
|
|
|
|
|
|
|
close(1000) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: Should find a way to render the components without using the `nextTick` function |
|
|
|
|
const refreshViews = async () => { |
|
|
|
|
isExpanded.value = false |
|
|
|
@ -368,6 +416,16 @@ const source = computed(() => {
|
|
|
|
|
{{ $t('general.duplicate') }} {{ $t('objects.table').toLowerCase() }} |
|
|
|
|
</div> |
|
|
|
|
</NcMenuItem> |
|
|
|
|
<NcDivider /> |
|
|
|
|
|
|
|
|
|
<NcMenuItem @click="onDuplicate"> |
|
|
|
|
<GeneralIcon class="nc-view-copy-icon" icon="duplicate" /> |
|
|
|
|
{{ |
|
|
|
|
$t('general.duplicateEntity', { |
|
|
|
|
entity: $t('title.defaultView').toLowerCase(), |
|
|
|
|
}) |
|
|
|
|
}} |
|
|
|
|
</NcMenuItem> |
|
|
|
|
|
|
|
|
|
<NcDivider /> |
|
|
|
|
<NcMenuItem |
|
|
|
|