Browse Source

chore(nc-gui): lint

pull/4031/head
braks 2 years ago
parent
commit
4049fd1b45
  1. 14
      packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue
  2. 6
      packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue
  3. 2
      packages/nc-gui/composables/useViews.ts

14
packages/nc-gui/components/smartsheet/sidebar/MenuTop.vue

@ -1,8 +1,9 @@
<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 { Menu as AntMenu } from 'ant-design-vue'
import Sortable from 'sortablejs'
import type { Menu as AntMenu } from 'ant-design-vue'
import {
ActiveViewInj,
extractSdkResponseErrorMsg,
@ -149,9 +150,10 @@ const initSortable = (el: HTMLElement) => {
onMounted(() => menuRef && initSortable(menuRef.$el))
/** Navigate to view by changing url param */
function changeView(view: { id: string; alias?: string; title?: string; type: ViewTypes }) {
function changeView(view: ViewType) {
router.push({ params: { viewTitle: view.title || '' } })
if (view.type === 1 && selected.value[0] === view.id) {
if (view.type === ViewTypes.FORM && selected.value[0] === view.id) {
// reload the page if the same form view is clicked
// router.go(0)
// fix me: router.go(0) reloads entire page. need to reload only the form view
@ -183,7 +185,7 @@ async function onRename(view: ViewType) {
}
/** Open delete modal */
function openDeleteDialog(view: Record<string, any>) {
function openDeleteDialog(view: ViewType) {
const isOpen = ref(true)
const { close } = useDialog(resolveComponent('DlgViewDelete'), {
@ -229,7 +231,7 @@ function openDeleteDialog(view: Record<string, any>) {
}"
@change-view="changeView"
@open-modal="$emit('openModal', $event)"
@delete="openDeleteDialog(view)"
@delete="openDeleteDialog"
@rename="onRename"
/>
</a-menu>

6
packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue

@ -30,7 +30,7 @@ const props = defineProps<Props>()
const emits = defineEmits<Emits>()
const vModel = useVModel(props, 'view', emits) as WritableComputedRef<ViewType & { is_default: boolean }>
const vModel = useVModel(props, 'view', emits) as WritableComputedRef<ViewType & { alias?: string; is_default: boolean }>
const { $e } = useNuxtApp()
@ -56,6 +56,8 @@ const onClick = useDebounceFn(() => {
/** Enable editing view name on dbl click */
function onDblClick() {
if (!isUIAllowed('virtualViewsCreateOrEdit')) return
if (!isEditing) {
isEditing = true
originalTitle = vModel.value.title
@ -162,7 +164,7 @@ function onStopEdit() {
<template>
<a-menu-item
class="select-none group !flex !items-center !my-0 hover:(bg-primary !bg-opacity-5)"
@dblclick.stop="isUIAllowed('virtualViewsCreateOrEdit') && onDblClick()"
@dblclick.stop="onDblClick"
@click.stop="onClick"
>
<div v-e="['a:view:open', { view: vModel.type }]" class="text-xs flex items-center w-full gap-2">

2
packages/nc-gui/composables/useViews.ts

@ -22,7 +22,7 @@ export function useViews(meta: MaybeRef<TableType | undefined>) {
isLoading.value = false
}
watch(() => meta, loadViews, { immediate: true })
watch(() => unref(meta), loadViews, { immediate: true })
return { views, isLoading, loadViews }
}

Loading…
Cancel
Save