Browse Source

fix: handle when active_view is null

pull/9091/head
DarkPhoenix2704 4 months ago
parent
commit
505cace237
  1. 17
      packages/nc-gui/components/dashboard/TreeView/TableNode.vue
  2. 1
      packages/nc-gui/composables/useTableNew.ts

17
packages/nc-gui/components/dashboard/TreeView/TableNode.vue

@ -51,8 +51,6 @@ const { loadViews: _loadViews, navigateToView } = useViewsStore()
const { activeView, activeViewTitleOrId, viewsByTable } = storeToRefs(useViewsStore()) const { activeView, activeViewTitleOrId, viewsByTable } = storeToRefs(useViewsStore())
const { isLeftSidebarOpen } = storeToRefs(useSidebarStore()) const { isLeftSidebarOpen } = storeToRefs(useSidebarStore())
const views = computed(() => viewsByTable.value.get(table.value.id!))
const { refreshCommandPalette } = useCommandPalette() const { refreshCommandPalette } = useCommandPalette()
// todo: temp // todo: temp
@ -214,18 +212,21 @@ const deleteTable = () => {
function onDuplicate() { function onDuplicate() {
isOptionsOpen.value = false isOptionsOpen.value = false
const views = viewsByTable.value.get(table.value.id as string)
const defaultView = views?.find((v) => v.is_default) || views?.[0]
const isOpen = ref(true) const isOpen = ref(true)
const { close } = useDialog(resolveComponent('DlgViewCreate'), { const { close } = useDialog(resolveComponent('DlgViewCreate'), {
'modelValue': isOpen, 'modelValue': isOpen,
'title': activeView.value!.title, 'title': defaultView!.title,
'type': activeView.value!.type as ViewTypes, 'type': defaultView!.type as ViewTypes,
'tableId': table.value!.id, 'tableId': table.value!.id,
'selectedViewId': activeView.value!.id, 'selectedViewId': defaultView!.id,
'groupingFieldColumnId': activeView.value!.view!.fk_grp_col_id, 'groupingFieldColumnId': defaultView!.view!.fk_grp_col_id,
'views': views, 'views': views,
'calendarRange': activeView.value!.view!.calendar_range, 'calendarRange': defaultView!.view!.calendar_range,
'coverImageColumnId': activeView.value!.view!.fk_cover_image_col_id, 'coverImageColumnId': defaultView!.view!.fk_cover_image_col_id,
'onUpdate:modelValue': closeDialog, 'onUpdate:modelValue': closeDialog,
'onCreated': async (view: ViewType) => { 'onCreated': async (view: ViewType) => {
closeDialog() closeDialog()

1
packages/nc-gui/composables/useTableNew.ts

@ -266,7 +266,6 @@ export function useTableNew(param: { onTableCreate?: (tableMeta: TableType) => v
table, table,
tables, tables,
base, base,
createTable, createTable,
generateUniqueTitle, generateUniqueTitle,
deleteTable, deleteTable,

Loading…
Cancel
Save