Browse Source

fix(gui-v2): mark default view as active initially

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3292/head
mertmit 2 years ago
parent
commit
05d83df42e
  1. 16
      packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue

16
packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue

@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ViewType, ViewTypes } from 'nocodb-sdk' import type { ViewType } from 'nocodb-sdk'
import { ViewTypes } from 'nocodb-sdk'
import type { SortableEvent } from 'sortablejs' import type { SortableEvent } from 'sortablejs'
import type { Menu as AntMenu } from 'ant-design-vue' import type { Menu as AntMenu } from 'ant-design-vue'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
@ -18,6 +19,12 @@ interface Emits {
const emits = defineEmits<Emits>() const emits = defineEmits<Emits>()
const viewTypeAlias = {
[ViewTypes.GRID as any]: 'grid',
[ViewTypes.FORM as any]: 'form',
[ViewTypes.GALLERY as any]: 'gallery',
}
const activeView = inject(ActiveViewInj, ref()) const activeView = inject(ActiveViewInj, ref())
const views = inject<Ref<any[]>>(ViewListInj, ref([])) const views = inject<Ref<any[]>>(ViewListInj, ref([]))
@ -176,7 +183,7 @@ function onDeleted() {
<template> <template>
<a-menu ref="menuRef" :class="{ dragging }" class="nc-views-menu flex-1" :selected-keys="selected"> <a-menu ref="menuRef" :class="{ dragging }" class="nc-views-menu flex-1" :selected-keys="selected">
<RenameableMenuItem <RenameableMenuItem
v-for="view of views" v-for="(view, index) of views"
:id="view.id" :id="view.id"
:key="view.id" :key="view.id"
:view="view" :view="view"
@ -184,8 +191,9 @@ function onDeleted() {
class="transition-all ease-in duration-300" class="transition-all ease-in duration-300"
:class="{ :class="{
'bg-gray-100': isMarked === view.id, 'bg-gray-100': isMarked === view.id,
'active': route.params.viewTitle && route.params.viewTitle === view.title, 'active':
[`nc-view-item nc-${view.type}-view-item`]: true, (route.params.viewTitle && route.params.viewTitle === view.title) || (route.params.viewTitle === '' && index === 0),
[`nc-view-item nc-${viewTypeAlias[view.type] || view.type}-view-item`]: true,
}" }"
@change-view="changeView" @change-view="changeView"
@open-modal="$emit('openModal', $event)" @open-modal="$emit('openModal', $event)"

Loading…
Cancel
Save