Browse Source

mobile optimisations - for now, move views sidebar again to the right - WIP

pull/5114/head
Daniel Spaude 1 year ago
parent
commit
a845a32b60
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 2
      packages/nc-gui/components.d.ts
  2. 1
      packages/nc-gui/components/smartsheet/qr-scanner-button/QrScannerButton.vue
  3. 4
      packages/nc-gui/components/smartsheet/sidebar/index.vue
  4. 166
      packages/nc-gui/components/smartsheet/sidebar/mobile.vue
  5. 32
      packages/nc-gui/pages/[projectType]/[projectId]/index.vue
  6. 2
      packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue

2
packages/nc-gui/components.d.ts vendored

@ -204,6 +204,8 @@ declare module '@vue/runtime-core' {
MdiLogin: typeof import('~icons/mdi/login')['default']
MdiLogout: typeof import('~icons/mdi/logout')['default']
MdiMagnify: typeof import('~icons/mdi/magnify')['default']
MdiMapMarker: typeof import('~icons/mdi/map-marker')['default']
MdiMapMarkerAlert: typeof import('~icons/mdi/map-marker-alert')['default']
MdiMenu: typeof import('~icons/mdi/menu')['default']
MdiMenuDown: typeof import('~icons/mdi/menu-down')['default']
MdiMicrosoftTeams: typeof import('~icons/mdi/microsoft-teams')['default']

1
packages/nc-gui/components/smartsheet/qr-scanner-button/QrScannerButton.vue

@ -117,7 +117,6 @@ const onDecode = async (codeValue: string) => {
<div>
<StreamBarcodeReader v-show="showScannerField" @decode="onDecode" @loaded="onLoaded"></StreamBarcodeReader>
<div v-if="showPleaseSelectColumnMessage" class="text-left text-wrap mt-2 text-[#e65100] text-xs">
Please select a column
{{ $t('msg.info.codeScanner.selectColumn') }}
</div>
<div v-if="showScannerIsLoadingMessage" class="text-left text-wrap mt-2 text-[#e65100] text-xs">

4
packages/nc-gui/components/smartsheet/sidebar/index.vue

@ -35,8 +35,6 @@ const setLastOpenedViewId = (viewId?: string) => {
const { isUIAllowed } = useUIPermission()
const { isMobileMode } = useGlobal()
const router = useRouter()
const route = useRoute()
@ -46,7 +44,7 @@ const { $e } = useNuxtApp()
/** Sidebar visible */
const { isOpen } = useSidebar('nc-right-sidebar')
const sidebarCollapsed = computed(() => !isOpen.value || isMobileMode.value)
const sidebarCollapsed = computed(() => !isOpen.value)
/** Sidebar ref */
const sidebar = ref()

166
packages/nc-gui/components/smartsheet/sidebar/mobile.vue

@ -1,166 +0,0 @@
<script setup lang="ts">
import type { ViewType, ViewTypes } from 'nocodb-sdk'
import {
ActiveViewInj,
MetaInj,
inject,
ref,
resolveComponent,
useDialog,
useNuxtApp,
useRoute,
useRouter,
useUIPermission,
useViews,
watch,
} from '#imports'
const emits = defineEmits(['closeMobileViewsSidebar'])
const meta = inject(MetaInj, ref())
const activeView = inject(ActiveViewInj, ref())
const { activeTab } = useTabs()
const { views, loadViews, isLoading } = useViews(meta)
const { lastOpenedViewMap } = useProject()
const setLastOpenedViewId = (viewId?: string) => {
if (viewId && activeTab.value?.id) {
lastOpenedViewMap.value[activeTab.value?.id] = viewId
}
}
const { isUIAllowed } = useUIPermission()
const router = useRouter()
const route = useRoute()
const { $e } = useNuxtApp()
/** Watch route param and change active view based on `viewTitle` */
watch(
[views, () => route.params.viewTitle],
([nextViews, viewTitle]) => {
const lastOpenedViewId = activeTab.value?.id && lastOpenedViewMap.value[activeTab.value?.id]
const lastOpenedView = nextViews.find((v) => v.id === lastOpenedViewId)
if (viewTitle) {
let view = nextViews.find((v) => v.title === viewTitle)
if (view) {
activeView.value = view
setLastOpenedViewId(activeView.value?.id)
} else {
/** search with view id and if found replace with title */
view = nextViews.find((v) => v.id === viewTitle)
if (view) {
router.replace({
params: {
viewTitle: view.title,
},
})
}
}
} else if (lastOpenedView) {
/** if active view is not found, set it to last opened view */
router.replace({
params: {
viewTitle: lastOpenedView.title,
},
})
} else {
if (nextViews?.length && activeView.value !== nextViews[0]) {
activeView.value = nextViews[0]
}
}
/** if active view is not found, set it to first view */
if (nextViews?.length && (!activeView.value || !nextViews.includes(activeView.value))) {
activeView.value = nextViews[0]
}
},
{ immediate: true },
)
/** Open delete modal */
function onOpenModal({
title = '',
type,
copyViewId,
groupingFieldColumnId,
}: {
title?: string
type: ViewTypes
copyViewId?: string
groupingFieldColumnId?: string
}) {
const isOpen = ref(true)
const { close } = useDialog(resolveComponent('DlgViewCreate'), {
'modelValue': isOpen,
title,
type,
meta,
'selectedViewId': copyViewId,
groupingFieldColumnId,
'views': views,
'onUpdate:modelValue': closeDialog,
'onCreated': async (view: ViewType) => {
closeDialog()
await loadViews()
router.push({ params: { viewTitle: view.title || '' } })
$e('a:view:create', { view: view.type })
},
})
function closeDialog() {
isOpen.value = false
close(1000)
}
}
</script>
<template>
<div class="flex items-center inline m-4">
<MdiBackburger
v-e="['c:grid:toggle-navdraw']"
class="cursor-pointer transform transition-transform duration-500"
@click="emits('closeMobileViewsSidebar')"
/>
<span class="ml-2 text-bold uppercase text-gray-500 font-weight-bold">{{ meta?.title }}</span>
</div>
<div class="flex-1 flex flex-col min-h-0">
<GeneralOverlay v-if="!views.length" :model-value="isLoading" inline class="bg-gray-300/50">
<div class="w-full h-full flex items-center justify-center">
<a-spin />
</div>
</GeneralOverlay>
<LazySmartsheetSidebarMenuTop :views="views" @open-modal="onOpenModal" @deleted="loadViews" />
<template v-if="isUIAllowed('virtualViewsCreateOrEdit')">
<div class="!my-3 w-full border-b-1" />
<LazySmartsheetSidebarMenuBottom @open-modal="onOpenModal" />
</template>
</div>
</template>
<style scoped>
:deep(.ant-menu-title-content) {
@apply w-full;
}
:deep(.ant-layout-sider-children) {
@apply flex flex-col;
}
</style>

32
packages/nc-gui/pages/[projectType]/[projectId]/index.vue

@ -68,17 +68,6 @@ const dropdownOpen = ref(false)
const activeView = ref()
const { activeTab } = useTabs()
const { metas } = useMetas()
const meta = computed<TableType | undefined>(() => activeTab.value && metas.value[activeTab.value.id!])
provide(ActiveViewInj, activeView)
provide(MetaInj, meta)
useViews(meta)
const showViewsMobileSidebar = ref(false)
/** Sidebar ref */
const sidebar = ref()
@ -209,18 +198,6 @@ onMounted(() => {
toggleHasSidebar(true)
})
const onClickedTableLink = () => {
if (isMobileMode) {
showViewsMobileSidebar.value = true
}
}
const onCloseMobileViewsSidebar = () => {
if (isMobileMode) {
showViewsMobileSidebar.value = false
}
}
onBeforeUnmount(reset)
function openKeyboardShortcutDialog() {
@ -600,8 +577,7 @@ useEventListener(document, 'keydown', async (e: KeyboardEvent) => {
</a-dropdown>
<div
class="hover:after:(bg-primary bg-opacity-75) group nc-sidebar-add-row flex items-center px-2"
:class="{ 'nc-sidebar-left-toggle-icon': !isMobileMode }"
class="nc-sidebar-left-toggle-icon hover:after:(bg-primary bg-opacity-75) group nc-sidebar-add-row flex items-center px-2"
>
<MdiBackburger
v-e="['c:grid:toggle-navdraw']"
@ -612,11 +588,7 @@ useEventListener(document, 'keydown', async (e: KeyboardEvent) => {
</div>
</div>
<LazyDashboardTreeView v-if="!(isMobileMode && showViewsMobileSidebar)" @clicked-table-link="onClickedTableLink" />
<SmartsheetSidebarMobile
v-if="meta && isMobileMode && showViewsMobileSidebar"
@close-mobile-views-sidebar="onCloseMobileViewsSidebar"
/>
<LazyDashboardTreeView @create-base-dlg="toggleDialog(true, 'dataSources')" />
</a-layout-sider>
</template>

2
packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue

@ -91,7 +91,7 @@ onMounted(() => {
</div>
<LazyGeneralShareBaseButton class="mb-1px" />
<LazyGeneralFullScreen v-if="!isMobileMode" class="nc-fullscreen-icon mb-1px" />
<LazyGeneralFullScreen class="nc-fullscreen-icon mb-1px" />
</div>
<div ref="mainArea" class="w-full min-h-[300px] flex-auto">

Loading…
Cancel
Save