Browse Source

fix: refresh meta for related tables on duplicate table

pull/7727/head
mertmit 6 months ago
parent
commit
dd3ea502d8
  1. 18
      packages/nc-gui/components/dlg/TableDuplicate.vue

18
packages/nc-gui/components/dlg/TableDuplicate.vue

@ -1,5 +1,5 @@
<script setup lang="ts">
import type { TableType } from 'nocodb-sdk'
import { type LinkToAnotherRecordType, type TableType, UITypes } from 'nocodb-sdk'
import { message } from 'ant-design-vue'
import { useVModel } from '#imports'
import type { TabType } from '#imports'
@ -31,6 +31,8 @@ const { loadTables } = baseStore
const { tables } = storeToRefs(baseStore)
const { getMeta } = useMetas()
const { t } = useI18n()
const { activeTable: _activeTable } = storeToRefs(useTablesStore())
@ -74,6 +76,20 @@ const _duplicate = async () => {
}) => {
if (data.status !== 'close') {
if (data.status === JobStatus.COMPLETED) {
const sourceTable = await getMeta(props.table.id!)
if (sourceTable) {
for (const col of sourceTable.columns || []) {
if ([UITypes.Links, UITypes.LinkToAnotherRecord].includes(col.uidt as UITypes)) {
if (col && col.colOptions) {
const relatedTableId = (col.colOptions as LinkToAnotherRecordType)?.fk_related_model_id
if (relatedTableId) {
await getMeta(relatedTableId, true)
}
}
}
}
}
await loadTables()
refreshCommandPalette()
const newTable = tables.value.find((el) => el.id === data?.data?.result?.id)

Loading…
Cancel
Save