Browse Source

fix(nc-gui): reorder table views nocodb/nocodb#7395

pull/7528/head
Ramesh Mane 9 months ago
parent
commit
91aef7a498
  1. 4
      packages/nc-gui/components/dashboard/TreeView/TableList.vue
  2. 28
      packages/nc-gui/components/dashboard/TreeView/ViewsList.vue

4
packages/nc-gui/components/dashboard/TreeView/TableList.vue

@ -22,6 +22,8 @@ const source = computed(() => base.value?.sources?.[sourceIndex.value])
const { isMobileMode } = useGlobal() const { isMobileMode } = useGlobal()
const { isUIAllowed } = useRoles()
const { baseTables } = storeToRefs(useTablesStore()) const { baseTables } = storeToRefs(useTablesStore())
const tables = computed(() => baseTables.value.get(base.value.id!) ?? []) const tables = computed(() => baseTables.value.get(base.value.id!) ?? [])
@ -114,7 +116,7 @@ const initSortable = (el: Element) => {
} }
watchEffect(() => { watchEffect(() => {
if (menuRefs.value) { if (menuRefs.value && isUIAllowed('viewCreateOrEdit')) {
if (menuRefs.value instanceof HTMLElement) { if (menuRefs.value instanceof HTMLElement) {
initSortable(menuRefs.value) initSortable(menuRefs.value)
} else { } else {

28
packages/nc-gui/components/dashboard/TreeView/ViewsList.vue

@ -22,7 +22,15 @@ import {
} from '#imports' } from '#imports'
interface Emits { interface Emits {
(event: 'openModal', data: { type: ViewTypes; title?: string; copyViewId?: string; groupingFieldColumnId?: string }): void (
event: 'openModal',
data: {
type: ViewTypes
title?: string
copyViewId?: string
groupingFieldColumnId?: string
},
): void
(event: 'deleted'): void (event: 'deleted'): void
} }
@ -119,7 +127,10 @@ async function onSortEnd(evt: SortableEvent, undo = false) {
if (views.value.length < 2) return if (views.value.length < 2) return
const { newIndex = 0, oldIndex = 0 } = evt let { newIndex = 0, oldIndex = 0 } = evt
newIndex = newIndex - 1
oldIndex = oldIndex - 1
if (newIndex === oldIndex) return if (newIndex === oldIndex) return
@ -149,7 +160,10 @@ async function onSortEnd(evt: SortableEvent, undo = false) {
}) })
} }
const children = evt.to.children as unknown as HTMLLIElement[] const children = Array.from(evt.to.children as unknown as HTMLLIElement[])
// remove `Create View` children from list
children.shift()
const previousEl = children[newIndex - 1] const previousEl = children[newIndex - 1]
const nextEl = children[newIndex + 1] const nextEl = children[newIndex + 1]
@ -196,7 +210,7 @@ const initSortable = (el: HTMLElement) => {
}) })
} }
onMounted(() => menuRef.value && initSortable(menuRef.value.$el)) onMounted(() => menuRef.value && isUIAllowed('viewCreateOrEdit') && initSortable(menuRef.value.$el))
/** Navigate to view by changing url param */ /** Navigate to view by changing url param */
async function changeView(view: ViewType) { async function changeView(view: ViewType) {
@ -279,7 +293,11 @@ function openDeleteDialog(view: ViewType) {
emits('deleted') emits('deleted')
removeFromRecentViews({ viewId: view.id, tableId: view.fk_model_id, baseId: base.value.id }) removeFromRecentViews({
viewId: view.id,
tableId: view.fk_model_id,
baseId: base.value.id,
})
refreshCommandPalette() refreshCommandPalette()
if (activeView.value?.id === view.id) { if (activeView.value?.id === view.id) {
navigateToTable({ navigateToTable({

Loading…
Cancel
Save