Browse Source

feat: suffix base alias for duplicate tabs

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3573/head
mertmit 2 years ago
parent
commit
ddd17e9229
  1. 15
      packages/nc-gui/composables/useTabs.ts

15
packages/nc-gui/composables/useTabs.ts

@ -17,7 +17,7 @@ const [setup, use] = useInjectionState(() => {
const router = useRouter()
const { tables } = useProject()
const { bases, tables } = useProject()
const projectType = $computed(() => route.params.projectType as string)
@ -33,12 +33,18 @@ const [setup, use] = useInjectionState(() => {
if (!currentTable) return -1
const currentBase = bases.value.find((b) => b.id === currentTable.base_id)
tab.id = currentTable.id
let index = tabs.value.findIndex((t) => t.id === tab.id)
tab.title = currentTable.title
// append base alias to tab title if duplicate titles exist on other bases
if (tables.value.find((t) => t.title === currentTable?.title && t.base_id !== currentTable?.base_id))
tab.title = `${tab.title}${currentBase?.alias ? ` (${currentBase.alias})` : ``}`
if (index === -1) {
tab.sortsState = tab.sortsState || new Map()
tab.filterState = tab.filterState || new Map()
@ -83,6 +89,13 @@ const [setup, use] = useInjectionState(() => {
}
// if tab not found add it
else {
const currentTable = tables.value.find((t) => t.id === tabMeta.id || t.title === tabMeta.id)
const currentBase = bases.value.find((b) => b.id === currentTable?.base_id)
// append base alias to tab title if duplicate titles exist on other bases
if (tables.value.find((t) => t.title === currentTable?.title && t.base_id !== currentTable?.base_id))
tabMeta.title = `${tabMeta.title}${currentBase?.alias ? ` (${currentBase.alias})` : ``}`
tabs.value = [...(tabs.value || []), tabMeta]
activeTabIndex.value = tabs.value.length - 1
}

Loading…
Cancel
Save