多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

242 lines
7.3 KiB

<script lang="ts" setup>
import { type ViewType } from 'nocodb-sdk'
import { ViewTypes } from 'nocodb-sdk'
const props = defineProps<{
// Prop used to align the dropdown to the left in sidebar
alignLeftLevel: number | undefined
source: Source
}>()
const { $e } = useNuxtApp()
const alignLeftLevel = toRef(props, 'alignLeftLevel')
const { refreshCommandPalette } = useCommandPalette()
const viewsStore = useViewsStore()
const { loadViews, navigateToView } = viewsStore
const { isFeatureEnabled } = useBetaFeatureToggle()
const table = inject(SidebarTableInj)!
const base = inject(ProjectInj)!
const isViewListLoading = ref(false)
const toBeCreateType = ref<ViewTypes | 'AI'>()
const isOpen = ref(false)
const overlayClassName = computed(() => {
if (alignLeftLevel.value === 1) return 'nc-view-create-dropdown nc-view-create-dropdown-left-1'
if (alignLeftLevel.value === 2) return 'nc-view-create-dropdown nc-view-create-dropdown-left-2'
return 'nc-view-create-dropdown'
})
Nc feat: header revamp (#9204) * fix(nc-gui): update topbar breadcrumb divider * feat(nc-gui): custom list component setup * fix(nc-gui): update reload view data tooltip * feat(nc-gui): custom list component * feat(nc-gui): add table list menu * fix(nc-gui): small changes * fix(nc-gui): add bases list dropdown * fix(nc-gui): show chevron icon in mobile view * feat(nc-gui): add view list dropdown in topbar * fix(nc-gui): auto scroll selected list option on open dropdown * feat(nc-gui): add typedocs for each fun from custom list component * chore(nc-gui): add typedocs for new functions * fix(nc-gui): view search issue on default view * fix(nc-gui): reset selected option hover state on search input * fix(nc-gui): font weight issue * fix(nc-gui): show reload data topbar option * fix(nc-gui): change view action menu position * fix(nc-gui): font weight issue * feat(nc-gui): create new table/view from topbar * fix(nc-gui): update other page headers * fix(nc-gui): project view header * fix(nc-gui): update admin panel workspaces page header * fix(nc-gui): admin panel base/workspace user page header * fix(nc-gui): admin panel scroll issue * fix(nc-gui): update project home page * fix(nc-gui): table list scroll issue * chore(nc-gui): lint * fix(nc-gui): reset breadcrumb btn hover state on open dropdown * fix(nc-gui): review changes * fix(nc-gui): use slash icon instead of text * fix(nc-gui): pr review changes * fix(nc-gui): details tab height issue * fix(nc-gui): add user account pages breadcrumb * fix(nc-gui): hide rename view option * fix(nc-gui): disable scrollIntoView on base rename * fix(nc-gui): on rename view select text * fix(nc-gui): user menu overflow issue if sidebar baselist is scrollable * feat(nc-gui): use virtual scrolling for NcList component * fix(nc-gui): reduce chevron icon opacity * chore(nc-gui): lint * fix(nc-gui): ai review changes * fix(nc-gui): view rename input focus issue * fix(nc-gui): topbar width issue * fix(nc-gui): udpate toolbar height * fix(nc-gui): update chevron icon from breadcrumb * fix(nc-gui): update breadcrumb icon size * fix(nc-gui): add min width for breadcrumb * fix(nc-gui): add topbar bottom border * fix(nc-gui): details tab heigth and alignment issue * fix(nc-gui): hide basename and show only icon * fix(nc-gui): update NcList component * fix(nc-gui): update admin panel header * fix(nc-gui): add header in account settings pages * fix(nc-gui): add account pages header oss * fix(nc-gui): udpate max width * chore(nc-gui): lint * fix(nc-gui(: reduce topbar top padding * fix(nc-gui): typo error * fix(nc-gui): review changes * fix(nc-gui): review changes * fix(nc-gui): slash icon conflict * fix(nc-gui): review changes * fix(nc-gui): remove chevron icon & add list wrapper div to control height * fix(nc-gui): ncList keyboard navigation issue * chore(nc-gui): lint
4 months ago
/**
* Opens a modal for creating or editing a view.
*
* @param options - The options for opening the modal.
* @param options.title - The title of the modal. Default is an empty string.
* @param options.type - The type of view to create or edit.
* @param options.copyViewId - The ID of the view to copy, if creating a copy.
* @param options.groupingFieldColumnId - The ID of the column to use for grouping, if applicable.
* @param options.calendarRange - The date range for calendar views.
* @param options.coverImageColumnId - The ID of the column to use for cover images, if applicable.
*
* @returns A Promise that resolves when the modal operation is complete.
*
* @remarks
* This function opens a modal dialog for creating or editing a view.
* It handles the dialog state, view creation, and navigation to the newly created view.
* After creating a view, it refreshes the command palette and reloads the views.
*
* @see {@link packages/nc-gui/components/smartsheet/topbar/ViewListDropdown.vue} for a similar implementation of view creation dialog.
* If this function is updated, consider updating the other implementations as well.
*/
async function onOpenModal({
title = '',
type,
copyViewId,
groupingFieldColumnId,
calendarRange,
coverImageColumnId,
}: {
title?: string
type: ViewTypes | 'AI'
copyViewId?: string
groupingFieldColumnId?: string
calendarRange?: Array<{
fk_from_column_id: string
fk_to_column_id: string | null // for ee only
}>
coverImageColumnId?: string
}) {
if (isViewListLoading.value) return
toBeCreateType.value = type
isViewListLoading.value = true
await loadViews({
tableId: table.value.id!,
})
isOpen.value = false
isViewListLoading.value = false
const isDlgOpen = ref(true)
const { close } = useDialog(resolveComponent('DlgViewCreate'), {
'modelValue': isDlgOpen,
title,
type,
'tableId': table.value.id,
'selectedViewId': copyViewId,
calendarRange,
groupingFieldColumnId,
coverImageColumnId,
'baseId': base.value.id,
'onUpdate:modelValue': closeDialog,
'onCreated': async (view?: ViewType) => {
closeDialog()
refreshCommandPalette()
await loadViews({
tableId: table.value.id!,
force: true,
})
table.value.meta = {
...(table.value.meta as object),
hasNonDefaultViews: true,
}
if (view) {
navigateToView({
view,
tableId: table.value.id!,
baseId: base.value.id!,
doNotSwitchTab: true,
})
}
$e('a:view:create', { view: view?.type || type })
},
})
function closeDialog() {
isOpen.value = false
1 year ago
isDlgOpen.value = false
close(1000)
}
}
</script>
<template>
<NcDropdown v-model:visible="isOpen" :overlay-class-name="overlayClassName" destroy-popup-on-hide @click.stop="isOpen = true">
<slot />
<template #overlay>
<NcMenu class="max-w-48">
<NcMenuItem @click.stop="onOpenModal({ type: ViewTypes.GRID })">
<div class="item" data-testid="sidebar-view-create-grid">
<div class="item-inner">
<GeneralViewIcon :meta="{ type: ViewTypes.GRID }" />
<div>Grid</div>
</div>
<GeneralLoader v-if="toBeCreateType === ViewTypes.GRID && isViewListLoading" />
<GeneralIcon v-else class="plus" icon="plus" />
</div>
</NcMenuItem>
<NcMenuItem v-if="!source.is_data_readonly" @click="onOpenModal({ type: ViewTypes.FORM })">
<div class="item" data-testid="sidebar-view-create-form">
<div class="item-inner">
<GeneralViewIcon :meta="{ type: ViewTypes.FORM }" />
<div>Form</div>
</div>
<GeneralLoader v-if="toBeCreateType === ViewTypes.FORM && isViewListLoading" />
<GeneralIcon v-else class="plus" icon="plus" />
</div>
</NcMenuItem>
<NcMenuItem @click="onOpenModal({ type: ViewTypes.GALLERY })">
<div class="item" data-testid="sidebar-view-create-gallery">
<div class="item-inner">
<GeneralViewIcon :meta="{ type: ViewTypes.GALLERY }" />
<div>Gallery</div>
</div>
<GeneralLoader v-if="toBeCreateType === ViewTypes.GALLERY && isViewListLoading" />
<GeneralIcon v-else class="plus" icon="plus" />
</div>
</NcMenuItem>
<NcMenuItem data-testid="sidebar-view-create-kanban" @click="onOpenModal({ type: ViewTypes.KANBAN })">
<div class="item">
<div class="item-inner">
<GeneralViewIcon :meta="{ type: ViewTypes.KANBAN }" />
<div>Kanban</div>
</div>
<GeneralLoader v-if="toBeCreateType === ViewTypes.KANBAN && isViewListLoading" />
<GeneralIcon v-else class="plus" icon="plus" />
</div>
</NcMenuItem>
<NcMenuItem data-testid="sidebar-view-create-calendar" @click="onOpenModal({ type: ViewTypes.CALENDAR })">
<div class="item">
<div class="item-inner">
<GeneralViewIcon :meta="{ type: ViewTypes.CALENDAR }" class="!w-4 !h-4" />
10 months ago
<div>{{ $t('objects.viewType.calendar') }}</div>
</div>
<GeneralLoader v-if="toBeCreateType === ViewTypes.CALENDAR && isViewListLoading" />
Nc Fix: UI improvements - left sidebar (#8244) * fix(nc-gui); update toolbar menu text grom GroupBy to Group * fix(nc-gui): move sidebar base, table expand icon to the right side * fix(nc-gui): sidebar base, table, view menu options padding issue * fix(nc-gui): add background color for row on hover in grid view * fix(nc-gui): reduce width of index column * fix(nc-gui): on hover grid row bg opacity issue * fix(nc-gui): reduce font size and grid cell height * fix(nc-gui): sidebar view menu alignment issue on mobile screen * fix(nc-gui): reduce font size * fix(nc-gui): set column default width to 180px * fix(nc-gui): keep only sidebar changes & revert all other changes * fix(nc-gui): change table icon * fix(nc-gui): trim base, table, view title while saving it * fix(nc-gui): increate left sidebar max width * fix(nc-gui): show truncated base/table/view name until standard end * fix(nc-gui): oss sidebar base menu options alignment issue * fix(nc-gui): use valid classname * fix(nc-gui): sidebar external db source menu ui fixes * fix(nc-gui): small changes * chore(nc-gui): lint * fix(nc-gui): pw test fail issue * fix(nc-gui): trim title while creating base, table, view * fix(nc-gui): some of the sidebar pw test fail issues * fix(test): sidebar test fail issue * fix(test): projectCollaboration test fail issue * fix(nc-gui): change font size of view menu option view mode chip text * fix(nc-gui): grayed out create view dropdown plus icon color * fix(nc-gui): grayed out table icon and reduce width of default view context menu * fix(nc-gui): remove copyright text from user menu * fix(nc-gui): chevron icon and show/hide sidebar icon should be gray in color
8 months ago
<GeneralIcon v-else class="plus" icon="plus" />
</div>
</NcMenuItem>
<template v-if="isFeatureEnabled(FEATURE_FLAG.AI_FEATURES)">
<NcDivider />
<NcMenuItem data-testid="sidebar-view-create-ai" @click="onOpenModal({ type: 'AI' })">
<div class="item">
<div class="item-inner">
<GeneralIcon icon="ncAutoAwesome" class="!w-4 !h-4 text-nc-fill-purple-dark" />
<div>{{ $t('labels.aiSuggested') }}</div>
</div>
</div>
</NcMenuItem>
</template>
</NcMenu>
</template>
</NcDropdown>
</template>
<style lang="scss" scoped>
.item {
@apply flex flex-row items-center w-36 justify-between;
}
.item-inner {
@apply flex flex-row items-center gap-x-1.75;
}
.plus {
Nc Fix: UI improvements - left sidebar (#8244) * fix(nc-gui); update toolbar menu text grom GroupBy to Group * fix(nc-gui): move sidebar base, table expand icon to the right side * fix(nc-gui): sidebar base, table, view menu options padding issue * fix(nc-gui): add background color for row on hover in grid view * fix(nc-gui): reduce width of index column * fix(nc-gui): on hover grid row bg opacity issue * fix(nc-gui): reduce font size and grid cell height * fix(nc-gui): sidebar view menu alignment issue on mobile screen * fix(nc-gui): reduce font size * fix(nc-gui): set column default width to 180px * fix(nc-gui): keep only sidebar changes & revert all other changes * fix(nc-gui): change table icon * fix(nc-gui): trim base, table, view title while saving it * fix(nc-gui): increate left sidebar max width * fix(nc-gui): show truncated base/table/view name until standard end * fix(nc-gui): oss sidebar base menu options alignment issue * fix(nc-gui): use valid classname * fix(nc-gui): sidebar external db source menu ui fixes * fix(nc-gui): small changes * chore(nc-gui): lint * fix(nc-gui): pw test fail issue * fix(nc-gui): trim title while creating base, table, view * fix(nc-gui): some of the sidebar pw test fail issues * fix(test): sidebar test fail issue * fix(test): projectCollaboration test fail issue * fix(nc-gui): change font size of view menu option view mode chip text * fix(nc-gui): grayed out create view dropdown plus icon color * fix(nc-gui): grayed out table icon and reduce width of default view context menu * fix(nc-gui): remove copyright text from user menu * fix(nc-gui): chevron icon and show/hide sidebar icon should be gray in color
8 months ago
@apply text-gray-500;
}
</style>
<style lang="scss">
.nc-view-create-dropdown {
@apply !max-w-43 !min-w-43;
}
.nc-view-create-dropdown-left-1 {
@apply !left-18;
}
.nc-view-create-dropdown-left-2 {
@apply !left-23.5;
}
</style>