Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

feat: outline (list) view

DarkPhoenix27043ada41eb99c5
diff --git a/packages/nc-gui/assets/css/variables.css b/packages/nc-gui/assets/css/variables.css
index 1cbebb6b6b..a0419f8c22 100644
--- a/packages/nc-gui/assets/css/variables.css
+++ b/packages/nc-gui/assets/css/variables.css
@@ -437,6 +437,7 @@
--color-view-icon-gallery: #fc3ac6;
--color-view-icon-map: blue;
--color-view-icon-kanban: #ff9052;
+ --color-view-icon-outline: #27d665;
--color-view-icon-view: blue;
}
@@ -855,6 +856,7 @@
--color-view-icon-gallery: #ff66da;
--color-view-icon-map: #6ab5ff;
--color-view-icon-kanban: #ffad70;
+ --color-view-icon-outline: #27d665;
--color-view-icon-view: #6ab5ff;
}
diff --git a/packages/nc-gui/components/dashboard/MiniSidebar/CreateNewActionMenu.vue b/packages/nc-gui/components/dashboard/MiniSidebar/CreateNewActionMenu.vue
index 463d2b6400..37db6f0a9c 100644
--- a/packages/nc-gui/components/dashboard/MiniSidebar/CreateNewActionMenu.vue
+++ b/packages/nc-gui/components/dashboard/MiniSidebar/CreateNewActionMenu.vue
@@ -21,7 +21,7 @@ const { openNewDashboardModal } = useDashboardStore()
const viewsStore = useViewsStore()
const { loadViews, onOpenViewCreateModal } = viewsStore
-const { activeView } = storeToRefs(viewsStore)
+const { activeView, isOutlineViewEnabled } = storeToRefs(viewsStore)
const { isAiFeaturesEnabled } = useNocoAi()
@@ -254,6 +254,12 @@ const hasDashboardCreateAccess = computed(() => {
<GeneralViewIcon :meta="{ type: ViewTypes.CALENDAR }" class="!w-4 !h-4" />
<div>{{ $t('objects.viewType.calendar') }}</div>
</NcMenuItem>
+ <template v-if="isOutlineViewEnabled">
+ <NcMenuItem data-testid="mini-sidebar-view-create-outline" @click="onOpenModal({ type: ViewTypes.OUTLINE })">
+ <GeneralViewIcon :meta="{ type: ViewTypes.OUTLINE }" />
+ <div>{{ $t('objects.viewType.outline') }}</div>
+ </NcMenuItem>
+ </template>
<template v-if="isAiFeaturesEnabled">
<NcDivider />
<NcMenuItem data-testid="mini-sidebar-view-create-ai" @click="onOpenModal({ type: 'AI' })">
diff --git a/packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue b/packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue
index d7ebb63353..b9bfc1554a 100644
--- a/packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue
+++ b/packages/nc-gui/components/dashboard/TreeView/CreateViewBtn.vue
@@ -14,6 +14,7 @@ const alignLeftLevel = toRef(props, 'alignLeftLevel')
const viewsStore = useViewsStore()
const { loadViews, onOpenViewCreateModal } = viewsStore
+const { isOutlineViewEnabled } = storeToRefs(viewsStore)
const { isAiFeaturesEnabled } = useNocoAi()
@@ -29,6 +30,8 @@ const isSqlView = computed(() => (table.value as TableType)?.type === 'view')
const isSyncedTable = computed(() => (table.value as TableType)?.synced)
+const isPgSource = computed(() => props.source?.type === 'pg')
+
const overlayClassName = computed(() => {
if (alignLeftLevel.value === 1) return 'nc-view-create-dropdown nc-view-create-dropdown-left-1'
@@ -186,6 +189,25 @@ async function onOpenModal({
<GeneralIcon v-else class="plus" icon="plus" />
</div>
</NcMenuItem>
+ <template v-if="isOutlineViewEnabled">
+ <NcTooltip :title="$t('tooltip.outlineViewOnlyPg')" :disabled="isPgSource" placement="right">
+ <NcMenuItem
+ :disabled="!isPgSource"
+ data-testid="sidebar-view-create-outline"
+ @click="isPgSource && onOpenModal({ type: ViewTypes.OUTLINE })"
+ >
+ <div class="item">
+ <div class="item-inner">
+ <GeneralViewIcon :meta="{ type: ViewTypes.OUTLINE }" :class="{ '!opacity-50': !isPgSource }" />
+ <div>{{ $t('objects.viewType.outline') }}</div>
+ </div>
+
+ <GeneralLoader v-if="toBeCreateType === ViewTypes.OUTLINE && isViewListLoading" />
+ <GeneralIcon v-else class="plus" icon="plus" :class="{ '!text-current': !isPgSource }" />
+ </div>
+ </NcMenuItem>
+ </NcTooltip>
+ </template>
<template v-if="isAiFeaturesEnabled">
<NcDivider />
<NcTooltip :title="`Auto suggest views for ${table?.title || 'the current table'}`" placement="right">
diff --git a/packages/nc-gui/components/dlg/View/Create.vue b/packages/nc-gui/components/dlg/View/Create.vue
index f004a4c8e8..a3c8ab4216 100644
--- a/packages/nc-gui/components/dlg/View/Create.vue
+++ b/packages/nc-gui/components/dlg/View/Create.vue
@@ -171,6 +171,7 @@ const typeAlias = computed(
[ViewTypes.KANBAN]: 'kanban',
[ViewTypes.MAP]: 'map',
[ViewTypes.CALENDAR]: 'calendar',
+ [ViewTypes.OUTLINE]: 'outline',
// Todo: add ai view docs route
AI: '',
}[props.type]),
@@ -840,6 +841,14 @@ watch(activeBaseId, () => {
{{ $t(`labels.${getPluralName('createCalendarView')}`) }}
</template>
</template>
+ <template v-else-if="form.type === ViewTypes.OUTLINE">
+ <template v-if="form.copy_from_id">
+ {{ $t('labels.duplicateOutlineView') }}
+ </template>
+ <template v-else>
+ {{ $t(`labels.${getPluralName('createOutlineView')}`) }}
+ </template>
+ </template>
<template v-else-if="form.type === 'AI'">
{{ $t('labels.createViewUsingAi') }}
</template>
diff --git a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue
index f6fc4d35c4..4f55ef8b59 100644
--- a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue
+++ b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue
@@ -308,6 +308,9 @@ function sharedViewUrl(withPrefill = true) {
case ViewTypes.CALENDAR:
viewType = 'calendar'
break
+ case ViewTypes.OUTLINE:
+ viewType = 'outline'
+ break
default:
viewType = 'view'
}
diff --git a/packages/nc-gui/components/shared-view/Outline.vue b/packages/nc-gui/components/shared-view/Outline.vue
new file mode 100644
index 0000000000..64d9816820
--- /dev/null
+++ b/packages/nc-gui/components/shared-view/Outline.vue
@@ -0,0 +1,49 @@
+<script lang="ts" setup>
+const { sharedView, meta, nestedFilters } = useSharedView()
+
+const { signedIn } = useGlobal()
+
+const { loadProject } = useBase()
+
+const { isLocked } = useProvideSmartsheetStore(sharedView, meta, true, ref([]), nestedFilters)
+
+useProvideOutlineViewStore(meta, sharedView)
+
+const reloadEventHook = createEventHook()
+
+provide(ReloadViewDataHookInj, reloadEventHook)
+provide(ReadonlyInj, ref(true))
+provide(MetaInj, meta)
+provide(ActiveViewInj, sharedView)
+provide(IsPublicInj, ref(true))
+provide(IsLockedInj, isLocked)
+
+useProvideViewColumns(sharedView, meta, () => reloadEventHook?.trigger(), true)
+
+useProvideSmartsheetLtarHelpers(meta)
+
+useViewRowColorProvider({ shared: true })
+
+if (signedIn.value) {
+ try {
+ await loadProject()
+ } catch (e: any) {
+ console.error(e)
+ message.error(await extractSdkResponseErrorMsg(e))
+ }
+}
+</script>
+
+<template>
+ <div class="nc-container flex flex-col h-full">
+ <LazySmartsheetToolbar show-full-screen-toggle />
+ <SmartsheetOutline />
+ </div>
+</template>
+
+<style scoped>
+.nc-container {
+ height: 100%;
+ flex: 1 1 100%;
+}
+</style>
diff --git a/packages/nc-gui/components/smartsheet/Toolbar.vue b/packages/nc-gui/components/smartsheet/Toolbar.vue
index 75751757ed..8b03958bb6 100644
--- a/packages/nc-gui/components/smartsheet/Toolbar.vue
+++ b/packages/nc-gui/components/smartsheet/Toolbar.vue
@@ -9,7 +9,7 @@ const isLocked = inject(IsLockedInj, ref(false))
const activeView = inject(ActiveViewInj, ref())
-const { isGrid, isGallery, isKanban, isMap, isCalendar, isForm, isViewOperationsAllowed, allFilters } =
+const { isGrid, isGallery, isKanban, isMap, isCalendar, isOutline, isForm, isViewOperationsAllowed, allFilters } =
useSmartsheetStoreOrThrow()
const { isUIAllowed } = useRoles()
@@ -102,15 +102,17 @@ provide(IsToolbarIconMode, isToolbarIconMode)
<SmartsheetToolbarStackedBy v-if="isKanban" />
- <SmartsheetToolbarFieldsMenu v-if="isGrid || isGallery || isKanban || isMap" :show-system-fields="false" />
+ <SmartsheetToolbarOutlineSetLevels v-if="isOutline" />
- <SmartsheetToolbarColumnFilterMenu v-if="isGrid || isGallery || isKanban || isMap" />
+ <SmartsheetToolbarFieldsMenu v-if="isGrid || isGallery || isKanban || isMap || isOutline" :show-system-fields="false" />
+
+ <SmartsheetToolbarColumnFilterMenu v-if="isGrid || isGallery || isKanban || isMap || isOutline" />
<SmartsheetToolbarGroupByMenu v-if="isGrid" />
- <SmartsheetToolbarSortListMenu v-if="isGrid || isGallery || isKanban" />
+ <SmartsheetToolbarSortListMenu v-if="isGrid || isGallery || isKanban || isOutline" />
- <SmartsheetToolbarRowColorFilterDropdown v-if="!isPublic && !isSharedBase && (isGrid || isGallery || isKanban)" />
+ <SmartsheetToolbarRowColorFilterDropdown v-if="!isPublic && !isSharedBase && (isGrid || isGallery || isKanban || isOutline)" />
<SmartsheetToolbarBulkAction
v-if="(isGrid || isGallery) && !isPublic && !isSharedBase && isUIAllowed('scriptExecute') && isViewActionsEnabled"
@@ -126,7 +128,7 @@ provide(IsToolbarIconMode, isToolbarIconMode)
<SmartsheetToolbarCalendarMode v-if="isCalendar && isTab" :tab="isTab" />
<template v-if="!isMobileMode">
- <SmartsheetToolbarRowHeight v-if="isGrid && isViewOperationsAllowed" />
+ <SmartsheetToolbarRowHeight v-if="(isGrid || isOutline) && isViewOperationsAllowed" />
<template v-if="!isCalendar">
<SmartsheetToolbarExport v-if="!isViewOperationsAllowed" is-in-toolbar />
@@ -145,7 +147,7 @@ provide(IsToolbarIconMode, isToolbarIconMode)
<SmartsheetToolbarCalendarActiveView v-if="isCalendar" />
<SmartsheetToolbarSearchData
- v-if="isGrid || isGallery || isKanban"
+ v-if="isGrid || isGallery || isKanban || isOutline"
:class="{
'shrink': !isMobileMode,
'w-full': isMobileMode,
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/components/Scroller.vue b/packages/nc-gui/components/smartsheet/grid/canvas/components/Scroller.vue
index a371c55cf4..540a4ecf6c 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/components/Scroller.vue
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/components/Scroller.vue
@@ -16,6 +16,10 @@ const props = defineProps({
type: Number,
default: 0,
},
+ inset: {
+ type: Number,
+ default: 72,
+ },
})
const emit = defineEmits(['scroll'])
@@ -44,6 +48,8 @@ const height = toRef(props, 'height')
const width = toRef(props, 'width')
+const inset = toRef(props, 'inset')
+
const wrapperRef = ref()
const contentWrapper = ref()
const verticalScrollbar = ref(null)
@@ -101,7 +107,7 @@ const horizontalThumbWidth = computed(() => {
})
const verticalThumbPosition = computed(() => {
- const availableSpace = height.value - 72 - ((height.value - 72) * verticalThumbHeight.value) / 100
+ const availableSpace = height.value - inset.value - ((height.value - inset.value) * verticalThumbHeight.value) / 100
const scrollRatio = scrollTop.value / (scrollHeight.value - height.value)
return scrollRatio * availableSpace
})
@@ -132,12 +138,12 @@ const updateScroll = (vertical?: number, horizontal?: number) => {
let newLeft = scrollLeft.value
if (vertical !== undefined) {
- const maxScroll = contentWrapper.value.scrollHeight - wrapperRef.value.clientHeight
+ const maxScroll = scrollHeight.value - height.value
newTop = getBoundedValue(vertical, 0, maxScroll)
}
if (horizontal !== undefined) {
- const maxScroll = contentWrapper.value.scrollWidth - wrapperRef.value.clientWidth
+ const maxScroll = scrollWidth.value - width.value
newLeft = getBoundedValue(horizontal, 0, maxScroll)
}
@@ -183,8 +189,8 @@ const handleWheel = (e: WheelEvent) => {
}
}
- const maxScrollY = contentWrapper.value.scrollHeight - wrapperRef.value.clientHeight
- const maxScrollX = contentWrapper.value.scrollWidth - wrapperRef.value.clientWidth
+ const maxScrollY = scrollHeight.value - height.value
+ const maxScrollX = scrollWidth.value - width.value
const canScrollVertically = (deltaY > 0 && scrollTop.value < maxScrollY) || (deltaY < 0 && scrollTop.value > 0)
const canScrollHorizontally = (deltaX > 0 && scrollLeft.value < maxScrollX) || (deltaX < 0 && scrollLeft.value > 0)
@@ -229,10 +235,8 @@ function handleDrag(event: MouseEvent | TouchEvent) {
const scrollRatio =
currentDragAxis.value === 'vertical'
- ? (contentWrapper.value.scrollHeight - wrapperRef.value.clientHeight) /
- (wrapperRef.value.clientHeight - (wrapperRef.value.clientHeight * verticalThumbHeight.value) / 100)
- : (contentWrapper.value.scrollWidth - wrapperRef.value.clientWidth) /
- (wrapperRef.value.clientWidth - (wrapperRef.value.clientWidth * horizontalThumbWidth.value) / 100)
+ ? (scrollHeight.value - height.value) / (height.value - (height.value * verticalThumbHeight.value) / 100)
+ : (scrollWidth.value - width.value) / (width.value - (width.value * horizontalThumbWidth.value) / 100)
const newScroll = dragStartScroll.value + delta * scrollRatio
@@ -259,10 +263,7 @@ const handleTrackClick = (axis: 'vertical' | 'horizontal', event: any) => {
const trackSize = axis === 'vertical' ? rect.height : rect.width
const scrollRatio = clickPosition / trackSize
- const maxScroll =
- axis === 'vertical'
- ? contentWrapper.value.scrollHeight - wrapperRef.value.clientHeight
- : contentWrapper.value.scrollWidth - wrapperRef.value.clientWidth
+ const maxScroll = axis === 'vertical' ? scrollHeight.value - height.value : scrollWidth.value - width.value
const newScroll = maxScroll * scrollRatio
@@ -354,10 +355,10 @@ const decayAnimation = (value: number, velocity: number): number => {
const animateScroll = () => {
const state = scrollState.value
- if (!state.animation || !contentWrapper.value || !wrapperRef.value) return
+ if (!state.animation) return
- const maxScrollY = contentWrapper.value.scrollHeight - wrapperRef.value.clientHeight
- const maxScrollX = contentWrapper.value.scrollWidth - wrapperRef.value.clientWidth
+ const maxScrollY = scrollHeight.value - height.value
+ const maxScrollX = scrollWidth.value - width.value
let newX = scrollLeft.value
let newY = scrollTop.value
diff --git a/packages/nc-gui/components/smartsheet/outline/composables/constants.ts b/packages/nc-gui/components/smartsheet/outline/composables/constants.ts
new file mode 100644
index 0000000000..f7471ae0fd
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/outline/composables/constants.ts
@@ -0,0 +1,36 @@
+// Row dimensions
+export const OUTLINE_ROW_HEIGHT = 40
+export const OUTLINE_HEADER_HEIGHT = 32
+
+// Sub-header row (column headers shown when expanding into a child level)
+export const SUB_HEADER_HEIGHT = 28
+
+// Add record row at the bottom of each group
+export const ADD_ROW_HEIGHT = 36
+
+// Indentation per depth level
+export const INDENT_PER_DEPTH = 28
+
+// Chevron column (fixed left area for expand/collapse + indent)
+export const CHEVRON_COL_WIDTH = 40
+
+// Chevron / expand-collapse toggle
+export const CHEVRON_SIZE = 16
+export const CHEVRON_MARGIN_RIGHT = 8
+
+// Gaps between depth transitions (rendered in useCanvasRender)
+export const DEPTH_INCREASE_GAP = 8
+export const DEPTH_DECREASE_GAP = 16
+
+// Cell padding
+export const CELL_PADDING = 10
+
+// Column resize
+export const RESIZE_HANDLE_WIDTH = 8
+export const MIN_COLUMN_WIDTH = 80
+
+// Default column width
+export const DEFAULT_COLUMN_WIDTH = 180
+
+// Bottom padding after the last row
+export const BOTTOM_PADDING = 120
diff --git a/packages/nc-gui/components/smartsheet/outline/composables/types.ts b/packages/nc-gui/components/smartsheet/outline/composables/types.ts
new file mode 100644
index 0000000000..35e659ffac
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/outline/composables/types.ts
@@ -0,0 +1,26 @@
+/**
+ * Hit-test element tracked during rendering.
+ */
+export interface OutlineCanvasElement {
+ type: 'row' | 'chevron' | 'header' | 'addRow' | 'expandRow' | 'cell'
+ rowIndex: number
+ x: number
+ y: number
+ width: number
+ height: number
+ depth: number
+ pk?: string | number
+ columnId?: string
+ parentPk?: string | number
+}
+
+export interface OutlineActiveCell {
+ rowIndex: number
+ depth: number
+ column: CanvasGridColumn
+ row: Record<string, any>
+ x: number
+ y: number
+ width: number
+ height: number
+}
diff --git a/packages/nc-gui/components/smartsheet/outline/composables/useCanvasOutline.ts b/packages/nc-gui/components/smartsheet/outline/composables/useCanvasOutline.ts
new file mode 100644
index 0000000000..1aee81d1f7
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/outline/composables/useCanvasOutline.ts
@@ -0,0 +1,891 @@
+import type { ColumnType, FormulaType, GridColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
+import { PermissionEntity, PermissionKey, UITypes, isLTAR, isSystemColumn, isVirtualCol } from 'nocodb-sdk'
+import { stringifyFilterOrSortArr } from '~/utils/dataUtils'
+import { SpriteLoader } from '../../grid/canvas/loaders/SpriteLoader'
+import { getSingleMultiselectColOptions, getUserColOptions, parseCellWidth } from '../../grid/canvas/utils/cell'
+import type { OutlineActiveCell, OutlineCanvasElement } from './types'
+import {
+ ADD_ROW_HEIGHT,
+ BOTTOM_PADDING,
+ CHEVRON_COL_WIDTH,
+ DEPTH_DECREASE_GAP,
+ DEPTH_INCREASE_GAP,
+ INDENT_PER_DEPTH,
+ OUTLINE_HEADER_HEIGHT,
+ OUTLINE_ROW_HEIGHT,
+ SUB_HEADER_HEIGHT,
+} from './constants'
+import { useCanvasRender } from './useCanvasRender'
+import { useColumnResize } from './useColumnResize'
+import { useOutlineDataFetch } from './useDataFetch'
+import { useOutlineCellRenderer } from './useOutlineCellRenderer'
+import type { OutlineViewRow } from '~/composables/useOutlineViewStore'
+
+export function useCanvasOutline({
+ scrollLeft,
+ scrollTop,
+ width,
+ height,
+ mousePosition,
+}: {
+ scrollLeft: Ref<number>
+ scrollTop: Ref<number>
+ width: Ref<number>
+ height: Ref<number>
+ mousePosition: { x: number; y: number }
+}) {
+ const { getColor } = useTheme()
+ const { $api } = useNuxtApp()
+
+ const { levels, displayLevels, isCollapsed, toggleCollapse, depthToLevelId, collapsedParents, isConfigured, selectedLevelId } =
+ useOutlineViewStoreOrThrow()
+
+ const { meta, view, nestedFilters, sorts } = useSmartsheetStoreOrThrow()
+ const {
+ fields: viewFields,
+ gridViewCols,
+ metaColumnById,
+ showSystemFields,
+ updateGridViewColumn,
+ resizingColOldWith,
+ } = useViewColumnsOrThrow()
+ const { metas, getMeta } = useMetas()
+ const { search, getValidSearchQueryForColumn } = useFieldQuery()
+
+ const baseStore = useBase()
+ const { sqlUis } = storeToRefs(baseStore)
+ const { basesUser } = storeToRefs(useBases())
+
+ const { isDataReadOnly, isUIAllowed } = useRoles()
+ const { isAllowed } = usePermissions()
+ const isPublicView = inject(IsPublicInj, ref(false))
+ const isDataEditAllowed = computed(() => isUIAllowed('dataEdit') && !isPublicView.value)
+ const isAddingEmptyRowAllowed = computed(() => isDataEditAllowed.value && !meta.value?.synced)
+
+ const spriteLoader = new SpriteLoader(() => triggerRefreshCanvas())
+ const canvasCursorRef = ref<CursorType>('')
+ const setCursor: SetCursorType = (cursor) => {
+ canvasCursorRef.value = cursor
+ }
+ const { isRowColouringEnabled, getEvaluatedRowMetaRowColorInfo } = useViewRowColorRender()
+
+ const headerRowHeight = computed(() => OUTLINE_HEADER_HEIGHT)
+
+ const rowHeight = computed(() => {
+ const outlineView = view.value?.view as any
+ const rh = outlineView?.row_height
+ if (rh !== undefined) {
+ const enumVal = [1, 2, 4, 6][rh] ?? 1
+ return rowHeightInPx[`${enumVal}`] ?? OUTLINE_ROW_HEIGHT
+ }
+ return OUTLINE_ROW_HEIGHT
+ })
+
+ const elementMap = ref<OutlineCanvasElement[]>([])
+ const hoverRow = ref<{ rowIndex: number }>({ rowIndex: -1 })
+ const activeCell = ref<OutlineActiveCell | null>(null)
+ const stickyHeaderDepth = ref(0)
+
+ const viewId = computed(() => view.value?.id)
+
+ const cachedRows = ref(new Map<number, OutlineViewRow>())
+ const chunkStates = ref<Array<'loading' | 'loaded' | undefined>>([])
+ const totalRows = ref(0)
+ const levelCounts = ref<Record<string, number>>({})
+
+ function getMetaForDepth(depth: number): TableType | undefined {
+ const level = displayLevels.value[depth]
+ if (!level?.fk_model_id) return undefined
+ const baseId = meta.value?.base_id
+ const metaKey = `${baseId}:${level.fk_model_id}`
+ return metas.value?.[metaKey] as TableType | undefined
+ }
+
+ async function updateOrSaveRow(row: Row, property?: string): Promise<any> {
+ if (!property) return
+
+ const newVal = row.row[property]
+ const oldVal = row.oldRow?.[property]
+ if (newVal === oldVal) return
+
+ const depth = row.row.__nc_depth ?? 0
+ const depthMeta = getMetaForDepth(depth)
+ if (!depthMeta) return
+
+ const rowId = extractPkFromRow(row.row, depthMeta.columns as ColumnType[])
+ if (!rowId) return
+
+ try {
+ const updatedRowData = await $api.dbTableRow.update(
+ NOCO,
+ depthMeta.base_id as string,
+ depthMeta.id as string,
+ encodeURIComponent(rowId),
+ { [property]: newVal ?? null },
+ )
+
+ for (const [idx, cached] of cachedRows.value) {
+ if (cached.__nc_pk === row.row.__nc_pk) {
+ Object.assign(cached, updatedRowData)
+ break
+ }
+ }
+ triggerRefreshCanvas()
+ } catch (e: any) {
+ message.error(e.message || 'Failed to save')
+ }
+ }
+
+ const { renderCell, handleCellClick, handleCellHover, imageLoader, actionManager } = useOutlineCellRenderer({
+ spriteLoader,
+ triggerRefreshCanvas: () => triggerRefreshCanvas(),
+ setCursor,
+ meta: meta as Ref<TableType | undefined>,
+ cachedRows: cachedRows as Ref<Map<number, Row>>,
+ totalRows,
+ chunkStates,
+ updateOrSaveRow,
+ })
+
+ // Collapsed state serialized for API calls
+ const collapsedJson = computed(() => {
+ const cp = collapsedParents.value
+ const hasAny = Object.values(cp).some((arr) => arr.length > 0)
+ return hasAny ? JSON.stringify(cp) : ''
+ })
+
+ const sharedViewPassword = inject(SharedViewPasswordInj, ref(''))
+
+ function buildDraftFilterSortParams() {
+ // For outline view, filters and sorts must be level-scoped (fk_level_id).
+ // If a draft entry lacks fk_level_id, fall back to the currently selected level.
+ const fallbackLevelId = selectedLevelId.value
+
+ // Build search filter from the toolbar search bar.
+ // SearchData.vue uses the selected level's columns for the field picker, so we look up
+ // the column from that level's table meta and scope the filter to selectedLevelId.
+ const searchFilters: any[] = []
+ const searchQuery = search.value.query?.trim()
+ if (searchQuery && search.value.field && fallbackLevelId) {
+ const selectedLevel = levels.value.find((l) => l.id === fallbackLevelId)
+ if (selectedLevel?.fk_model_id) {
+ const baseId = (meta.value as any)?.base_id
+ const levelMeta = metas.value?.[`${baseId}:${selectedLevel.fk_model_id}`] as any
+ const col = levelMeta?.columns?.find((c: ColumnType) => c.id === search.value.field)
+ if (col) {
+ const result = getValidSearchQueryForColumn(col, searchQuery, levelMeta, { getWhereQueryAs: 'object' })
+ if (result && typeof result === 'object' && 'fk_column_id' in result) {
+ searchFilters.push({ ...result, fk_level_id: fallbackLevelId })
+ }
+ }
+ }
+ }
+
+ const filterArrJson = isUIAllowed('filterSync')
+ ? searchFilters.length
+ ? stringifyFilterOrSortArr(searchFilters)
+ : undefined
+ : stringifyFilterOrSortArr([
+ ...(nestedFilters.value ?? [])
+ .filter((f) => !f.id)
+ .map((f) => ((f as any).fk_level_id ? f : { ...f, fk_level_id: fallbackLevelId })),
+ ...searchFilters,
+ ])
+
+ const sortArrJson = isUIAllowed('sortSync')
+ ? undefined
+ : stringifyFilterOrSortArr(
+ (sorts.value ?? [])
+ .filter((s) => !s.id)
+ .map((s) => ((s as any).fk_level_id ? s : { ...s, fk_level_id: fallbackLevelId })),
+ )
+
+ return { filterArrJson, sortArrJson }
+ }
+
+ async function loadPage(params: { offset: number; limit: number; collapsed: string }): Promise<OutlineViewRow[]> {
+ let response: any
+
+ const { filterArrJson, sortArrJson } = buildDraftFilterSortParams()
+
+ if (isPublicView.value) {
+ const sharedViewUuid = view.value?.uuid
+ if (!sharedViewUuid) return []
+
+ const query: Record<string, any> = {
+ limit: params.limit,
+ offset: params.offset,
+ }
+ if (params.collapsed) query.collapsed = params.collapsed
+ if (filterArrJson) query.filterArrJson = filterArrJson
+ if (sortArrJson) query.sortArrJson = sortArrJson
+
+ response = await $api.public.dataList(sharedViewUuid, query, {
+ headers: {
+ 'xc-password': sharedViewPassword.value,
+ },
+ })
+ } else {
+ const workspaceId = (meta.value as any)?.fk_workspace_id
+ const baseId = meta.value?.base_id
+ if (!workspaceId || !baseId || !viewId.value) return []
+
+ const query: Record<string, any> = {
+ operation: 'outlineViewDataList',
+ viewId: viewId.value,
+ limit: params.limit,
+ offset: params.offset,
+ }
+ if (params.collapsed) query.collapsed = params.collapsed
+ if (filterArrJson) query.filterArrJson = filterArrJson
+ if (sortArrJson) query.sortArrJson = sortArrJson
+
+ response = await $api.internal.getOperation(workspaceId, baseId, query)
+ }
+
+ const rows = response.list || response?.data?.list || []
+
+ if (isRowColouringEnabled.value) {
+ for (const row of rows) {
+ const colorInfo = getEvaluatedRowMetaRowColorInfo(row)
+ row.__nc_color = colorInfo
+ }
+ }
+
+ return rows
+ }
+
+ async function loadCount(params: { collapsed: string }): Promise<{ totalRows: number; counts: Record<string, number> }> {
+ const { filterArrJson, sortArrJson } = buildDraftFilterSortParams()
+
+ if (isPublicView.value) {
+ const sharedViewUuid = view.value?.uuid
+ if (!sharedViewUuid) return { totalRows: 0, counts: {} }
+
+ const query: Record<string, any> = {}
+ if (params.collapsed) query.collapsed = params.collapsed
+ if (filterArrJson) query.filterArrJson = filterArrJson
+ if (sortArrJson) query.sortArrJson = sortArrJson
+
+ const response = await $api.public.dbViewRowCount(sharedViewUuid, query, {
+ headers: {
+ 'xc-password': sharedViewPassword.value,
+ },
+ })
+ return {
+ totalRows: +(response.totalRows || 0),
+ counts: (response as any).counts || {},
+ }
+ }
+
+ const workspaceId = (meta.value as any)?.fk_workspace_id
+ const baseId = meta.value?.base_id
+ if (!workspaceId || !baseId || !viewId.value) return { totalRows: 0, counts: {} }
+
+ const query: Record<string, any> = {
+ operation: 'outlineViewDataCount',
+ viewId: viewId.value,
+ }
+ if (params.collapsed) query.collapsed = params.collapsed
+ if (filterArrJson) query.filterArrJson = filterArrJson
+ if (sortArrJson) query.sortArrJson = sortArrJson
+
+ const response = await $api.internal.getOperation(workspaceId, baseId, query)
+ return {
+ totalRows: +(response.totalRows || 0),
+ counts: response.counts || {},
+ }
+ }
+
+ const { fetchCount, updateVisibleRows, resetAndReload } = useOutlineDataFetch({
+ viewId,
+ cachedRows,
+ chunkStates,
+ totalRows,
+ levelCounts,
+ collapsedJson,
+ loadPage,
+ loadCount,
+ triggerRefreshCanvas: () => triggerRefreshCanvas(),
+ })
+
+ const columnsPerLevel = computed<Record<string, CanvasGridColumn[]>>(() => {
+ const result: Record<string, CanvasGridColumn[]> = {}
+
+ for (const level of levels.value) {
+ if (!level.id || !level.fk_model_id) continue
+
+ const baseId = meta.value?.base_id
+ const levelMetaKey = `${baseId}:${level.fk_model_id}`
+ const levelMeta = metas.value?.[levelMetaKey] as TableType | undefined
+
+ const levelFields = (viewFields.value || [])
+ .filter((f: any) => {
+ if (f.fk_level_id !== level.id || !f.show) return false
+ const col = metaColumnById.value?.[f.fk_column_id!]
+ if (!col) return false
+ // Hide system columns unless showSystemFields is on (keep PV)
+ if (!showSystemFields.value && isSystemColumn(col) && !col.pv) return false
+ return true
+ })
+ .sort((a: any, b: any) => (a.order ?? 0) - (b.order ?? 0))
+
+ const cols: CanvasGridColumn[] = []
+
+ const levelBaseUsers = baseId ? basesUser.value.get(baseId) || [] : []
+
+ for (const f of levelFields) {
+ const col = metaColumnById.value[f.fk_column_id!] as ColumnType
+ if (!col) continue
+
+ const viewCol = gridViewCols.value[f.fk_column_id] as GridColumnType | undefined
+
+ let relatedColObj: ColumnType | undefined
+ let relatedTableMeta: any
+
+ if ([UITypes.Lookup, UITypes.Rollup].includes(col.uidt as UITypes)) {
+ const lookupMetaKey = `${baseId}:${col.fk_model_id!}`
+ relatedColObj = metas.value?.[lookupMetaKey]?.columns?.find(
+ (c: ColumnType) => c.id === (col as any)?.colOptions?.fk_relation_column_id,
+ ) as ColumnType
+
+ if (relatedColObj && (relatedColObj as any).colOptions?.fk_related_model_id) {
+ const relatedBaseId = ((relatedColObj as any).colOptions as any)?.fk_related_base_id || baseId
+ const relatedMetaKey = `${relatedBaseId}:${(relatedColObj as any).colOptions.fk_related_model_id}`
+ relatedTableMeta = metas.value?.[relatedMetaKey]
+ }
+ } else if (isLTAR(col.uidt as UITypes, (col as any).colOptions)) {
+ const colOptions = (col as any).colOptions as LinkToAnotherRecordType
+ if (colOptions?.fk_related_model_id) {
+ const relatedBaseId = (colOptions as any)?.fk_related_base_id || baseId
+ const ltarMetaKey = `${relatedBaseId}:${colOptions.fk_related_model_id}`
+ relatedTableMeta = metas.value?.[ltarMetaKey]
+ }
+ }
+
+ col.extra = {}
+
+ if ([UITypes.SingleSelect, UITypes.MultiSelect].includes(col.uidt as UITypes)) {
+ col.extra = getSingleMultiselectColOptions(col)
+ } else if ([UITypes.User, UITypes.CreatedBy, UITypes.LastModifiedBy].includes(col.uidt as UITypes)) {
+ col.extra = getUserColOptions(col, levelBaseUsers)
+ }
+
+ if ([UITypes.LastModifiedTime, UITypes.CreatedTime, UITypes.DateTime].includes(col.uidt as UITypes)) {
+ const colMeta = parseProp(col.meta)
+ col.extra.timezone = isEeUI ? getTimeZoneFromName(colMeta?.timezone) : undefined
+ col.extra.isDisplayTimezone = isEeUI ? colMeta?.isDisplayTimezone : undefined
+ }
+
+ if ([UITypes.Formula].includes(col.uidt as UITypes)) {
+ const referencedColumn = (col.colOptions as FormulaType)?.parsed_tree?.referencedColumn
+ const displayType = (col.meta as any)?.display_type ?? referencedColumn?.uidt
+ const levelMeta = metas.value?.[`${baseId}:${col.fk_model_id!}`]
+ const displayColumnConfig = (col.meta as any)?.display_type
+ ? ((col.meta as any)?.display_column_meta as any)
+ : referencedColumn
+ ? levelMeta?.columns?.find((c: ColumnType) => c.id === referencedColumn.id)
+ : undefined
+
+ if ([UITypes.DateTime].includes(displayType) && displayColumnConfig?.meta) {
+ const displayColumnConfigMeta = displayColumnConfig.meta
+ displayColumnConfig.extra = {
+ timezone:
+ isEeUI && displayColumnConfigMeta.isDisplayTimezone
+ ? getTimeZoneFromName(displayColumnConfigMeta.timezone)
+ : undefined,
+ isDisplayTimezone: isEeUI ? displayColumnConfigMeta.isDisplayTimezone : undefined,
+ }
+ }
+ col.extra.display_type = displayType
+ col.extra.display_column_meta = displayColumnConfig
+ }
+
+ const sqlUi = sqlUis.value[col.source_id!] ?? Object.values(sqlUis.value)[0]
+
+ const isCellEditable =
+ showReadonlyColumnTooltip(col) ||
+ !showEditRestrictedColumnTooltip(col) ||
+ isAllowed(PermissionEntity.FIELD, col.id, PermissionKey.RECORD_FIELD_EDIT)
+
+ const isSyncedCol = !!(levelMeta?.synced && col.readonly)
+
+ const isReadonly =
+ col.readonly || isDataReadOnly.value || !isDataEditAllowed.value || isPublicView.value || !isCellEditable || isSyncedCol
+
+ cols.push({
+ id: col.id!,
+ grid_column_id: viewCol?.id ?? col.id!,
+ title: col.title!,
+ uidt: col.uidt as any,
+ width: viewCol?.width ?? '180px',
+ fixed: false,
+ pv: !!col.pv,
+ virtual: isVirtualCol(col),
+ readonly: isReadonly,
+ isCellEditable,
+ isSyncedColumn: isSyncedCol,
+ columnObj: col as ColumnType & { extra?: any },
+ relatedColObj,
+ relatedTableMeta,
+ aggregation: '',
+ agg_fn: '',
+ agg_prefix: '',
+ abstractType: sqlUi?.getAbstractType(col) ?? null,
+ })
+ }
+
+ result[level.id] = cols
+ }
+
+ return result
+ })
+
+ watch(
+ columnsPerLevel,
+ async (levels) => {
+ const baseId = meta.value?.base_id
+ if (!baseId) return
+
+ for (const cols of Object.values(levels)) {
+ for (const col of cols) {
+ const columnObj = col.columnObj
+ if (isLTAR(columnObj.uidt as UITypes, (columnObj as any).colOptions)) {
+ const colOptions = (columnObj as any).colOptions as LinkToAnotherRecordType
+ if (colOptions?.fk_related_model_id) {
+ const relatedBaseId = (colOptions as any)?.fk_related_base_id || baseId
+ const metaKey = `${relatedBaseId}:${colOptions.fk_related_model_id}`
+ if (!metas.value?.[metaKey]) {
+ await getMeta(colOptions.fk_related_model_id, false, false, relatedBaseId)
+ }
+ }
+ } else if ([UITypes.Lookup, UITypes.Rollup].includes(columnObj.uidt as UITypes)) {
+ const lookupMetaKey = `${baseId}:${columnObj.fk_model_id!}`
+ const relatedColObj = metas.value?.[lookupMetaKey]?.columns?.find(
+ (c: ColumnType) => c.id === (columnObj as any)?.colOptions?.fk_relation_column_id,
+ )
+ if (relatedColObj && (relatedColObj as any).colOptions?.fk_related_model_id) {
+ const relatedBaseId = ((relatedColObj as any).colOptions as any)?.fk_related_base_id || baseId
+ const metaKey = `${relatedBaseId}:${(relatedColObj as any).colOptions.fk_related_model_id}`
+ if (!metas.value?.[metaKey]) {
+ await getMeta((relatedColObj as any).colOptions.fk_related_model_id, false, false, relatedBaseId)
+ }
+ }
+ }
+ }
+ }
+ },
+ { immediate: true },
+ )
+
+ const rootColumns = computed<CanvasGridColumn[]>(() => {
+ const rootLevel = displayLevels.value[0]
+ if (!rootLevel?.id) return []
+ return columnsPerLevel.value[rootLevel.id] ?? []
+ })
+
+ function getColumnsForDepth(depth: number): CanvasGridColumn[] {
+ const levelId = depthToLevelId.value[depth]
+ if (!levelId) return []
+ return columnsPerLevel.value[levelId] ?? []
+ }
+
+ const levelOrder = computed(() => displayLevels.value.map((l) => l.fk_model_id!))
+
+ const scrollMetrics = computed(() => {
+ const N = displayLevels.value.length
+ if (N === 0 || totalRows.value === 0) {
+ return { subHeaderCount: 0, rowCount: 0, addRowCount: 0, groups: [] as number[], scrollableHeight: 0 }
+ }
+
+ const cts = levelCounts.value
+ const order = levelOrder.value
+
+ const groups = new Array(N).fill(0)
+ groups[0] = 1
+ for (let d = 1; d < N; d++) {
+ groups[d] = cts[order[d - 1]] || 0
+ }
+
+ const rowCount = totalRows.value
+
+ // The render loop draws sub-headers in TWO places:
+ // 1. Depth increase (non-first): entering a child group β€” one per non-root group
+ // 2. Depth decrease: re-rendering column headers after closing children
+ //
+ // Add-rows are drawn for each closed level on depth decrease + trailing.
+ // The root level (d=0) never gets an add-row (trailing loop uses d >= 1).
+ //
+ // Count of each transition type:
+ const depthIncreaseCount = groups.slice(1).reduce((s: number, g: number) => s + g, 0)
+ const depthDecreaseCount = Math.max(0, groups[N - 1] - 1)
+
+ // Sub-headers: one per depth-increase + one per depth-decrease
+ const subHeaderCount = depthIncreaseCount + depthDecreaseCount
+
+ // Add-rows: exclude root group (root never gets an add-row)
+ const addRowCount = isAddingEmptyRowAllowed.value ? groups.reduce((s: number, g: number) => s + g, 0) - 1 : 0
+
+ // Gaps before sub-headers at depth boundaries
+ const transitionGapHeight = depthIncreaseCount * DEPTH_INCREASE_GAP + depthDecreaseCount * DEPTH_DECREASE_GAP
+
+ const scrollableHeight =
+ subHeaderCount * SUB_HEADER_HEIGHT +
+ rowCount * rowHeight.value +
+ addRowCount * ADD_ROW_HEIGHT +
+ transitionGapHeight +
+ BOTTOM_PADDING
+
+ return { subHeaderCount, rowCount, addRowCount, groups, scrollableHeight }
+ })
+
+ const totalHeight = computed(() => {
+ if (totalRows.value === 0) return headerRowHeight.value
+ return headerRowHeight.value + scrollMetrics.value.scrollableHeight
+ })
+
+ const slotHeight = computed(() => {
+ if (totalRows.value === 0) return rowHeight.value
+ return scrollMetrics.value.scrollableHeight / totalRows.value
+ })
+
+ const totalWidth = computed(() => {
+ let maxWidth = width.value
+ const maxDepth = displayLevels.value.length
+ for (let d = 0; d < maxDepth; d++) {
+ const cols = getColumnsForDepth(d)
+ const indent = CHEVRON_COL_WIDTH + d * INDENT_PER_DEPTH
+ const colsWidth = indent + cols.reduce((sum, c) => sum + parseCellWidth(c.width), 0)
+ maxWidth = Math.max(maxWidth, colsWidth)
+ }
+ return maxWidth
+ })
+
+ const rowSlice = computed(() => {
+ if (totalRows.value === 0) return { start: 0, end: 0 }
+
+ const sh = slotHeight.value
+ const hh = headerRowHeight.value
+ const buffer = 3
+
+ const adjustedScroll = Math.max(0, scrollTop.value - hh)
+ const start = Math.max(0, Math.floor(adjustedScroll / sh) - buffer)
+ const end = Math.min(totalRows.value, Math.ceil((adjustedScroll + height.value) / sh) + buffer)
+
+ return { start, end }
+ })
+
+ const { canvasRef, renderCanvas } = useCanvasRender({
+ width,
+ height,
+ scrollLeft,
+ scrollTop,
+ headerRowHeight,
+ rowHeight,
+ cachedRows,
+ rowSlice,
+ slotHeight,
+ totalRows,
+ hoverRow,
+ mousePosition,
+ elementMap,
+ isCollapsed,
+ displayLevels,
+ getColumnsForDepth,
+ getColor,
+ meta,
+ renderCell,
+ stickyHeaderDepth,
+ isAddingEmptyRowAllowed,
+ })
+
+ let rafId: number | null = null
+ function triggerRefreshCanvas() {
+ if (rafId) cancelAnimationFrame(rafId)
+ rafId = requestAnimationFrame(() => {
+ renderCanvas()
+ rafId = null
+ })
+ }
+
+ watch([scrollTop, scrollLeft, width, height, rowHeight, () => totalRows.value, columnsPerLevel], () => triggerRefreshCanvas())
+
+ watch(rowSlice, (slice) => updateVisibleRows(slice))
+ watch(collapsedJson, () => resetAndReload())
+
+ function findElementAt(x: number, y: number, type?: OutlineCanvasElement['type']): OutlineCanvasElement | null {
+ for (let i = elementMap.value.length - 1; i >= 0; i--) {
+ const el = elementMap.value[i]
+ if (type && el.type !== type) continue
+ if (x >= el.x && x <= el.x + el.width && y >= el.y && y <= el.y + el.height) {
+ return el
+ }
+ }
+ return null
+ }
+
+ function resolveHeaderAt(x: number, y: number): { columns: CanvasGridColumn[]; startX: number } | null {
+ // Sticky header: shows columns for the depth of the first visible row
+ if (y >= 0 && y < headerRowHeight.value) {
+ const d = stickyHeaderDepth.value
+ const cols = getColumnsForDepth(d)
+ const indent = CHEVRON_COL_WIDTH + d * INDENT_PER_DEPTH
+ return {
+ columns: cols,
+ startX: indent - scrollLeft.value,
+ }
+ }
+
+ // Sub-headers: check elementMap for 'header' type
+ const headerEl = findElementAt(x, y, 'header')
+ if (headerEl) {
+ const cols = getColumnsForDepth(headerEl.depth)
+ const indent = CHEVRON_COL_WIDTH + headerEl.depth * INDENT_PER_DEPTH
+ return {
+ columns: cols,
+ startX: indent - scrollLeft.value,
+ }
+ }
+
+ return null
+ }
+
+ const {
+ isResizing,
+ startResize,
+ updateCursor: getResizeCursor,
+ } = useColumnResize(
+ canvasRef,
+ triggerRefreshCanvas,
+ resolveHeaderAt,
+ // onResize: live local update during drag
+ (columnId: string, newWidth: number) => {
+ const widthStr = `${Math.round(newWidth)}px`
+ if (gridViewCols.value[columnId]) {
+ gridViewCols.value[columnId].width = widthStr
+ }
+ triggerRefreshCanvas()
+ },
+ // onResizeEnd: persist to server
+ (columnId: string, newWidth: number) => {
+ const widthStr = `${Math.round(newWidth)}px`
+ if (gridViewCols.value[columnId]) {
+ resizingColOldWith.value = gridViewCols.value[columnId].width || '180px'
+ gridViewCols.value[columnId].width = widthStr
+ }
+ updateGridViewColumn(columnId, { width: widthStr })
+ },
+ )
+
+ function handleCanvasMouseDown(e: MouseEvent) {
+ if (startResize(e)) return
+ }
+
+ const expandRowHook = createEventHook<{ row: OutlineViewRow; depth: number }>()
+ const addRowHook = createEventHook<{ depth: number; parentPk?: string | number }>()
+
+ async function handleCanvasClick(e: MouseEvent) {
+ if (isResizing.value) return
+
+ const rect = canvasRef.value?.getBoundingClientRect()
+ if (!rect) return
+
+ const x = e.clientX - rect.left
+ const y = e.clientY - rect.top
+
+ const expandEl = findElementAt(x, y, 'expandRow')
+ if (expandEl) {
+ const row = cachedRows.value.get(expandEl.rowIndex)
+ if (row) {
+ expandRowHook.trigger({ row, depth: expandEl.depth })
+ }
+ return
+ }
+
+ const cellEl = findElementAt(x, y, 'cell')
+ if (cellEl && cellEl.columnId) {
+ const row = cachedRows.value.get(cellEl.rowIndex)
+ if (row) {
+ const cols = getColumnsForDepth(cellEl.depth)
+ const col = cols.find((c) => c.id === cellEl.columnId)
+ if (col) {
+ const rowObj: Row = { row: { ...row }, oldRow: { ...row }, rowMeta: { rowIndex: cellEl.rowIndex } }
+ const cellPosition = { x: cellEl.x, y: cellEl.y, width: cellEl.width, height: cellEl.height }
+ const handled = await handleCellClick({
+ event: e,
+ row: rowObj,
+ column: col,
+ value: row[col.title],
+ mousePosition: { x, y },
+ pk: row.__nc_pk,
+ selected: false,
+ imageLoader,
+ path: [],
+ cellPosition,
+ })
+
+ if (handled) {
+ const cached = cachedRows.value.get(cellEl.rowIndex)
+ if (cached) {
+ Object.assign(cached, rowObj.row)
+ }
+ triggerRefreshCanvas()
+ return
+ }
+
+ const canvasOnlyTypes = [UITypes.Checkbox, UITypes.Rating, UITypes.Button]
+ if (canvasOnlyTypes.includes(col.columnObj.uidt as UITypes)) {
+ return
+ }
+
+ activeCell.value = {
+ rowIndex: cellEl.rowIndex,
+ depth: cellEl.depth,
+ column: col,
+ row: { ...row },
+ x: cellEl.x,
+ y: cellEl.y,
+ width: cellEl.width,
+ height: cellEl.height,
+ }
+ return
+ }
+ }
+ }
+
+ const addRowEl = findElementAt(x, y, 'addRow')
+ if (addRowEl) {
+ addRowHook.trigger({ depth: addRowEl.depth, parentPk: addRowEl.parentPk })
+ return
+ }
+
+ activeCell.value = null
+
+ const chevron = findElementAt(x, y, 'chevron')
+ if (chevron && chevron.pk !== undefined) {
+ toggleCollapse(chevron.depth, String(chevron.pk))
+ }
+ }
+
+ function handleCanvasMouseMove(e: MouseEvent) {
+ const rect = canvasRef.value?.getBoundingClientRect()
+ if (!rect) return
+
+ const x = e.clientX - rect.left
+ const y = e.clientY - rect.top
+
+ mousePosition.x = x
+ mousePosition.y = y
+
+ canvasCursorRef.value = ''
+
+ if (canvasRef.value) {
+ const resizeCursor = getResizeCursor(x, y)
+ if (resizeCursor) {
+ canvasRef.value.style.cursor = resizeCursor
+ } else {
+ const expandEl = findElementAt(x, y, 'expandRow')
+ const chevronEl = findElementAt(x, y, 'chevron')
+ const addRowEl = findElementAt(x, y, 'addRow')
+
+ if (expandEl || chevronEl || addRowEl) {
+ canvasRef.value.style.cursor = 'pointer'
+ } else {
+ const cellEl = findElementAt(x, y, 'cell')
+ if (cellEl?.columnId) {
+ const row = cachedRows.value.get(cellEl.rowIndex)
+ if (row) {
+ const cols = getColumnsForDepth(cellEl.depth)
+ const col = cols.find((c) => c.id === cellEl.columnId)
+ if (col) {
+ handleCellHover({
+ event: e,
+ row: { row: { ...row }, oldRow: { ...row }, rowMeta: {} },
+ column: col,
+ value: row[col.title],
+ mousePosition: { x, y },
+ pk: row.__nc_pk,
+ selected: false,
+ imageLoader,
+ })
+ }
+ }
+ }
+ canvasRef.value.style.cursor = canvasCursorRef.value || ''
+ }
+ }
+ }
+
+ const rowEl = findElementAt(x, y, 'row')
+ const newHoverIndex = rowEl?.rowIndex ?? -1
+
+ const inHeader = y < headerRowHeight.value || findElementAt(x, y, 'header')
+ if (inHeader) {
+ triggerRefreshCanvas()
+ } else if (newHoverIndex >= 0) {
+ if (hoverRow.value.rowIndex !== newHoverIndex) {
+ hoverRow.value = { rowIndex: newHoverIndex }
+ }
+ triggerRefreshCanvas()
+ } else if (hoverRow.value.rowIndex !== newHoverIndex) {
+ hoverRow.value = { rowIndex: newHoverIndex }
+ triggerRefreshCanvas()
+ }
+ }
+
+ function handleCanvasMouseLeave() {
+ mousePosition.x = -1
+ mousePosition.y = -1
+ if (hoverRow.value.rowIndex !== -1) {
+ hoverRow.value = { rowIndex: -1 }
+ }
+ triggerRefreshCanvas()
+ }
+
+ async function loadInitialData() {
+ if (!isConfigured.value || !viewId.value) return
+
+ await fetchCount()
+ if (totalRows.value > 0) {
+ updateVisibleRows({ start: 0, end: Math.ceil(height.value / rowHeight.value) + 5 })
+ }
+ nextTick(() => triggerRefreshCanvas())
+ }
+
+ onMounted(async () => {
+ // Wait for levels + viewId to be available (view meta may load async)
+ await waitForCondition(() => isConfigured.value && !!viewId.value, 100)
+ // Wait a tick for the v-else template branch to render the canvas element
+ await nextTick()
+ await loadInitialData()
+ })
+
+ watch(
+ () => levels.value.length,
+ () => {
+ if (isConfigured.value && viewId.value) {
+ resetAndReload()
+ }
+ },
+ )
+
+ onBeforeUnmount(() => {
+ if (rafId) cancelAnimationFrame(rafId)
+ })
+
+ return {
+ canvasRef,
+ triggerRefreshCanvas,
+ resetAndReload,
+ totalHeight,
+ totalWidth,
+ handleCanvasMouseDown,
+ handleCanvasClick,
+ handleCanvasMouseMove,
+ handleCanvasMouseLeave,
+ onExpandRow: expandRowHook.on,
+ onAddRow: addRowHook.on,
+ activeCell,
+ cachedRows,
+ }
+}
diff --git a/packages/nc-gui/components/smartsheet/outline/composables/useCanvasRender.ts b/packages/nc-gui/components/smartsheet/outline/composables/useCanvasRender.ts
new file mode 100644
index 0000000000..9cc4bdf24d
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/outline/composables/useCanvasRender.ts
@@ -0,0 +1,695 @@
+import type { ColumnType, OutlineViewLevelType, TableType } from 'nocodb-sdk'
+import { parseCellWidth } from '../../grid/canvas/utils/cell'
+import { getSafe2DContext } from '../../grid/canvas/utils/safeCanvas'
+import type { OutlineCanvasElement } from './types'
+import {
+ ADD_ROW_HEIGHT,
+ CELL_PADDING,
+ CHEVRON_COL_WIDTH,
+ CHEVRON_SIZE,
+ DEPTH_DECREASE_GAP,
+ DEPTH_INCREASE_GAP,
+ INDENT_PER_DEPTH,
+ SUB_HEADER_HEIGHT,
+} from './constants'
+import type { OutlineViewRow } from '~/composables/useOutlineViewStore'
+
+type GetColorFn = (cssVar: string, darkCssVar?: string, opacity?: number) => string
+
+type RenderCellFn = (
+ ctx: CanvasRenderingContext2D,
+ column: ColumnType,
+ options: {
+ value: any
+ row?: Record<string, any>
+ x: number
+ y: number
+ width: number
+ height: number
+ pv?: boolean
+ padding?: number
+ pk?: any
+ mousePosition?: { x: number; y: number }
+ meta?: any
+ isRowHovered?: boolean
+ relatedColObj?: any
+ relatedTableMeta?: any
+ readonly?: boolean
+ },
+) => void
+
+export function useCanvasRender({
+ width,
+ height,
+ scrollLeft,
+ scrollTop,
+ headerRowHeight,
+ rowHeight,
+ cachedRows,
+ rowSlice,
+ slotHeight,
+ totalRows,
+ hoverRow,
+ mousePosition,
+ elementMap,
+ isCollapsed,
+ displayLevels,
+ getColumnsForDepth,
+ getColor,
+ meta,
+ renderCell,
+ stickyHeaderDepth,
+ isAddingEmptyRowAllowed,
+}: {
+ width: Ref<number>
+ height: Ref<number>
+ scrollLeft: Ref<number>
+ scrollTop: Ref<number>
+ headerRowHeight: ComputedRef<number>
+ rowHeight: ComputedRef<number>
+ cachedRows: Ref<Map<number, OutlineViewRow>>
+ rowSlice: ComputedRef<{ start: number; end: number }>
+ slotHeight: ComputedRef<number>
+ totalRows: Ref<number>
+ hoverRow: Ref<{ rowIndex: number }>
+ mousePosition: { x: number; y: number }
+ elementMap: Ref<OutlineCanvasElement[]>
+ isCollapsed: (depth: number, pk: string) => boolean
+ displayLevels: ComputedRef<OutlineViewLevelType[]>
+ getColumnsForDepth: (depth: number) => CanvasGridColumn[]
+ getColor: GetColorFn
+ meta: Ref<TableType | undefined>
+ renderCell: RenderCellFn
+ stickyHeaderDepth: Ref<number>
+ isAddingEmptyRowAllowed: ComputedRef<boolean>
+}) {
+ const canvasRef = ref<HTMLCanvasElement>()
+
+ function getColors() {
+ return {
+ bg: getColor(themeV4Colors.base.white),
+ rowBg: getColor(themeV4Colors.base.white),
+ rowHoverBg: getColor(themeV4Colors.gray['50']),
+ borderColor: getColor(themeV4Colors.gray['200']),
+ borderLight: getColor(themeV4Colors.gray['100']),
+ chevronColor: getColor(themeV4Colors.gray['500']),
+ headerBg: getColor(themeV4Colors.base.white),
+ headerText: getColor(themeV4Colors.gray['500']),
+ subHeaderBg: getColor(themeV4Colors.base.white),
+ subHeaderText: getColor(themeV4Colors.gray['500']),
+ addRowBg: getColor(themeV4Colors.base.white),
+ addRowText: getColor(themeV4Colors.gray['400']),
+ }
+ }
+
+ function renderCanvas() {
+ const canvas = canvasRef.value
+ if (!canvas) return
+
+ const ctx = getSafe2DContext(canvas)
+ if (!ctx) return
+
+ const dpr = window.devicePixelRatio || 1
+ canvas.width = width.value * dpr
+ canvas.height = height.value * dpr
+ canvas.style.width = `${width.value}px`
+ ctx.scale(dpr, dpr)
+
+ const colors = getColors()
+
+ ctx.clearRect(0, 0, width.value, canvas.height)
+ ctx.fillStyle = colors.bg
+ ctx.fillRect(0, 0, width.value, canvas.height)
+
+ elementMap.value = []
+
+ const { start, end } = rowSlice.value
+ const rows = cachedRows.value
+ const sh = slotHeight.value
+
+ const hh = headerRowHeight.value
+
+ // Content starts after the sticky header
+ let y = hh + start * sh // estimated start Y in content coords
+
+ // Track the depth shown by the most recent sub-header that's
+ // at or above the viewport top, so we can render a sticky header.
+ let stickyDepth = 0
+ let stickyFound = false
+
+ // Track last parent PK per depth (for addRow context)
+ const lastPkAtDepth: Record<number, string | number> = {}
+
+ for (let i = start; i < end && i < totalRows.value; i++) {
+ const row = rows.get(i)
+ if (!row) {
+ y += rowHeight.value
+ continue
+ }
+
+ const depth = row.__nc_depth ?? 0
+
+ // Check previous row for depth transitions
+ const prevRow = i > 0 ? rows.get(i - 1) : undefined
+ const prevDepth = prevRow ? prevRow.__nc_depth ?? 0 : i === 0 ? -1 : undefined
+
+ if (prevDepth !== undefined) {
+ if (depth > prevDepth) {
+ // The very first group's header is covered by the sticky header β€” skip it
+ const isFirstGroup = prevDepth === -1
+
+ if (!isFirstGroup) {
+ // Add gap before sub-header
+ if (prevDepth >= 0) {
+ y += DEPTH_INCREASE_GAP
+ }
+ // Entering a new group: draw sub-header
+ const subHeaderScreenY = y - scrollTop.value
+ if (subHeaderScreenY + SUB_HEADER_HEIGHT > hh && subHeaderScreenY < height.value) {
+ renderSubHeader(ctx, depth, subHeaderScreenY, colors)
+ }
+ // Track for sticky: if this sub-header is at or above the header bottom
+ if (subHeaderScreenY <= hh) {
+ stickyDepth = depth
+ stickyFound = true
+ } else if (!stickyFound) {
+ stickyDepth = depth
+ stickyFound = true
+ }
+ y += SUB_HEADER_HEIGHT
+ } else {
+ // First group: sticky header covers it, just track depth
+ stickyDepth = depth
+ stickyFound = true
+ }
+ } else if (depth < prevDepth) {
+ // Closing groups: draw add-row for each closed depth
+ if (isAddingEmptyRowAllowed.value) {
+ for (let d = prevDepth; d > depth; d--) {
+ const addRowScreenY = y - scrollTop.value
+ if (addRowScreenY + ADD_ROW_HEIGHT > hh && addRowScreenY < height.value) {
+ renderAddRow(ctx, d, addRowScreenY, colors, lastPkAtDepth[d - 1])
+ }
+ y += ADD_ROW_HEIGHT
+ }
+ }
+
+ // Re-render sub-header for the current depth
+ // so column names are visible again after expanded children
+ y += DEPTH_DECREASE_GAP
+ const subHeaderScreenY = y - scrollTop.value
+ if (subHeaderScreenY + SUB_HEADER_HEIGHT > hh && subHeaderScreenY < height.value) {
+ renderSubHeader(ctx, depth, subHeaderScreenY, colors)
+ }
+ if (subHeaderScreenY <= hh) {
+ stickyDepth = depth
+ stickyFound = true
+ }
+ y += SUB_HEADER_HEIGHT
+ }
+ }
+
+ // Render the data row
+ const screenY = y - scrollTop.value
+ if (screenY + rowHeight.value > hh && screenY < height.value) {
+ renderRow(ctx, row, i, screenY, depth, colors)
+ }
+
+ // Track PK at this depth for addRow parent context
+ lastPkAtDepth[depth] = row.__nc_pk
+
+ // If no sub-header found yet, use this row's depth for the sticky
+ if (!stickyFound) {
+ stickyDepth = depth
+ stickyFound = true
+ }
+
+ y += rowHeight.value
+ }
+
+ // After the last rendered row, insert trailing add-rows for open depths
+ const lastRow = rows.get(end - 1)
+ if (lastRow && end >= totalRows.value && isAddingEmptyRowAllowed.value) {
+ const lastDepth = lastRow.__nc_depth ?? 0
+ for (let d = lastDepth; d >= 1; d--) {
+ const addRowScreenY = y - scrollTop.value
+ if (addRowScreenY + ADD_ROW_HEIGHT > hh && addRowScreenY < height.value) {
+ renderAddRow(ctx, d, addRowScreenY, colors, lastPkAtDepth[d - 1])
+ }
+ y += ADD_ROW_HEIGHT
+ }
+ }
+
+ // Sticky header (drawn last to overlay β€” shows columns for the depth
+ // of the sub-header that has scrolled past the viewport top)
+ stickyHeaderDepth.value = stickyDepth
+ renderHeader(ctx, stickyDepth, colors)
+ }
+
+ function renderHeader(ctx: CanvasRenderingContext2D, depth: number, colors: ReturnType<typeof getColors>) {
+ const hh = headerRowHeight.value
+ const cols = getColumnsForDepth(depth)
+ const indent = CHEVRON_COL_WIDTH + depth * INDENT_PER_DEPTH
+
+ // Background β€” shadow only when scrolled
+ if (scrollTop.value > 0) {
+ ctx.save()
+ ctx.shadowColor = 'rgba(0, 0, 0, 0.12)'
+ ctx.shadowBlur = 8
+ ctx.shadowOffsetX = 0
+ ctx.shadowOffsetY = 4
+ ctx.fillStyle = colors.headerBg
+ ctx.fillRect(0, -2, width.value, hh + 2)
+ ctx.restore()
+ } else {
+ ctx.fillStyle = colors.headerBg
+ ctx.fillRect(0, 0, width.value, hh)
+ }
+
+ if (cols.length === 0) return
+
+ let x = indent - scrollLeft.value
+ const isHeaderHovered = mousePosition.y >= 0 && mousePosition.y < hh
+
+ ctx.font = '700 11px Inter'
+ ctx.textBaseline = 'middle'
+
+ for (let ci = 0; ci < cols.length; ci++) {
+ const col = cols[ci]
+ const w = parseCellWidth(col.width)
+
+ ctx.fillStyle = colors.headerText
+ const text = truncateText(ctx, col.title, w - CELL_PADDING * 2)
+ ctx.fillText(text, x + CELL_PADDING, hh / 2)
+
+ // Pill divider between columns (including after the last)
+ if (isHeaderHovered) {
+ const pillX = x + w
+ renderHeaderPill(ctx, pillX, 0, hh)
+ }
+
+ x += w
+ }
+ }
+
+ function renderSubHeader(ctx: CanvasRenderingContext2D, depth: number, screenY: number, colors: ReturnType<typeof getColors>) {
+ const cols = getColumnsForDepth(depth)
+ if (cols.length === 0) return
+
+ const indent = CHEVRON_COL_WIDTH + depth * INDENT_PER_DEPTH
+
+ // Track sub-header in element map for hit-testing (resize, etc.)
+ elementMap.value.push({
+ type: 'header',
+ rowIndex: -1,
+ x: 0,
+ y: screenY,
+ width: width.value,
+ height: SUB_HEADER_HEIGHT,
+ depth,
+ })
+
+ ctx.fillStyle = colors.subHeaderBg
+ ctx.fillRect(0, screenY, width.value, SUB_HEADER_HEIGHT)
+
+ const borderStartX = indent - scrollLeft.value
+
+ ctx.strokeStyle = colors.borderLight
+ ctx.lineWidth = 0.5
+ ctx.beginPath()
+ ctx.moveTo(borderStartX, screenY + SUB_HEADER_HEIGHT - 0.5)
+ ctx.lineTo(width.value, screenY + SUB_HEADER_HEIGHT - 0.5)
+ ctx.stroke()
+
+ let x = borderStartX
+ const isSubHeaderHovered = mousePosition.y >= screenY && mousePosition.y < screenY + SUB_HEADER_HEIGHT
+
+ ctx.font = '700 10px Inter'
+ ctx.textBaseline = 'middle'
+
+ for (let ci = 0; ci < cols.length; ci++) {
+ const col = cols[ci]
+ const w = parseCellWidth(col.width)
+
+ ctx.fillStyle = colors.subHeaderText
+ const text = truncateText(ctx, col.title, w - CELL_PADDING * 2)
+ ctx.fillText(text, x + CELL_PADDING, screenY + SUB_HEADER_HEIGHT / 2)
+
+ // Pill divider between columns (including after the last)
+ if (isSubHeaderHovered) {
+ const pillX = x + w
+ renderHeaderPill(ctx, pillX, screenY, SUB_HEADER_HEIGHT)
+ }
+
+ x += w
+ }
+ }
+
+ function renderAddRow(
+ ctx: CanvasRenderingContext2D,
+ depth: number,
+ screenY: number,
+ colors: ReturnType<typeof getColors>,
+ parentPk?: string | number,
+ ) {
+ const rh = ADD_ROW_HEIGHT
+ const indent = CHEVRON_COL_WIDTH + depth * INDENT_PER_DEPTH
+
+ const isAddRowHovered = mousePosition.y >= screenY && mousePosition.y < screenY + rh
+
+ ctx.fillStyle = isAddRowHovered ? getColor(themeV4Colors.gray['50']) : colors.addRowBg
+ ctx.fillRect(0, screenY, width.value, rh)
+
+ const borderStartX = indent - scrollLeft.value
+ ctx.strokeStyle = colors.borderLight
+ ctx.lineWidth = 0.5
+ ctx.beginPath()
+ ctx.moveTo(borderStartX, screenY + rh - 0.5)
+ ctx.lineTo(width.value, screenY + rh - 0.5)
+ ctx.stroke()
+
+ const x = borderStartX + CELL_PADDING
+ ctx.font = '400 12px Inter'
+ ctx.textBaseline = 'middle'
+ ctx.fillStyle = isAddRowHovered ? getColor(themeV4Colors.gray['600']) : colors.addRowText
+ ctx.fillText('+ New record', x, screenY + rh / 2)
+
+ elementMap.value.push({
+ type: 'addRow',
+ rowIndex: -1,
+ x: 0,
+ y: screenY,
+ width: width.value,
+ height: rh,
+ depth,
+ parentPk,
+ })
+ }
+
+ function renderRow(
+ ctx: CanvasRenderingContext2D,
+ row: OutlineViewRow,
+ rowIndex: number,
+ screenY: number,
+ depth: number,
+ colors: ReturnType<typeof getColors>,
+ ) {
+ const rh = rowHeight.value
+ const isHovered = hoverRow.value.rowIndex === rowIndex
+ const maxDepth = displayLevels.value.length - 1
+ const isParent = depth < maxDepth
+ const collapsed = isCollapsed(depth, String(row.__nc_pk))
+ const indent = CHEVRON_COL_WIDTH + depth * INDENT_PER_DEPTH
+
+ // Row coloring
+ const colorInfo = row.__nc_color as
+ | {
+ rowBgColor?: string
+ rowHoverColor?: string
+ rowLeftBorderColor?: string
+ rowBorderColor?: string
+ is_set_as_background?: boolean
+ }
+ | undefined
+
+ const rowColor = colorInfo
+ ? colorInfo.is_set_as_background && isHovered
+ ? colorInfo.rowHoverColor
+ : colorInfo.rowBgColor
+ : null
+
+ // Row background
+ ctx.fillStyle = rowColor || (isHovered ? colors.rowHoverBg : colors.rowBg)
+ ctx.fillRect(0, screenY, width.value, rh)
+
+ // Row bottom border (starts from indent)
+ const borderStartX = indent - scrollLeft.value
+ ctx.strokeStyle = rowColor ? colorInfo?.rowBorderColor || colors.borderColor : colors.borderColor
+ ctx.lineWidth = 0.5
+ ctx.beginPath()
+ ctx.moveTo(borderStartX, screenY + rh - 0.5)
+ ctx.lineTo(width.value, screenY + rh - 0.5)
+ ctx.stroke()
+
+ // Left border color indicator
+ if (colorInfo?.rowLeftBorderColor) {
+ const indicatorW = 4
+ const indicatorH = rh - 8
+ const indicatorX = borderStartX
+ const indicatorY = screenY + (rh - indicatorH) / 2
+
+ ctx.fillStyle = colorInfo.rowLeftBorderColor
+ ctx.beginPath()
+ ctx.roundRect(indicatorX, indicatorY, indicatorW, indicatorH, 8)
+ ctx.fill()
+ }
+
+ // Element map: row
+ elementMap.value.push({
+ type: 'row',
+ rowIndex,
+ x: 0,
+ y: screenY,
+ width: width.value,
+ height: rh,
+ depth,
+ pk: row.__nc_pk,
+ })
+
+ // Chevron
+ if (isParent) {
+ const chevronX = depth * INDENT_PER_DEPTH + (CHEVRON_COL_WIDTH - CHEVRON_SIZE) / 2 - scrollLeft.value
+ const chevronY = screenY + 8
+
+ renderChevron(ctx, chevronX, chevronY, collapsed, colors.chevronColor)
+
+ // Hit area: full chevron column width for easier clicking
+ const hitX = depth * INDENT_PER_DEPTH - scrollLeft.value
+ elementMap.value.push({
+ type: 'chevron',
+ rowIndex,
+ x: hitX,
+ y: screenY,
+ width: CHEVRON_COL_WIDTH,
+ height: rh,
+ depth,
+ pk: row.__nc_pk,
+ })
+ }
+
+ // Cell values per column
+ const cols = getColumnsForDepth(depth)
+ let x = indent - scrollLeft.value
+
+ for (const col of cols) {
+ const w = parseCellWidth(col.width)
+ const value = row[col.title]
+ const isEditable = !col.readonly
+
+ // Editable cell: border + shadow
+ if (isEditable && isHovered) {
+ const cellX = x + 1
+ const cellY = screenY + 2
+ const cellW = w - 2
+ const cellH = rh - 4
+
+ // Shadow layers (approximate multi-layer CSS box-shadow)
+ ctx.save()
+ ctx.shadowColor = 'rgba(0, 0, 0, 0.12)'
+ ctx.shadowBlur = 4
+ ctx.shadowOffsetX = 0
+ ctx.shadowOffsetY = 1
+ ctx.fillStyle = colors.rowBg
+ ctx.beginPath()
+ ctx.roundRect(cellX, cellY, cellW, cellH, 4)
+ ctx.fill()
+ ctx.restore()
+
+ // Border
+ ctx.strokeStyle = getColor(themeV4Colors.gray['300'])
+ ctx.lineWidth = 0.5
+ ctx.beginPath()
+ ctx.roundRect(cellX, cellY, cellW, cellH, 4)
+ ctx.stroke()
+ }
+
+ // Clip and render cell via the type-aware renderer
+ ctx.save()
+ ctx.beginPath()
+ ctx.rect(x, screenY, w, rh)
+ ctx.clip()
+
+ renderCell(ctx, col.columnObj, {
+ value,
+ row,
+ x,
+ y: screenY,
+ width: w,
+ height: rh,
+ pv: col.pv,
+ padding: CELL_PADDING,
+ pk: row.__nc_pk,
+ mousePosition,
+ meta: meta.value,
+ isRowHovered: isHovered,
+ relatedColObj: col.relatedColObj,
+ relatedTableMeta: col.relatedTableMeta,
+ readonly: col.readonly,
+ })
+
+ ctx.restore()
+
+ // Register editable cell hit region
+ if (isEditable) {
+ elementMap.value.push({
+ type: 'cell',
+ rowIndex,
+ x,
+ y: screenY,
+ width: w,
+ height: rh,
+ depth,
+ pk: row.__nc_pk,
+ columnId: col.id,
+ })
+ }
+
+ x += w
+ }
+
+ // "Open >" expand button on hover β€” positioned at the right of the first cell
+ if (isHovered && cols.length > 0) {
+ const firstColW = parseCellWidth(cols[0].width)
+ const firstCellX = indent - scrollLeft.value
+
+ const label = 'Open'
+ ctx.font = '500 11px Inter'
+ const labelW = ctx.measureText(label).width
+ const chevronW = 5
+ const btnPadH = 6
+ const btnGap = 3
+ const btnW = btnPadH + labelW + btnGap + chevronW + btnPadH
+ const btnH = 20
+ const btnX = firstCellX + firstColW - btnW - CELL_PADDING
+ const btnY = screenY + (rh - btnH) / 2
+
+ // Only render if button fits inside first cell
+ if (btnX > firstCellX + CELL_PADDING) {
+ // Background pill
+ ctx.fillStyle = getColor(themeV4Colors.gray['100'])
+ ctx.beginPath()
+ ctx.roundRect(btnX, btnY, btnW, btnH, 4)
+ ctx.fill()
+
+ // Check hover over expand button
+ const isBtnHovered =
+ mousePosition.x >= btnX && mousePosition.x <= btnX + btnW && mousePosition.y >= btnY && mousePosition.y <= btnY + btnH
+
+ if (isBtnHovered) {
+ ctx.fillStyle = getColor(themeV4Colors.gray['200'])
+ ctx.beginPath()
+ ctx.roundRect(btnX, btnY, btnW, btnH, 4)
+ ctx.fill()
+ }
+
+ // Label text
+ ctx.fillStyle = getColor(themeV4Colors.gray['600'])
+ ctx.font = '500 11px Inter'
+ ctx.textBaseline = 'middle'
+ ctx.fillText(label, btnX + btnPadH, btnY + btnH / 2)
+
+ // Right chevron ">"
+ const chevronX = btnX + btnPadH + labelW + btnGap
+ const chevronCY = btnY + btnH / 2
+ const cs = 3
+ ctx.beginPath()
+ ctx.moveTo(chevronX, chevronCY - cs)
+ ctx.lineTo(chevronX + cs, chevronCY)
+ ctx.lineTo(chevronX, chevronCY + cs)
+ ctx.strokeStyle = getColor(themeV4Colors.gray['600'])
+ ctx.lineWidth = 1.5
+ ctx.stroke()
+
+ // Element map for click
+ elementMap.value.push({
+ type: 'expandRow',
+ rowIndex,
+ x: btnX,
+ y: btnY,
+ width: btnW,
+ height: btnH,
+ depth,
+ pk: row.__nc_pk,
+ })
+ }
+ }
+ }
+
+ function renderHeaderPill(ctx: CanvasRenderingContext2D, pillX: number, headerY: number, headerH: number) {
+ const pillW = 3
+ const pillH = 14
+ const pillR = 1.5
+ const px = pillX - pillW / 2
+ const py = headerY + (headerH - pillH) / 2
+
+ // Check if mouse is directly over the pill (generous hit area)
+ const hitPadX = 8
+ const hitPadY = 4
+ const isHovered =
+ mousePosition.x >= px - hitPadX &&
+ mousePosition.x <= px + pillW + hitPadX &&
+ mousePosition.y >= py - hitPadY &&
+ mousePosition.y <= py + pillH + hitPadY
+
+ ctx.fillStyle = isHovered ? getColor(themeV4Colors.brand['500']) : getColor(themeV4Colors.gray['300'])
+
+ ctx.beginPath()
+ ctx.roundRect(px, py, pillW, pillH, pillR)
+ ctx.fill()
+ }
+
+ function renderChevron(ctx: CanvasRenderingContext2D, x: number, y: number, collapsed: boolean, color: string) {
+ ctx.save()
+ ctx.fillStyle = color
+ ctx.beginPath()
+
+ const cx = x + CHEVRON_SIZE / 2
+ const cy = y + CHEVRON_SIZE / 2
+ const s = 4
+
+ if (collapsed) {
+ ctx.moveTo(cx - s / 2 + 1, cy - s)
+ ctx.lineTo(cx + s / 2 + 1, cy)
+ ctx.lineTo(cx - s / 2 + 1, cy + s)
+ } else {
+ ctx.moveTo(cx - s, cy - s / 2 + 1)
+ ctx.lineTo(cx, cy + s / 2 + 1)
+ ctx.lineTo(cx + s, cy - s / 2 + 1)
+ }
+
+ ctx.closePath()
+ ctx.fill()
+ ctx.restore()
+ }
+
+ function truncateText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string {
+ if (maxWidth <= 0) return ''
+ if (ctx.measureText(text).width <= maxWidth) return text
+
+ const ellipsis = '...'
+ const ew = ctx.measureText(ellipsis).width
+ let lo = 0
+ let hi = text.length
+ while (lo < hi) {
+ const mid = Math.ceil((lo + hi) / 2)
+ if (ctx.measureText(text.slice(0, mid)).width + ew <= maxWidth) lo = mid
+ else hi = mid - 1
+ }
+ return text.slice(0, lo) + ellipsis
+ }
+
+ return {
+ canvasRef,
+ renderCanvas,
+ }
+}
diff --git a/packages/nc-gui/components/smartsheet/outline/composables/useColumnResize.ts b/packages/nc-gui/components/smartsheet/outline/composables/useColumnResize.ts
new file mode 100644
index 0000000000..cc7130d3d1
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/outline/composables/useColumnResize.ts
@@ -0,0 +1,115 @@
+import { parseCellWidth } from '../../grid/canvas/utils/cell'
+import { MIN_COLUMN_WIDTH, RESIZE_HANDLE_WIDTH } from './constants'
+
+export interface HeaderContext {
+ columns: CanvasGridColumn[]
+ startX: number // left edge of first column (already adjusted for scroll)
+}
+
+/**
+ * Column resize for the outline view canvas.
+ * Works on both root header and sub-headers via `resolveHeader`.
+ */
+export function useColumnResize(
+ canvasRef: Ref<HTMLCanvasElement | undefined>,
+ drawCanvas: () => void,
+ /** Given canvas-local (x, y), return the columns + startX for that header, or null */
+ resolveHeader: (x: number, y: number) => HeaderContext | null,
+ onResize: (columnId: string, width: number) => void,
+ onResizeEnd: (columnId: string, width: number) => void,
+) {
+ const isResizing = ref(false)
+ const resizingColumn = ref<{
+ id: string
+ initialWidth: number
+ startX: number
+ currentWidth: number
+ } | null>(null)
+
+ const isLocked = inject(IsLockedInj, ref(false))
+
+ /** Find a resizeable column border near x in the given header context */
+ function findResizeTarget(x: number, y: number): { id: string; width: number } | null {
+ const ctx = resolveHeader(x, y)
+ if (!ctx) return null
+
+ let currentX = ctx.startX
+ for (const column of ctx.columns) {
+ const w = parseCellWidth(column.width)
+ const borderX = currentX + w
+
+ if (Math.abs(x - borderX) <= RESIZE_HANDLE_WIDTH / 2) {
+ return { id: column.id, width: w }
+ }
+ currentX += w
+ }
+ return null
+ }
+
+ function handleDrag(e: MouseEvent) {
+ if (!isResizing.value || !resizingColumn.value) return
+
+ const rect = canvasRef.value?.getBoundingClientRect()
+ if (!rect) return
+
+ const x = e.clientX - rect.left
+ const delta = x - resizingColumn.value.startX
+ const newWidth = Math.max(MIN_COLUMN_WIDTH, resizingColumn.value.initialWidth + delta)
+ resizingColumn.value.currentWidth = newWidth
+
+ onResize(resizingColumn.value.id, newWidth)
+ }
+
+ function handleMouseUp() {
+ if (isResizing.value && resizingColumn.value) {
+ onResizeEnd(resizingColumn.value.id, resizingColumn.value.currentWidth)
+ }
+ cleanup()
+ }
+
+ function cleanup() {
+ isResizing.value = false
+ resizingColumn.value = null
+ window.removeEventListener('mousemove', handleDrag)
+ window.removeEventListener('mouseup', handleMouseUp)
+ }
+
+ /** Call from canvas mousedown β€” returns true if resize started */
+ function startResize(e: MouseEvent): boolean {
+ const rect = canvasRef.value?.getBoundingClientRect()
+ if (!rect || isLocked.value) return false
+
+ const x = e.clientX - rect.left
+ const y = e.clientY - rect.top
+ const target = findResizeTarget(x, y)
+ if (!target) return false
+
+ isResizing.value = true
+ resizingColumn.value = {
+ id: target.id,
+ initialWidth: target.width,
+ startX: x,
+ currentWidth: target.width,
+ }
+
+ window.addEventListener('mousemove', handleDrag)
+ window.addEventListener('mouseup', handleMouseUp)
+ return true
+ }
+
+ /** Call from canvas mousemove to get cursor */
+ function updateCursor(x: number, y: number): string | null {
+ if (isResizing.value) return 'col-resize'
+ const target = findResizeTarget(x, y)
+ return target ? 'col-resize' : null
+ }
+
+ onBeforeUnmount(cleanup)
+
+ return {
+ isResizing,
+ resizingColumn,
+ startResize,
+ updateCursor,
+ }
+}
diff --git a/packages/nc-gui/components/smartsheet/outline/composables/useDataFetch.ts b/packages/nc-gui/components/smartsheet/outline/composables/useDataFetch.ts
new file mode 100644
index 0000000000..6f3d5fed8c
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/outline/composables/useDataFetch.ts
@@ -0,0 +1,278 @@
+/**
+ * useOutlineDataFetch β€” Chunked data loading for the outline view canvas.
+ *
+ * The outline view API (`outlineViewDataList`) supports offset/limit pagination.
+ * The count API (`outlineViewDataCount`) returns totalRows + per-model counts.
+ *
+ * Both endpoints accept a `collapsed` param (JSON) so the server
+ * only returns expanded rows β€” collapsed subtrees are skipped server-side.
+ *
+ * This composable adapts the grid canvas's useDataFetch pattern:
+ * - Chunked loading with prefetch
+ * - Scroll-direction-aware prefetching
+ * - Throttled API calls
+ */
+
+import type { OutlineViewRow } from '~/composables/useOutlineViewStore'
+
+const CHUNK_SIZE = 50
+const INITIAL_LOAD_SIZE = 100
+const BUFFER_SIZE = 100
+const PREFETCH_THRESHOLD = 25
+const API_THROTTLE = 500
+
+export function useOutlineDataFetch({
+ viewId,
+ cachedRows,
+ chunkStates,
+ totalRows,
+ levelCounts,
+ collapsedJson,
+ loadPage,
+ loadCount,
+ triggerRefreshCanvas,
+}: {
+ /** Current view ID */
+ viewId: ComputedRef<string | undefined>
+ /** Row cache: index β†’ row data */
+ cachedRows: Ref<Map<number, OutlineViewRow>>
+ /** Chunk state tracking */
+ chunkStates: Ref<Array<'loading' | 'loaded' | undefined>>
+ /** Total visible row count (from count endpoint) */
+ totalRows: Ref<number>
+ /** Per-model counts from count endpoint: { modelId: count } */
+ levelCounts: Ref<Record<string, number>>
+ /** Serialized collapsed state for API calls */
+ collapsedJson: ComputedRef<string>
+ /** Fetch a page of data */
+ loadPage: (params: { offset: number; limit: number; collapsed: string }) => Promise<OutlineViewRow[]>
+ /** Fetch total count */
+ loadCount: (params: { collapsed: string }) => Promise<{ totalRows: number; counts: Record<string, number> }>
+ /** Trigger canvas re-render */
+ triggerRefreshCanvas: () => void
+}) {
+ const previousRowSlice = ref({ start: 0, end: 0 })
+
+ // -------------------------------------------------------------------
+ // Fetch count
+ // -------------------------------------------------------------------
+ async function fetchCount() {
+ if (!viewId.value) return
+
+ try {
+ const result = await loadCount({ collapsed: collapsedJson.value })
+ totalRows.value = result.totalRows
+ levelCounts.value = result.counts
+ } catch (e) {
+ console.error('Error fetching outline view count:', e)
+ }
+ }
+
+ // -------------------------------------------------------------------
+ // Fetch a single chunk
+ // -------------------------------------------------------------------
+ async function fetchChunk(chunkId: number, isInitialLoad = false) {
+ if (chunkStates.value[chunkId]) return
+
+ const offset = chunkId * CHUNK_SIZE
+ const limit = isInitialLoad ? INITIAL_LOAD_SIZE : CHUNK_SIZE
+
+ if (offset >= totalRows.value) return
+
+ chunkStates.value[chunkId] = 'loading'
+ if (isInitialLoad) {
+ chunkStates.value[chunkId + 1] = 'loading'
+ }
+
+ try {
+ const rows = await loadPage({
+ offset,
+ limit,
+ collapsed: collapsedJson.value,
+ })
+
+ rows.forEach((row, idx) => {
+ cachedRows.value.set(offset + idx, row)
+ })
+
+ chunkStates.value[chunkId] = 'loaded'
+ if (isInitialLoad) {
+ chunkStates.value[chunkId + 1] = 'loaded'
+ }
+ } catch (e) {
+ console.error(`Error fetching outline chunk ${chunkId}:`, e)
+ chunkStates.value[chunkId] = undefined
+ if (isInitialLoad) {
+ chunkStates.value[chunkId + 1] = undefined
+ }
+ }
+ }
+
+ // -------------------------------------------------------------------
+ // Fetch contiguous chunk group in one API call
+ // -------------------------------------------------------------------
+ async function fetchChunkGroup(group: number[]) {
+ if (group.length === 0) return
+
+ const startChunk = group[0]!
+ const endChunk = group[group.length - 1]!
+ const offset = startChunk * CHUNK_SIZE
+ const limit = (endChunk + 1) * CHUNK_SIZE - offset
+
+ if (offset >= totalRows.value) return
+
+ group.forEach((id) => (chunkStates.value[id] = 'loading'))
+
+ try {
+ const rows = await loadPage({
+ offset,
+ limit,
+ collapsed: collapsedJson.value,
+ })
+
+ rows.forEach((row, idx) => {
+ cachedRows.value.set(offset + idx, row)
+ })
+
+ group.forEach((id) => (chunkStates.value[id] = 'loaded'))
+ } catch (e) {
+ console.error(`Error fetching outline chunks ${startChunk}-${endChunk}:`, e)
+ group.forEach((id) => (chunkStates.value[id] = undefined))
+ }
+ }
+
+ // -------------------------------------------------------------------
+ // Throttled batch fetcher
+ // -------------------------------------------------------------------
+ const debouncedFetchChunks = useThrottleFn(
+ async (chunksToFetch: Set<number>, firstChunkId: number) => {
+ if (chunksToFetch.size === 0) return
+
+ const chunks = Array.from(chunksToFetch).sort((a, b) => a - b)
+
+ // Group contiguous chunks
+ const groups: number[][] = []
+ let currentGroup: number[] = [chunks[0]!]
+
+ for (let i = 1; i < chunks.length; i++) {
+ if (chunks[i] === chunks[i - 1]! + 1) {
+ currentGroup.push(chunks[i]!)
+ } else {
+ groups.push(currentGroup)
+ currentGroup = [chunks[i]!]
+ }
+ }
+ groups.push(currentGroup)
+
+ const maxGroupSize = Math.floor(200 / CHUNK_SIZE) // API max limit is 200
+
+ for (const group of groups) {
+ if (group[0] === 0 && firstChunkId === 0 && !chunkStates.value[0]) {
+ await fetchChunk(0, true)
+ const remaining = group.filter((id) => id > 1)
+ if (remaining.length) {
+ for (let i = 0; i < remaining.length; i += maxGroupSize) {
+ await fetchChunkGroup(remaining.slice(i, i + maxGroupSize))
+ }
+ }
+ } else if (group.length > maxGroupSize) {
+ for (let i = 0; i < group.length; i += maxGroupSize) {
+ await fetchChunkGroup(group.slice(i, i + maxGroupSize))
+ }
+ } else {
+ await fetchChunkGroup(group)
+ }
+ }
+
+ nextTick(triggerRefreshCanvas)
+ },
+ API_THROTTLE,
+ true,
+ )
+
+ // -------------------------------------------------------------------
+ // Update visible rows β€” called on scroll
+ // -------------------------------------------------------------------
+ function updateVisibleRows(rowSlice: { start: number; end: number }) {
+ const { start, end } = rowSlice
+ const firstChunkId = Math.floor(start / CHUNK_SIZE)
+ const lastChunkId = Math.floor(Math.max(0, end - 1) / CHUNK_SIZE)
+
+ // Scroll direction
+ let scrollDirection: 'down' | 'up' | 'none' = 'none'
+ if (start > previousRowSlice.value.start) scrollDirection = 'down'
+ else if (start < previousRowSlice.value.start) scrollDirection = 'up'
+ previousRowSlice.value = { start, end }
+
+ const chunksToFetch = new Set<number>()
+
+ // Visible chunks
+ for (let chunkId = firstChunkId; chunkId <= lastChunkId; chunkId++) {
+ if (!chunkStates.value[chunkId]) {
+ chunksToFetch.add(chunkId)
+ }
+ }
+
+ // Prefetch based on scroll direction
+ if (scrollDirection === 'down' || scrollDirection === 'none') {
+ const nextChunkId = lastChunkId + 1
+ if (end % CHUNK_SIZE > CHUNK_SIZE - PREFETCH_THRESHOLD && !chunkStates.value[nextChunkId]) {
+ chunksToFetch.add(nextChunkId)
+ }
+ } else if (scrollDirection === 'up') {
+ const prevChunkId = firstChunkId - 1
+ if (prevChunkId >= 0 && start % CHUNK_SIZE < PREFETCH_THRESHOLD && !chunkStates.value[prevChunkId]) {
+ chunksToFetch.add(prevChunkId)
+ }
+ }
+
+ // Evict out-of-buffer rows
+ clearCache(Math.max(0, start - BUFFER_SIZE), Math.min(totalRows.value, end + BUFFER_SIZE))
+
+ debouncedFetchChunks(chunksToFetch, firstChunkId)
+ }
+
+ // -------------------------------------------------------------------
+ // Clear rows outside the buffer window
+ // -------------------------------------------------------------------
+ function clearCache(keepStart: number, keepEnd: number) {
+ const affectedChunks = new Set<number>()
+
+ for (const [idx] of cachedRows.value) {
+ if (idx < keepStart || idx >= keepEnd) {
+ cachedRows.value.delete(idx)
+ affectedChunks.add(Math.floor(idx / CHUNK_SIZE))
+ }
+ }
+
+ // Reset chunkStates for evicted chunks so they get re-fetched when scrolled back
+ for (const chunkId of affectedChunks) {
+ chunkStates.value[chunkId] = undefined
+ }
+ }
+
+ // -------------------------------------------------------------------
+ // Reset β€” call when collapsed state changes (server re-query needed)
+ // Does NOT clear old cache β€” stale rows are naturally evicted by
+ // updateVisibleRows and overwritten by new fetches, avoiding flicker.
+ // -------------------------------------------------------------------
+ async function resetAndReload() {
+ chunkStates.value = []
+
+ await fetchCount()
+
+ if (totalRows.value > 0) {
+ await fetchChunk(0, true)
+ }
+
+ nextTick(triggerRefreshCanvas)
+ }
+
+ return {
+ fetchCount,
+ fetchChunk,
+ updateVisibleRows,
+ resetAndReload,
+ clearCache,
+ }
+}
diff --git a/packages/nc-gui/components/smartsheet/outline/composables/useOutlineCellRenderer.ts b/packages/nc-gui/components/smartsheet/outline/composables/useOutlineCellRenderer.ts
new file mode 100644
index 0000000000..69f658fcfb
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/outline/composables/useOutlineCellRenderer.ts
@@ -0,0 +1,370 @@
+import { type ColumnType, type TableType, UITypes } from 'nocodb-sdk'
+import { renderSingleLineText } from '../../grid/canvas/utils/canvas'
+import type { SpriteLoader } from '../../grid/canvas/loaders/SpriteLoader'
+import { ImageWindowLoader } from '../../grid/canvas/loaders/ImageLoader'
+import { MarkdownLoader } from '../../grid/canvas/loaders/markdownLoader'
+import { EmailCellRenderer } from '../../grid/canvas/cells/Email'
+import { SingleLineTextCellRenderer } from '../../grid/canvas/cells/SingleLineText'
+import { LongTextCellRenderer } from '../../grid/canvas/cells/LongText'
+import { FloatCellRenderer } from '../../grid/canvas/cells/Number'
+import { DecimalCellRenderer } from '../../grid/canvas/cells/Decimal'
+import { AttachmentCellRenderer } from '../../grid/canvas/cells/Attachment'
+import { CheckboxCellRenderer } from '../../grid/canvas/cells/Checkbox'
+import { DateCellRenderer } from '../../grid/canvas/cells/Date'
+import { DateTimeCellRenderer } from '../../grid/canvas/cells/DateTime'
+import { YearCellRenderer } from '../../grid/canvas/cells/Year'
+import { TimeCellRenderer } from '../../grid/canvas/cells/Time'
+import { CurrencyRenderer } from '../../grid/canvas/cells/Currency'
+import { PercentCellRenderer } from '../../grid/canvas/cells/Percent'
+import { UrlCellRenderer } from '../../grid/canvas/cells/Url'
+import { GeoDataCellRenderer } from '../../grid/canvas/cells/GeoData'
+import { PhoneNumberCellRenderer } from '../../grid/canvas/cells/PhoneNumber'
+import { DurationCellRenderer } from '../../grid/canvas/cells/Duration'
+import { JsonCellRenderer } from '../../grid/canvas/cells/Json'
+import { BarcodeCellRenderer } from '../../grid/canvas/cells/Barcode'
+import { QRCodeCellRenderer } from '../../grid/canvas/cells/QRCode'
+import { RatingCellRenderer } from '../../grid/canvas/cells/Rating'
+import { ColourCellRenderer } from '../../grid/canvas/cells/Colour'
+import { UserFieldCellRenderer } from '../../grid/canvas/cells/User'
+import { SingleSelectCellRenderer } from '../../grid/canvas/cells/SingleSelect'
+import { MultiSelectCellRenderer } from '../../grid/canvas/cells/MultiSelect'
+import { RollupCellRenderer } from '../../grid/canvas/cells/Rollup'
+import { LinksCellRenderer } from '../../grid/canvas/cells/Links'
+import { LookupCellRenderer } from '../../grid/canvas/cells/Lookup'
+import { ButtonCellRenderer } from '../../grid/canvas/cells/Button'
+import { LtarCellRenderer } from '../../grid/canvas/cells/LTAR'
+import { FormulaCellRenderer } from '../../grid/canvas/cells/Formula'
+import { UUIDCellRenderer } from '../../grid/canvas/cells/UUID'
+import { GenericReadOnlyRenderer } from '../../grid/canvas/cells/GenericReadonlyRenderer'
+import { NullCellRenderer } from '../../grid/canvas/cells/Null'
+import { PlainCellRenderer } from '../../grid/canvas/cells/Plain'
+import { ActionManager } from '../../grid/canvas/loaders/ActionManager'
+
+const CLEANUP_INTERVAL = 1000
+
+export function useOutlineCellRenderer(params: {
+ spriteLoader: SpriteLoader
+ triggerRefreshCanvas: () => void
+ setCursor: SetCursorType
+ meta: Ref<TableType | undefined>
+ cachedRows: Ref<Map<number, Row>>
+ totalRows: Ref<number>
+ chunkStates: Ref<Array<'loading' | 'loaded' | undefined>>
+ updateOrSaveRow: (row: Row, property?: string) => Promise<any>
+}) {
+ const { spriteLoader, triggerRefreshCanvas, setCursor } = params
+
+ const { getColor, isDark } = useTheme()
+ const { metas } = useMetas()
+ const { showNull, appInfo, user } = useGlobal()
+ const { t } = useI18n()
+ const { $api } = useNuxtApp()
+
+ const isPublic = inject(IsPublicInj, ref(false))
+
+ const baseStore = useBase()
+ const { isMysql, isXcdbBase, isPg } = baseStore
+ const { sqlUis } = storeToRefs(baseStore)
+
+ const { basesUser } = storeToRefs(useBases())
+
+ const imageLoader = new ImageWindowLoader(() => triggerRefreshCanvas())
+ const markdownLoader = new MarkdownLoader(() => triggerRefreshCanvas())
+
+ const { generateRows: _generateRows } = useNocoAi()
+ const { eventBus: scriptEventBus } = useScriptExecutor()
+ const { loadScript } = useScriptStore()
+ const { currentUser } = useUserSync()
+
+ function generateRows(columnId: string, rowIds: string[]) {
+ return _generateRows(params.meta.value?.id, columnId, rowIds)
+ }
+
+ const emptySelectedRows = computed(() => [] as Array<Row>)
+ const emptyIsRowSortRequired = computed(() => [] as Array<Row>)
+
+ const getDataCache = () => ({
+ cachedRows: params.cachedRows,
+ totalRows: params.totalRows,
+ chunkStates: params.chunkStates,
+ selectedRows: emptySelectedRows,
+ isRowSortRequiredRows: emptyIsRowSortRequired,
+ })
+
+ const actionManager = new ActionManager(
+ $api,
+ loadScript,
+ generateRows,
+ params.meta as Ref<TableType>,
+ triggerRefreshCanvas,
+ getDataCache,
+ scriptEventBus,
+ currentUser,
+ )
+
+ if (baseStore.base?.id && baseStore.base?.fk_workspace_id) {
+ actionManager.setBaseInfo(baseStore.base.id, baseStore.base.fk_workspace_id)
+ }
+
+ onUnmounted(() => {
+ actionManager.releaseEventListeners()
+ })
+
+ const cellTypesRegistry = new Map<string, CellRenderer>()
+
+ cellTypesRegistry.set(UITypes.Email, EmailCellRenderer)
+ cellTypesRegistry.set(UITypes.SingleLineText, SingleLineTextCellRenderer)
+ cellTypesRegistry.set(UITypes.LongText, LongTextCellRenderer)
+ cellTypesRegistry.set(UITypes.Number, FloatCellRenderer)
+ cellTypesRegistry.set(UITypes.Decimal, DecimalCellRenderer)
+ cellTypesRegistry.set(UITypes.Attachment, AttachmentCellRenderer)
+ cellTypesRegistry.set(UITypes.Checkbox, CheckboxCellRenderer)
+ cellTypesRegistry.set(UITypes.Date, DateCellRenderer)
+ cellTypesRegistry.set(UITypes.DateTime, DateTimeCellRenderer)
+ cellTypesRegistry.set(UITypes.Year, YearCellRenderer)
+ cellTypesRegistry.set(UITypes.Time, TimeCellRenderer)
+ cellTypesRegistry.set(UITypes.Currency, CurrencyRenderer)
+ cellTypesRegistry.set(UITypes.Percent, PercentCellRenderer)
+ cellTypesRegistry.set(UITypes.URL, UrlCellRenderer)
+ cellTypesRegistry.set(UITypes.GeoData, GeoDataCellRenderer)
+ cellTypesRegistry.set(UITypes.PhoneNumber, PhoneNumberCellRenderer)
+ cellTypesRegistry.set(UITypes.Duration, DurationCellRenderer)
+ cellTypesRegistry.set(UITypes.CreatedTime, DateTimeCellRenderer)
+ cellTypesRegistry.set(UITypes.LastModifiedTime, DateTimeCellRenderer)
+ cellTypesRegistry.set(UITypes.JSON, JsonCellRenderer)
+ cellTypesRegistry.set(UITypes.Barcode, BarcodeCellRenderer)
+ cellTypesRegistry.set(UITypes.QrCode, QRCodeCellRenderer)
+ cellTypesRegistry.set(UITypes.Rating, RatingCellRenderer)
+ cellTypesRegistry.set(UITypes.Colour, ColourCellRenderer)
+ cellTypesRegistry.set(UITypes.User, UserFieldCellRenderer)
+ cellTypesRegistry.set(UITypes.CreatedBy, UserFieldCellRenderer)
+ cellTypesRegistry.set(UITypes.LastModifiedBy, UserFieldCellRenderer)
+ cellTypesRegistry.set(UITypes.SingleSelect, SingleSelectCellRenderer)
+ cellTypesRegistry.set(UITypes.MultiSelect, MultiSelectCellRenderer)
+ cellTypesRegistry.set(UITypes.Rollup, RollupCellRenderer)
+ cellTypesRegistry.set(UITypes.Links, LinksCellRenderer)
+ cellTypesRegistry.set(UITypes.Lookup, LookupCellRenderer)
+ cellTypesRegistry.set(UITypes.Button, ButtonCellRenderer)
+ cellTypesRegistry.set(UITypes.LinkToAnotherRecord, LtarCellRenderer)
+ cellTypesRegistry.set(UITypes.Formula, FormulaCellRenderer)
+ cellTypesRegistry.set(UITypes.Geometry, SingleLineTextCellRenderer)
+ cellTypesRegistry.set(UITypes.SpecificDBType, SingleLineTextCellRenderer)
+ cellTypesRegistry.set(UITypes.UUID, UUIDCellRenderer)
+ cellTypesRegistry.set(UITypes.ForeignKey, GenericReadOnlyRenderer)
+ cellTypesRegistry.set(UITypes.ID, GenericReadOnlyRenderer)
+
+ const cellRenderStoreMap = new Map<string, CellRenderStore>()
+ const expirationTimes = new Map<string, number>()
+
+ const getCellRenderStore = (key: string) => {
+ if (!cellRenderStoreMap.has(key)) {
+ cellRenderStoreMap.set(key, {})
+ }
+ expirationTimes.set(key, Date.now() + CLEANUP_INTERVAL)
+ return cellRenderStoreMap.get(key)!
+ }
+
+ let cleanUpInterval: ReturnType<typeof setInterval> | null = null
+
+ onMounted(() => {
+ cleanUpInterval = setInterval(() => {
+ const now = Date.now()
+ for (const [key, expiration] of expirationTimes.entries()) {
+ if (now >= expiration) {
+ cellRenderStoreMap.delete(key)
+ expirationTimes.delete(key)
+ }
+ }
+ }, CLEANUP_INTERVAL)
+ })
+
+ onUnmounted(() => {
+ if (cleanUpInterval) {
+ clearInterval(cleanUpInterval)
+ }
+ })
+
+ const renderCell = (
+ ctx: CanvasRenderingContext2D,
+ column: ColumnType,
+ {
+ value,
+ row,
+ x,
+ y,
+ width,
+ height,
+ pv = false,
+ padding = 10,
+ pk,
+ mousePosition,
+ meta,
+ isRowHovered = false,
+ renderAsPlainCell = false,
+ relatedColObj,
+ relatedTableMeta,
+ textColor,
+ fontFamily,
+ readonly = false,
+ }: Omit<CellRendererOptions, 'metas' | 'isMysql' | 'isXcdbBase' | 'sqlUis' | 'baseUsers' | 'isPg'>,
+ ) => {
+ const cellType = cellTypesRegistry.get(column.uidt!)
+ const cellRenderStore = getCellRenderStore(`${column.id}-${pk}`)
+
+ const shouldRenderNull = showNull.value && isShowNullField(column) && (ncIsUndefined(value) || ncIsNull(value))
+
+ let cellRenderer: CellRenderFn | undefined
+
+ if (renderAsPlainCell) {
+ cellRenderer = PlainCellRenderer.render
+ } else if (cellType) {
+ cellRenderer = shouldRenderNull ? cellType.renderEmpty ?? NullCellRenderer.render : cellType.render
+ } else if (shouldRenderNull) {
+ cellRenderer = NullCellRenderer.render
+ }
+
+ ctx.textAlign = 'left'
+
+ if (cellRenderer) {
+ cellRenderer(ctx, {
+ value,
+ row,
+ column,
+ x,
+ y,
+ width,
+ height,
+ selected: false,
+ pv,
+ readonly,
+ spriteLoader,
+ imageLoader,
+ markdownLoader,
+ isMysql,
+ isPg,
+ isXcdbBase,
+ t,
+ padding,
+ renderCell,
+ meta,
+ metas: metas.value,
+ relatedColObj,
+ relatedTableMeta,
+ tag: {},
+ fontSize: 13,
+ textAlign: 'center',
+ textColor,
+ mousePosition,
+ pk,
+ disabled: false,
+ sqlUis: sqlUis.value,
+ actionManager,
+ setCursor,
+ getColor,
+ isDark: isDark.value,
+ cellRenderStore,
+ baseUsers: meta?.base_id ? basesUser.value.get(meta.base_id) || [] : [],
+ user: user.value,
+ isUnderLookup: false,
+ isPublic: isPublic.value,
+ path: [],
+ fontFamily,
+ isRowHovered,
+ isRowChecked: false,
+ rowMeta: {},
+ allowLocalUrl: appInfo.value?.allowLocalUrl,
+ })
+ } else {
+ renderSingleLineText(ctx, {
+ x: x + padding,
+ y,
+ text: value?.toString() ?? '',
+ fontFamily: fontFamily ?? `${pv ? 600 : 500} 13px Inter`,
+ fillStyle: pv ? getColor(themeV4Colors.brand['500']) : getColor(textColor ?? themeV4Colors.gray['600']),
+ height,
+ py: padding,
+ cellRenderStore,
+ })
+ }
+ }
+
+ const handleCellClick = async (ctx: {
+ event: MouseEvent
+ row: Row
+ column: CanvasGridColumn
+ value: any
+ mousePosition: { x: number; y: number }
+ pk: any
+ selected: boolean
+ imageLoader: ImageWindowLoader
+ path: Array<number>
+ cellPosition: { x: number; y: number; width: number; height: number }
+ }) => {
+ if (!ctx.column?.columnObj?.uidt) return false
+
+ const cellHandler = cellTypesRegistry.get(ctx.column.columnObj.uidt)
+ const cellRenderStore = getCellRenderStore(`${ctx.column.id}-${ctx.pk}`)
+
+ if (cellHandler?.handleClick) {
+ return await cellHandler.handleClick({
+ ...ctx,
+ cellRenderStore,
+ isDoubleClick: ctx.event.detail === 2,
+ readonly: ctx.column.readonly,
+ getCellPosition: () => ctx.cellPosition,
+ updateOrSaveRow: params.updateOrSaveRow,
+ actionManager,
+ makeCellEditable: () => {},
+ markdownLoader,
+ isPublic: isPublic.value,
+ openDetachedExpandedForm: () => {},
+ openDetachedLongText: () => {},
+ allowLocalUrl: appInfo.value?.allowLocalUrl,
+ t,
+ getColor,
+ baseRoles: {},
+ })
+ }
+ return false
+ }
+
+ const handleCellHover = async (ctx: {
+ event: MouseEvent
+ row: Row
+ column: CanvasGridColumn
+ value: any
+ mousePosition: { x: number; y: number }
+ pk: any
+ selected: boolean
+ imageLoader: ImageWindowLoader
+ }) => {
+ if (!ctx.column?.columnObj?.uidt) return
+
+ const cellHandler = cellTypesRegistry.get(ctx.column.columnObj.uidt)
+ const cellRenderStore = getCellRenderStore(`${ctx.column.id}-${ctx.pk}`)
+
+ if (cellHandler?.handleHover) {
+ return await cellHandler.handleHover({
+ ...ctx,
+ cellRenderStore,
+ setCursor,
+ markdownLoader,
+ path: [],
+ baseUsers: ctx.row?.row?.base_id ? basesUser.value.get(ctx.row.row.base_id) || [] : [],
+ t,
+ getCellPosition: () => ({ x: 0, y: 0, width: 0, height: 0 }),
+ updateOrSaveRow: params.updateOrSaveRow,
+ actionManager,
+ makeCellEditable: () => {},
+ })
+ }
+ }
+
+ return {
+ renderCell,
+ handleCellClick,
+ handleCellHover,
+ imageLoader,
+ actionManager,
+ }
+}
diff --git a/packages/nc-gui/components/smartsheet/outline/index.vue b/packages/nc-gui/components/smartsheet/outline/index.vue
new file mode 100644
index 0000000000..0f6ac24d56
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/outline/index.vue
@@ -0,0 +1,472 @@
+<script setup lang="ts">
+import {
+ type ColumnType,
+ type LinkToAnotherRecordType,
+ RelationTypes,
+ type TableType,
+ isLinksOrLTAR,
+ isVirtualCol,
+} from 'nocodb-sdk'
+import { flip, offset, shift, useFloating } from '@floating-ui/vue'
+import Scroller from '../grid/canvas/components/Scroller.vue'
+import Tooltip from '../grid/canvas/components/Tooltip.vue'
+import { useCanvasOutline } from './composables/useCanvasOutline'
+
+const { meta, view } = useSmartsheetStoreOrThrow()
+const { metas, getMeta } = useMetas()
+const { $api } = useNuxtApp()
+
+const route = useRoute()
+const router = useRouter()
+
+const rowHeightEnum = computed(() => {
+ const outlineView = view.value?.view as OutlineType | undefined
+ if (outlineView?.row_height !== undefined) {
+ switch (outlineView.row_height) {
+ case 0:
+ return 1
+ case 1:
+ return 2
+ case 2:
+ return 4
+ case 3:
+ return 6
+ default:
+ return 1
+ }
+ }
+ return 1
+})
+
+provide(IsCanvasInjectionInj, true)
+provide(IsFormInj, ref(false))
+provide(IsGalleryInj, ref(false))
+provide(IsGridInj, ref(false))
+provide(IsCalendarInj, ref(false))
+provide(IsListInj, ref(true))
+provide(RowHeightInj, rowHeightEnum)
+
+const scrollTop = ref(0)
+const scrollLeft = ref(0)
+const wrapperRef = ref()
+const activeCellRow = ref<Row | null>(null)
+
+const mousePosition = reactive({ x: 0, y: 0 })
+const clientMousePosition = reactive(clientMousePositionDefaultValue)
+const scroller = ref()
+provide(ClientMousePositionInj, clientMousePosition)
+
+const isContextMenuOpen = ref(false)
+
+const reloadViewDataHook = inject(ReloadViewDataHookInj, createEventHook())
+const isPublicView = inject(IsPublicInj, ref(false))
+
+const { height, width } = useElementSize(wrapperRef)
+const tooltipStore = useTooltipStore()
+const { targetReference, placement } = storeToRefs(tooltipStore)
+const tooltipRef = ref()
+const { floatingStyles } = useFloating(targetReference, tooltipRef, {
+ placement,
+ middleware: [offset(8), flip(), shift({ padding: 5 })],
+})
+
+const { isConfigured } = useOutlineViewStoreOrThrow()
+
+const {
+ canvasRef,
+ triggerRefreshCanvas,
+ resetAndReload,
+ totalHeight,
+ totalWidth,
+ handleCanvasMouseDown,
+ handleCanvasClick,
+ handleCanvasMouseMove,
+ handleCanvasMouseLeave,
+ onExpandRow,
+ onAddRow,
+ activeCell,
+ cachedRows,
+} = useCanvasOutline({
+ scrollLeft,
+ scrollTop,
+ width,
+ height,
+ mousePosition,
+})
+
+function handleScroll({ left, top }: { left: number; top: number }) {
+ scrollLeft.value = left
+ scrollTop.value = top
+ if (activeCell.value) {
+ activeCell.value = null
+ }
+}
+
+reloadViewDataHook.on(() => {
+ resetAndReload()
+})
+
+const { displayLevels } = useOutlineViewStoreOrThrow()
+
+const expandedFormDlg = ref(false)
+const expandedFormRow = ref<Row>()
+const expandedFormRowState = ref<Record<string, any>>()
+const expandedFormMeta = ref<TableType>()
+
+function getMetaForDepth(depth: number): TableType | undefined {
+ const level = displayLevels.value[depth]
+ if (!level?.fk_model_id) return undefined
+ const baseId = meta.value?.base_id
+ const metaKey = `${baseId}:${level.fk_model_id}`
+ return metas.value?.[metaKey] as TableType | undefined
+}
+
+const expandedFormOnRowIdDlg = computed({
+ get() {
+ return !!route.query.rowId
+ },
+ set(val) {
+ if (!val) {
+ expandedFormMeta.value = undefined
+ router.push({
+ query: {
+ ...route.query,
+ rowId: undefined,
+ },
+ })
+ }
+ },
+})
+
+function expandForm(row: Row, state?: Record<string, any>) {
+ const rowMeta = expandedFormMeta.value || meta.value
+ const rowId = extractPkFromRow(row.row, rowMeta!.columns as ColumnType[])
+ expandedFormRowState.value = state
+
+ if (rowId && !isPublicView.value) {
+ expandedFormRow.value = undefined
+ router.push({
+ query: {
+ ...route.query,
+ rowId,
+ },
+ })
+ } else {
+ expandedFormRow.value = row
+ expandedFormDlg.value = true
+ }
+}
+
+onExpandRow(async ({ row, depth }) => {
+ let depthMeta = getMetaForDepth(depth)
+ if (!depthMeta) {
+ const level = displayLevels.value[depth]
+ if (level?.fk_model_id) {
+ const baseId = meta.value?.base_id
+ depthMeta = (await getMeta(level.fk_model_id, false, false, baseId)) as TableType | undefined
+ }
+ }
+ expandedFormMeta.value = depthMeta
+
+ const rowObj: Row = {
+ row: { ...row },
+ oldRow: { ...row },
+ rowMeta: {},
+ }
+ expandForm(rowObj)
+})
+
+onAddRow(async ({ depth, parentPk }) => {
+ let depthMeta = getMetaForDepth(depth)
+ if (!depthMeta) {
+ const level = displayLevels.value[depth]
+ if (level?.fk_model_id) {
+ const baseId = meta.value?.base_id
+ depthMeta = (await getMeta(level.fk_model_id, false, false, baseId)) as TableType | undefined
+ }
+ }
+ if (!depthMeta) return
+
+ expandedFormMeta.value = depthMeta
+
+ const newRow: Row = {
+ row: {},
+ oldRow: {},
+ rowMeta: { new: true },
+ }
+
+ if (parentPk !== undefined && depth > 0) {
+ const parentLevel = displayLevels.value[depth - 1]
+ let parentDepthMeta = getMetaForDepth(depth - 1)
+ if (!parentDepthMeta && parentLevel?.fk_model_id) {
+ parentDepthMeta = (await getMeta(parentLevel.fk_model_id, false, false, meta.value?.base_id)) as TableType | undefined
+ }
+
+ if (parentLevel?.fk_link_column_id && parentDepthMeta) {
+ const hmCol = parentDepthMeta.columns?.find((c: ColumnType) => c.id === parentLevel.fk_link_column_id)
+ if (hmCol) {
+ const hmColOpt = hmCol.colOptions as LinkToAnotherRecordType
+
+ const btCol = depthMeta.columns?.find((c: ColumnType) => {
+ if (!isLinksOrLTAR(c)) return false
+ const colOpt = c.colOptions as LinkToAnotherRecordType
+ if (!colOpt) return false
+ return (
+ colOpt.fk_related_model_id === parentDepthMeta!.id &&
+ (colOpt.type === RelationTypes.BELONGS_TO || colOpt.type === 'bt') &&
+ colOpt.fk_child_column_id === hmColOpt.fk_child_column_id
+ )
+ })
+
+ if (btCol?.title) {
+ const parentPkCols = parentDepthMeta.columns?.filter((c: ColumnType) => c.pk) ?? []
+ const parentPvCol = parentDepthMeta.columns?.find((c: ColumnType) => c.pv)
+ const pkValues = parentPk.toString().split('___')
+ const parentRowRef: Record<string, any> = {}
+ parentPkCols.forEach((col: ColumnType, i: number) => {
+ parentRowRef[col.title!] = pkValues[i] ?? parentPk
+ })
+ if (parentPvCol?.title && !(parentPvCol.title in parentRowRef)) {
+ parentRowRef[parentPvCol.title] = parentPk
+ }
+
+ newRow.row[btCol.title] = parentRowRef
+ expandedFormRowState.value = { [btCol.title]: parentRowRef }
+ expandedFormRow.value = newRow
+ expandedFormDlg.value = true
+ return
+ }
+ }
+ }
+ }
+
+ expandedFormRow.value = newRow
+ expandedFormRowState.value = undefined
+ expandedFormDlg.value = true
+})
+
+const activeCellStyle = computed(() => {
+ if (!activeCell.value) return {}
+ return {
+ position: 'absolute' as const,
+ top: `${activeCell.value.y}px`,
+ left: `${activeCell.value.x}px`,
+ width: `${activeCell.value.width}px`,
+ height: `${activeCell.value.height}px`,
+ zIndex: 10,
+ }
+})
+
+function onCellValueUpdate(val: any) {
+ if (!activeCell.value || !activeCellRow.value) return
+ activeCellRow.value.row[activeCell.value.column.title] = val
+}
+
+let pendingSave: {
+ cell: typeof activeCell.value
+ row: Row
+} | null = null
+
+watch(activeCell, (newVal, oldVal) => {
+ if (oldVal && activeCellRow.value) {
+ pendingSave = {
+ cell: { ...oldVal },
+ row: JSON.parse(JSON.stringify(activeCellRow.value)),
+ }
+ savePendingCell()
+ }
+
+ if (newVal) {
+ activeCellRow.value = {
+ row: { ...newVal.row },
+ oldRow: { ...newVal.row },
+ rowMeta: {},
+ }
+ } else {
+ activeCellRow.value = null
+ }
+})
+
+async function onVirtualCellSave(rowObj: Row, property: string) {
+ if (!activeCell.value) return
+ await saveRowProperty(activeCell.value, rowObj, property)
+}
+
+async function onCellSave() {
+ if (!activeCell.value || !activeCellRow.value) return
+ await saveRowProperty(activeCell.value, activeCellRow.value, activeCell.value.column.title)
+}
+
+async function saveRowProperty(cell: NonNullable<typeof activeCell.value>, rowObj: Row, property: string) {
+ const newVal = rowObj.row[property]
+ const oldVal = rowObj.oldRow[property]
+
+ if (newVal === oldVal) return
+
+ const depthMeta = getMetaForDepth(cell.depth)
+ if (!depthMeta) return
+
+ const rowId = extractPkFromRow(rowObj.row, depthMeta.columns as ColumnType[])
+ if (!rowId) return
+
+ try {
+ const updatedRowData = await $api.dbTableRow.update(
+ NOCO,
+ depthMeta.base_id as string,
+ depthMeta.id as string,
+ encodeURIComponent(rowId),
+ {
+ [property]: newVal ?? null,
+ },
+ )
+
+ const cached = cachedRows.value.get(cell.rowIndex)
+ if (cached) {
+ Object.assign(cached, updatedRowData)
+ triggerRefreshCanvas()
+ }
+ } catch (e: any) {
+ console.error('Failed to save cell:', e)
+ message.error(e.message || 'Failed to save')
+ }
+}
+
+async function savePendingCell() {
+ const save = pendingSave
+ pendingSave = null
+ if (!save?.cell || !save?.row) return
+
+ await saveRowProperty(save.cell!, save.row, save.cell!.column.title)
+}
+</script>
+
+<template>
+ <div ref="wrapperRef" class="flex flex-col w-full h-full nc-outline-view-wrapper bg-nc-bg-gray-extralight">
+ <div v-if="!isConfigured" class="flex flex-col items-center justify-center h-full gap-6 p-8">
+ <GeneralIcon class="text-nc-content-orange-dark w-16 h-16" icon="alertTriangleSolid" />
+ <div class="text-xl font-semibold text-nc-content-gray">Hierarchy Not Configured</div>
+ <div class="text-sm text-nc-content-gray-muted">
+ Use <span class="font-medium text-nc-content-gray">Set Levels</span> in the toolbar to configure your outline view
+ hierarchy.
+ </div>
+ </div>
+
+ <template v-else>
+ <Scroller
+ ref="scroller"
+ class="relative flex-1"
+ :scroll-height="totalHeight"
+ :scroll-width="totalWidth"
+ :height="height"
+ :width="width"
+ :inset="50"
+ @scroll="handleScroll"
+ >
+ <div
+ class="sticky top-0 left-0"
+ :style="{
+ height: `${totalHeight}px`,
+ width: `${totalWidth}px`,
+ }"
+ >
+ <Teleport to="body">
+ <Transition name="tooltip">
+ <Tooltip v-if="tooltipStore.tooltipText" ref="tooltipRef" :tooltip-style="floatingStyles" />
+ </Transition>
+ </Teleport>
+ <NcDropdown
+ v-model:visible="isContextMenuOpen"
+ :trigger="['contextmenu']"
+ overlay-class-name="nc-dropdown-grid-context-menu"
+ >
+ <canvas
+ ref="canvasRef"
+ class="sticky top-0 left-0"
+ :height="`${height}px`"
+ :width="`${width}px`"
+ oncontextmenu="return false"
+ @mousedown="handleCanvasMouseDown"
+ @click="handleCanvasClick"
+ @mousemove="handleCanvasMouseMove"
+ @mouseleave="handleCanvasMouseLeave"
+ />
+ <template #overlay>
+ <NcMenu>
+ <NcMenuItem> This is context menu </NcMenuItem>
+ </NcMenu>
+ </template>
+ </NcDropdown>
+
+ <div
+ v-if="activeCell && activeCellRow"
+ :style="activeCellStyle"
+ class="nc-outline-active-cell pointer-events-auto rounded bg-white"
+ >
+ <SmartsheetRow :row="activeCellRow">
+ <template #default>
+ <SmartsheetVirtualCell
+ v-if="isVirtualCol(activeCell.column.columnObj)"
+ v-model="activeCellRow.row[activeCell.column.title]"
+ :column="activeCell.column.columnObj"
+ :row="activeCellRow"
+ active
+ @save="onVirtualCellSave"
+ />
+ <SmartsheetCell
+ v-else
+ :model-value="activeCellRow.row[activeCell.column.title]"
+ :column="activeCell.column.columnObj"
+ active
+ edit-enabled
+ @update:model-value="onCellValueUpdate"
+ @save="onCellSave"
+ />
+ </template>
+ </SmartsheetRow>
+ </div>
+ </div>
+ </Scroller>
+ </template>
+ </div>
+
+ <Suspense>
+ <LazySmartsheetExpandedForm
+ v-if="expandedFormRow && expandedFormDlg"
+ v-model="expandedFormDlg"
+ :row="expandedFormRow"
+ :load-row="!isPublicView"
+ :state="expandedFormRowState"
+ :meta="expandedFormMeta || meta"
+ use-meta-fields
+ />
+ </Suspense>
+ <Suspense>
+ <LazySmartsheetExpandedForm
+ v-if="expandedFormOnRowIdDlg && (expandedFormMeta?.id || meta?.id)"
+ v-model="expandedFormOnRowIdDlg"
+ :row="expandedFormRow ?? { row: {}, oldRow: {}, rowMeta: {} }"
+ :meta="expandedFormMeta || meta"
+ :load-row="!isPublicView"
+ :row-id="route.query.rowId"
+ :expand-form="expandForm"
+ use-meta-fields
+ />
+ </Suspense>
+</template>
+
+<style scoped lang="scss">
+:deep(.custom-scrollbar-track.vertical) {
+ bottom: 4px;
+}
+:deep(.custom-scrollbar-track.horizontal) {
+ bottom: 4px;
+}
+.nc-outline-active-cell {
+ box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.32), 0px 0px 3px rgba(0, 0, 0, 0.11), 0px 1px 4px rgba(0, 0, 0, 0.12);
+ border: 1px solid var(--nc-border-gray-medium);
+ display: flex;
+ align-items: center;
+ padding: 0 8px;
+ overflow: hidden;
+}
+</style>
diff --git a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
index b9ca46183b..3abfcc6746 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilter.vue
@@ -4,6 +4,7 @@ import {
type FilterType,
ViewSettingOverrideOptions,
isCreatedOrLastModifiedTimeCol,
+ isHiddenCol,
isSystemColumn,
isVirtualCol,
} from 'nocodb-sdk'
@@ -141,23 +142,53 @@ const {
isForm,
eventBus,
allFilters: smartsheetAllFilters,
+ isOutline,
} = widget.value || workflow.value || rlsPolicyId?.value
? {
nestedFilters: ref([]),
isForm: ref(false),
eventBus: null,
allFilters: ref([]),
+ isOutline: ref(false),
}
: useSmartsheetStoreOrThrow()
+const outlineViewStore = isOutline.value ? useOutlineViewStoreOrThrow() : undefined
+const isOutlineConfigured = computed(
+ () => (outlineViewStore?.isConfigured.value ?? false) && (outlineViewStore?.levels.value?.length ?? 0) > 1,
+)
+
+const levelId = computed(() =>
+ isOutline.value && isOutlineConfigured.value ? outlineViewStore?.selectedLevelId.value : undefined,
+)
+
+const { getMetaByKey } = useMetas()
+
const currentFilters = modelValue.value || (!link.value && !webHook.value && !workflow.value && nestedFilters.value) || []
-const columns = computed(() => meta.value?.columns || [])
+const columns = computed(() => {
+ if (isOutline.value && isOutlineConfigured.value && outlineViewStore?.selectedLevel.value) {
+ const level = outlineViewStore.selectedLevel.value
+ if (level.fk_model_id && level.fk_model_id !== meta.value?.id) {
+ const tableMeta = getMetaByKey(meta.value?.base_id, level.fk_model_id)
+ return tableMeta?.columns || []
+ }
+ }
+ return meta.value?.columns || []
+})
+
+const { showSystemFields } =
+ widget.value || workflow.value || rlsPolicyId?.value ? { showSystemFields: ref(false) } : useViewColumnsOrThrow()
const fieldsToFilter = computed(() =>
columns.value.filter((c) => {
if ((link.value || workflow.value) && isSystemColumn(c) && !c.pk && !isCreatedOrLastModifiedTimeCol(c)) return false
+ if (isSystemColumn(c)) {
+ if (isHiddenCol(c, meta.value)) return false
+ if (!showSystemFields.value) return false
+ }
+
const customFilter = props.filterOption ? props.filterOption(c) : true
return !excludedFilterColUidt.includes(c.uidt as UITypes) && customFilter
@@ -495,7 +526,8 @@ const scrollDownIfNeeded = () => {
* (e.g. AI-generated filters, copy-paste filters).
*/
const addFilter = async (filter?: Partial<FilterType>, isCopyFilter = false) => {
- await _addFilter(false, filter)
+ const draft = levelId.value && !nested.value ? { ...(filter ?? {}), fk_level_id: levelId.value } : filter
+ await _addFilter(false, draft)
if (filter && !isCopyFilter) {
selectFilterField(filters.value[filters.value.length - 1], filters.value.length - 1)
@@ -512,7 +544,8 @@ const addFilter = async (filter?: Partial<FilterType>, isCopyFilter = false) =>
}
const addFilterGroup = async (filter?: Partial<FilterType>) => {
- await _addFilterGroup(filter)
+ const draft = levelId.value && !nested.value ? { ...(filter ?? {}), fk_level_id: levelId.value } : filter
+ await _addFilterGroup(draft)
if (!nested.value) {
// if nested, scroll to bottom
@@ -628,7 +661,13 @@ watch(
},
)
-const visibleFilters = computed(() => filters.value.filter((filter) => filter.status !== 'delete'))
+const visibleFilters = computed(() =>
+ filters.value.filter((filter) => {
+ if (filter.status === 'delete') return false
+ if (levelId.value && !nested.value) return (filter as any).fk_level_id === levelId.value
+ return true
+ }),
+)
const isLogicalOpChangeAllowed = computed(() => {
return new Set(visibleFilters.value.slice(1).map((filter) => filter.logical_op)).size > 1
@@ -1474,7 +1513,7 @@ defineExpose({
</NcButton>
<NcTooltip
- v-if="!filter.readOnly && !readOnly && isEeUI && isViewFilter && !filter.is_group && !webHook && !link && !widget"
+ v-if="!filter.readOnly && !readOnly && isEeUI && isViewFilter && !filter.is_group && !webHook && !link && !widget && !isOutline"
>
<template #title>
{{ getPinTooltip(filter) }}
diff --git a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
index 3793a84b2f..c2a891dc10 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
@@ -110,7 +110,11 @@ const queryFilterOpen = ref(false)
const viewFilterOpen = ref(true)
const smartsheetEventListener = async (event: string, payload?: any) => {
- if (validateViewConfigOverrideEvent(event, ViewSettingOverrideOptions.FILTER_CONDITION, payload) && activeView?.value?.id) {
+ if (
+ (event === SmartsheetStoreEvents.FILTER_RELOAD ||
+ validateViewConfigOverrideEvent(event, ViewSettingOverrideOptions.FILTER_CONDITION, payload)) &&
+ activeView?.value?.id
+ ) {
await loadFilters({
hookId: undefined,
isWebhook: false,
diff --git a/packages/nc-gui/components/smartsheet/toolbar/CreateSort.vue b/packages/nc-gui/components/smartsheet/toolbar/CreateSort.vue
index 91d70f3f04..df29698851 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/CreateSort.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/CreateSort.vue
@@ -20,11 +20,30 @@ const activeView = inject(ActiveViewInj, ref())
const meta = inject(MetaInj, ref())
+const { isOutline } = useSmartsheetStoreOrThrow()
+
+const outlineViewStore = isOutline.value ? useOutlineViewStoreOrThrow() : undefined
+const isOutlineConfigured = computed(() => outlineViewStore?.isConfigured.value ?? false)
+
+const { getMetaByKey } = useMetas()
+
const { showSystemFields, metaColumnById } = useViewColumnsOrThrow(activeView, meta)
+const levelTableColumns = computed(() => {
+ if (!isOutline.value || !isOutlineConfigured.value || !outlineViewStore?.selectedLevel.value) {
+ return meta.value?.columns || []
+ }
+ const level = outlineViewStore.selectedLevel.value
+ if (level.fk_model_id === meta.value?.id) {
+ return meta.value?.columns || []
+ }
+ const tableMeta = getMetaByKey(meta.value?.base_id, level.fk_model_id)
+ return tableMeta?.columns || []
+})
+
const options = computed<ColumnType[]>(() =>
(
- clone(meta.value?.columns)
+ clone(levelTableColumns.value)
?.filter((c: ColumnType) => {
if (c.uidt === UITypes.Links) {
return true
diff --git a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
index 785a8e118d..08e6a1b371 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
@@ -1,5 +1,5 @@
<script lang="ts" setup>
-import type { ColumnType, GalleryType, KanbanType, LookupType } from 'nocodb-sdk'
+import type { ColumnType, GalleryType, KanbanType, ListType, LookupType } from 'nocodb-sdk'
import { UITypes, ViewTypes, isLinksOrLTAR, isSystemColumn } from 'nocodb-sdk'
import Draggable from 'vuedraggable'
@@ -50,8 +50,12 @@ const {
isLocalMode,
} = useViewColumnsOrThrow()
-const { eventBus, isDefaultView, isSqlView, isViewOperationsAllowed } = useSmartsheetStoreOrThrow()
+const { eventBus, isDefaultView, isSqlView, isViewOperationsAllowed, isOutline } = useSmartsheetStoreOrThrow()
+const outlineViewStore = isOutline.value ? useOutlineViewStoreOrThrow() : undefined
+const isOutlineConfigured = computed(
+ () => (outlineViewStore?.isConfigured.value ?? false) && (outlineViewStore?.levels.value?.length ?? 0) > 1,
+)
const isFieldsMenuReadOnly = computed(() => {
return isLocked.value || !isViewOperationsAllowed.value || (isLocalMode.value && hasViewFieldDataEditPermission.value)
})
@@ -91,9 +95,17 @@ const gridDisplayValueField = computed(() => {
})
const localFilteredFieldList = computed(() => {
- return filteredFieldList.value.filter((el) =>
+ let list = filteredFieldList.value.filter((el) =>
activeView.value?.type !== ViewTypes.CALENDAR ? el !== gridDisplayValueField.value : true,
)
+
+ // For outline view with levels configured, filter by selected level
+ if (isOutline.value && isOutlineConfigured.value && outlineViewStore?.selectedLevelId.value) {
+ const levelId = outlineViewStore.selectedLevelId.value
+ list = list.filter((field: any) => field.fk_level_id === levelId)
+ }
+
+ return list
})
const onMove = async (_event: { moved: { newIndex: number; oldIndex: number } }, undo = false) => {
@@ -284,42 +296,51 @@ const coverImageObjectFit = computed({
},
})
+const getSelectedLevelId = () => {
+ if (!isOutline.value || !isOutlineConfigured.value || !outlineViewStore?.selectedLevelId.value) {
+ return undefined
+ }
+ return outlineViewStore.selectedLevelId.value
+}
+
const onShowAll = async () => {
+ const levelId = getSelectedLevelId()
addUndo({
undo: {
fn: async () => {
- await hideAll()
+ await hideAll(undefined, levelId)
},
args: [],
},
redo: {
fn: async () => {
- await showAll()
+ await showAll(undefined, levelId)
},
args: [],
},
scope: defineViewScope({ view: activeView.value }),
})
- await showAll()
+ await showAll(undefined, levelId)
}
const onHideAll = async () => {
+ const levelId = getSelectedLevelId()
addUndo({
undo: {
fn: async () => {
- await showAll()
+ await showAll(undefined, levelId)
},
args: [],
},
redo: {
fn: async () => {
- await hideAll()
+ await hideAll(undefined, levelId)
},
args: [],
},
scope: defineViewScope({ view: activeView.value }),
})
- await hideAll()
+ await hideAll(undefined, levelId)
}
const visibleFields = computed(
@@ -338,6 +359,13 @@ const visibleFields = computed(
return false
}
+ // For outline view with levels, only include selected level's fields
+ if (isOutline.value && isOutlineConfigured.value && outlineViewStore?.selectedLevelId.value) {
+ if ((field as any).fk_level_id !== outlineViewStore.selectedLevelId.value) {
+ return false
+ }
+ }
+
return true
}) || [],
)
@@ -476,6 +504,72 @@ watch(
},
)
+const prefixColumnOptions = ref<SelectProps['options']>([])
+
+const allowedPrefixTypes = new Set([
+ UITypes.SingleSelect,
+ UITypes.User,
+ UITypes.Checkbox,
+ UITypes.CreatedBy,
+ UITypes.LastModifiedBy,
+])
+
+const updatePrefixColumn = async (val?: string | null) => {
+ if (activeView.value?.type === ViewTypes.OUTLINE && activeView.value?.id && activeView.value?.view) {
+ await updateViewMeta(activeView.value.id, ViewTypes.OUTLINE, {
+ fk_prefix_column_id: val,
+ })
+ }
+}
+
+const prefixColumnId = computed({
+ get: () => {
+ if (activeView.value?.type !== ViewTypes.OUTLINE || !activeView.value?.view) return undefined
+
+ const fk_prefix_column_id = (activeView.value.view as ListType).fk_prefix_column_id
+
+ if (prefixColumnOptions.value?.find((o) => o.value === fk_prefix_column_id)) return fk_prefix_column_id
+ return fk_prefix_column_id === null ? null : undefined
+ },
+ set: async (val) => {
+ if (val !== prefixColumnId.value) {
+ addUndo({
+ undo: {
+ fn: updatePrefixColumn,
+ args: [prefixColumnId.value],
+ },
+ redo: {
+ fn: updatePrefixColumn,
+ args: [val],
+ },
+ scope: defineViewScope({ view: activeView.value }),
+ })
+
+ await updatePrefixColumn(val)
+ }
+ },
+})
+
+watch(
+ fields,
+ (newValue) => {
+ if (!newValue || isPublic.value || activeView.value?.type !== ViewTypes.OUTLINE) return
+
+ const filterFields =
+ newValue
+ .filter((el) => el.fk_column_id && allowedPrefixTypes.has(metaColumnById.value[el.fk_column_id]?.uidt as UITypes))
+ .map((field) => ({
+ value: field.fk_column_id,
+ label: field.title,
+ })) ?? []
+
+ prefixColumnOptions.value = [{ value: null, label: t('labels.noPrefix') }, ...filterFields]
+ },
+ {
+ immediate: true,
+ },
+)
+
const addColumnDropdown = ref(false)
const openSubmenusCount = ref(0)
@@ -692,6 +786,64 @@ const onAddColumnDropdownVisibilityChange = () => {
</div>
</div>
+ <!--
+ <div v-if="!isPublic && isOutline" class="flex items-center gap-2 p-2 w-80 border-b-1 border-nc-border-gray-light">
+ <div class="pl-2 flex text-sm select-none text-nc-content-gray-subtle2">{{ $t('labels.prefixField') }}</div>
+
+ <div
+ class="flex-1 nc-dropdown-prefix-column-wrapper flex items-stretch border-1 border-nc-border-gray-medium rounded-lg transition-all duration-0.3s"
+ :class="{
+ 'nc-disabled': isFieldsMenuReadOnly,
+ }"
+ >
+ <a-select
+ v-model:value="prefixColumnId"
+ class="flex-1 w-full"
+ dropdown-class-name="nc-dropdown-prefix-column !rounded-lg"
+ :bordered="false"
+ :disabled="isFieldsMenuReadOnly"
+ @click.stop
+ >
+ <template #suffixIcon><GeneralIcon class="text-nc-content-gray-subtle" icon="arrowDown" /></template>
+
+ <a-select-option v-for="option of prefixColumnOptions" :key="option.value" :value="option.value">
+ <div class="w-full flex gap-2 items-center justify-between max-w-[400px]">
+ <div
+ class="flex-1 flex items-center gap-1"
+ :class="{
+ 'max-w-[calc(100%_-_20px)]': prefixColumnId === option.value,
+ 'max-w-full': prefixColumnId !== option.value,
+ }"
+ >
+ <SmartsheetHeaderIcon
+ v-if="option.value && metaColumnById[option.value]"
+ :column="metaColumnById[option.value]"
+ class="!w-3.5 !h-3.5 !ml-0"
+ color="text-nc-content-gray-subtle"
+ />
+
+ <NcTooltip class="flex-1 max-w-[calc(100%_-_20px)] truncate" show-on-truncate-only>
+ <template #title>
+ {{ option.label }}
+ </template>
+ <template #default>{{ option.label }}</template>
+ </NcTooltip>
+ </div>
+ <GeneralIcon
+ v-if="prefixColumnId === option.value"
+ id="nc-selected-item-icon"
+ icon="check"
+ class="flex-none text-nc-content-brand w-4 h-4"
+ />
+ </div>
+ </a-select-option>
+ </a-select>
+ </div>
+ </div>
+-->
+ <div v-if="isOutline && isOutlineConfigured" class="px-2 py-2 border-b-1">
+ <SmartsheetToolbarOutlineLevelSelector />
+ </div>
<div class="py-2" @click.stop>
<a-input
ref="fieldsMenuSearchRef"
@@ -985,6 +1137,16 @@ const onAddColumnDropdownVisibilityChange = () => {
@apply shadow-selected border-nc-border-brand;
}
}
+.nc-dropdown-prefix-column-wrapper {
+ @apply h-8;
+
+ &:not(.nc-disabled):not(:focus-within) {
+ @apply shadow-default hover:shadow-hover;
+ }
+ &:not(.nc-disabled):focus-within {
+ @apply shadow-selected border-nc-border-brand;
+ }
+}
:deep(.ant-input-affix-wrapper) {
&:not(.ant-input-affix-wrapper-disabled):not(.ant-input-affix-wrapper-focused):not(:focus) {
@@ -995,4 +1157,13 @@ const onAddColumnDropdownVisibilityChange = () => {
@apply border-nc-border-brand shadow-selected;
}
}
+
+:deep(.selector-level) {
+ &:has(.level-three) {
+ @apply max-w-24.5;
+ }
+ &:has(.level-two) {
+ @apply max-w-23;
+ }
+}
</style>
diff --git a/packages/nc-gui/components/smartsheet/toolbar/Outline/LevelSelector.vue b/packages/nc-gui/components/smartsheet/toolbar/Outline/LevelSelector.vue
new file mode 100644
index 0000000000..f3992318ce
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/toolbar/Outline/LevelSelector.vue
@@ -0,0 +1,35 @@
+<script setup lang="ts">
+const { levels, selectedLevelId, setSelectedLevel } = useOutlineViewStoreOrThrow()
+
+const meta = inject(MetaInj, ref())
+const { getMetaByKey } = useMetas()
+
+function getTableTitle(tableId?: string) {
+ if (!tableId) return 'Unknown'
+ const baseId = meta.value?.base_id
+ const tableMeta = getMetaByKey(baseId, tableId)
+ return tableMeta?.title || 'Unknown'
+}
+</script>
+
+<template>
+ <div v-if="levels.length > 0" class="flex items-center gap-1">
+ <div
+ v-for="(level, index) in levels"
+ :key="level.id || index"
+ class="flex items-center gap-1 px-2 selector-level py-1 overflow-hidden rounded-md text-xs font-medium cursor-pointer transition-colors"
+ :class="{
+ 'bg-nc-bg-brand text-nc-content-brand': selectedLevelId === level.id,
+ 'bg-nc-bg-gray-light text-nc-content-gray-muted hover:bg-nc-bg-gray-medium': selectedLevelId !== level.id,
+ 'level-two': levels.length === 2,
+ 'level-three': levels.length === 3,
+ }"
+ @click="setSelectedLevel(level.id ?? null)"
+ >
+ <NcTooltip show-on-truncate-only class="truncate">
+ Level {{ index + 1 }} - {{ getTableTitle(level.fk_model_id) }}
+ <template #title> Level {{ index + 1 }} - {{ getTableTitle(level.fk_model_id) }} </template>
+ </NcTooltip>
+ </div>
+ </div>
+</template>
diff --git a/packages/nc-gui/components/smartsheet/toolbar/Outline/SetLevels.vue b/packages/nc-gui/components/smartsheet/toolbar/Outline/SetLevels.vue
new file mode 100644
index 0000000000..77635bc06b
--- /dev/null
+++ b/packages/nc-gui/components/smartsheet/toolbar/Outline/SetLevels.vue
@@ -0,0 +1,331 @@
+<script setup lang="ts">
+import type { ColumnType, LinkToAnotherRecordType, ListViewLevelType, TableType } from 'nocodb-sdk'
+import { RelationTypes, isLinksOrLTAR } from 'nocodb-sdk'
+
+const meta = inject(MetaInj, ref())
+
+const isPublic = inject(IsPublicInj, ref(false))
+
+const isLocked = inject(IsLockedInj, ref(false))
+
+const isToolbarIconMode = inject(
+ IsToolbarIconMode,
+ computed(() => false),
+)
+
+const { eventBus } = useSmartsheetStoreOrThrow()
+
+const { levels, saveLevelConfiguration, showEmptyParents, updateViewMeta, isLoading } = useOutlineViewStoreOrThrow()
+
+const open = ref(false)
+
+useMenuCloseOnEsc(open)
+
+const localLevels = ref<Partial<ListViewLevelType>[]>([])
+
+watch(open, (val) => {
+ if (val) {
+ if (levels.value.length > 0) {
+ localLevels.value = levels.value.map((l) => ({ ...l }))
+ } else {
+ localLevels.value = [{ level: 0, fk_model_id: meta.value?.id }]
+ }
+ }
+})
+
+const displayOrder = computed(() => {
+ return localLevels.value.map((_, i) => i).reverse()
+})
+
+const canAddLevel = computed(() => {
+ if (localLevels.value.length >= 3) return false
+ if (localLevels.value.length === 0) return true
+
+ return localLevels.value.every((level, idx) => {
+ if (!level.fk_model_id) return false
+ return !(idx > 0 && !level.fk_link_column_id)
+ })
+})
+
+function filterTableForLevel(arrayIndex: number): (table: TableType) => boolean {
+ return (table: TableType) => {
+ const sourceId = meta.value?.source_id
+ if (sourceId && table.source_id !== sourceId) return false
+
+ const usedTableIds = new Set(
+ localLevels.value
+ .filter((_, i) => i !== arrayIndex)
+ .map((l) => l.fk_model_id)
+ .filter(Boolean),
+ )
+ return !usedTableIds.has(table.id!)
+ }
+}
+
+// Filter: only HM link columns pointing to the target table (level below)
+function filterLinkColumnForLevel(targetTableId: string | undefined) {
+ return (c: ColumnType) => {
+ if (!isLinksOrLTAR(c) || c.system) return false
+ const colOptions = c.colOptions as LinkToAnotherRecordType | undefined
+ if (!colOptions) return false
+ if (colOptions.type !== RelationTypes.HAS_MANY) return false
+ if (targetTableId && colOptions.fk_related_model_id !== targetTableId) return false
+ return true
+ }
+}
+
+function onTableSelect(arrayIndex: number, tableId: string | null | undefined) {
+ if (!tableId) return
+ localLevels.value[arrayIndex].fk_model_id = tableId
+ localLevels.value[arrayIndex].fk_link_column_id = undefined
+}
+
+function addLevel() {
+ if (!canAddLevel.value) return
+ localLevels.value.push({ level: localLevels.value.length })
+}
+
+function removeLevel(arrayIndex: number) {
+ if (arrayIndex === 0) return
+ localLevels.value.splice(arrayIndex, 1)
+ localLevels.value.forEach((l, i) => {
+ l.level = i
+ })
+}
+
+async function save() {
+ if (isLocked.value) return
+
+ try {
+ const cleanedLevels = localLevels.value.map((l) => {
+ const clean: Partial<ListViewLevelType> = {
+ level: l.level,
+ fk_model_id: l.fk_model_id,
+ }
+ if (l.fk_link_column_id) clean.fk_link_column_id = l.fk_link_column_id
+ if (l.fk_self_link_column_id) clean.fk_self_link_column_id = l.fk_self_link_column_id
+ if (l.wrap_headers != null) clean.wrap_headers = l.wrap_headers
+ if (l.enable_nested_records != null) clean.enable_nested_records = l.enable_nested_records
+ return clean
+ })
+
+ await saveLevelConfiguration({
+ levels: cleanedLevels as ListViewLevelType[],
+ })
+
+ await nextTick()
+
+ if (levels.value.length > 0) {
+ localLevels.value = levels.value.map((l) => ({ ...l }))
+ }
+
+ eventBus.emit(SmartsheetStoreEvents.FIELD_RELOAD)
+ eventBus.emit(SmartsheetStoreEvents.SORT_RELOAD)
+ eventBus.emit(SmartsheetStoreEvents.FILTER_RELOAD)
+ } catch (e) {
+ console.error('Error saving level configuration:', e)
+ }
+}
+
+async function toggleHideEmptySections(val: boolean) {
+ if (isLocked.value) return
+ await updateViewMeta({ show_empty_parents: !val })
+}
+
+const hideEmptySections = computed({
+ get: () => !showEmptyParents.value,
+ set: (val: boolean) => {
+ toggleHideEmptySections(val)
+ },
+})
+
+const isConfigValid = computed(() => {
+ if (localLevels.value.length === 0) return false
+ return localLevels.value.every((level, idx) => {
+ if (!level.fk_model_id) return false
+ if (idx > 0 && !level.fk_link_column_id) return false
+ return true
+ })
+})
+
+const isDirty = computed(() => {
+ return JSON.stringify(localLevels.value) !== JSON.stringify(levels.value.map((l) => ({ ...l })))
+})
+</script>
+
+<template>
+ <NcDropdown
+ v-if="!isPublic"
+ v-model:visible="open"
+ :trigger="['click']"
+ overlay-class-name="nc-dropdown-outline-set-levels-menu overflow-hidden"
+ class="!xs:hidden"
+ >
+ <NcTooltip :disabled="!isToolbarIconMode" class="nc-outline-set-levels-btn">
+ <template #title>
+ {{ $t('title.setLevels') }}
+ </template>
+
+ <NcButton
+ v-e="['c:outline:set-levels']"
+ class="nc-outline-set-levels-menu-btn nc-toolbar-btn !border-0 !h-7 group"
+ size="small"
+ type="secondary"
+ :show-as-disabled="isLocked"
+ >
+ <div class="flex items-center gap-2">
+ <GeneralIcon icon="layers" class="h-4 w-4" />
+ <div v-if="!isToolbarIconMode" class="flex items-center gap-0.5">
+ <span class="text-capitalize !text-[13px] font-medium">
+ {{ $t('title.setLevels') }}
+ </span>
+ <div
+ v-if="levels.length > 0"
+ class="flex items-center rounded-md transition-colors duration-0.3s bg-nc-bg-gray-light px-1 min-h-5"
+ :class="{
+ 'group-hover:bg-nc-bg-gray-medium': !isLocked,
+ }"
+ >
+ <span class="!text-[13px] font-medium !leading-5">{{ levels.length }}</span>
+ </div>
+ </div>
+ </div>
+ </NcButton>
+ </NcTooltip>
+
+ <template #overlay>
+ <div v-if="open" class="p-4 w-96 bg-nc-bg-default nc-table-toolbar-menu rounded-lg flex flex-col gap-4" @click.stop>
+ <div class="flex items-center justify-between">
+ <span class="text-sm font-semibold text-nc-content-gray">
+ {{ $t('title.levels') }}
+ </span>
+ <NcButton
+ v-if="localLevels.length < 3"
+ type="text"
+ size="xs"
+ class="!text-nc-content-gray-subtle !text-xs"
+ :disabled="isLocked"
+ @click="addLevel"
+ >
+ <div
+ :class="{
+ 'text-nc-content-gray-disabled': isLocked || !canAddLevel,
+ }"
+ class="flex items-center gap-1"
+ >
+ <GeneralIcon icon="plus" class="w-3.5 h-3.5" />
+ <span>{{ $t('general.addLevelAbove') }}</span>
+ </div>
+ </NcButton>
+ </div>
+
+ <div class="border-t border-nc-border-gray-medium" />
+ <div class="flex flex-col">
+ <template v-for="(arrIdx, displayIdx) in displayOrder" :key="arrIdx">
+ <div class="flex flex-col gap-2 p-3 rounded-lg border border-nc-border-gray-medium">
+ <div class="flex items-center justify-between">
+ <span class="text-[11px] font-semibold text-nc-content-gray-muted uppercase tracking-wide">
+ {{ $t('general.levelN', { n: arrIdx + 1 }) }}
+ </span>
+ <NcTooltip v-if="arrIdx === 0">
+ <template #title>
+ {{ $t('tooltip.levelOneTable') }}
+ </template>
+ <GeneralIcon icon="info" class="w-3.5 h-3.5 text-nc-content-gray-muted" />
+ </NcTooltip>
+ <NcButton
+ v-else
+ type="text"
+ size="xxs"
+ class="!text-nc-content-gray-muted hover:!text-nc-content-red-dark"
+ :disabled="isLocked"
+ @click="removeLevel(arrIdx)"
+ >
+ <GeneralIcon icon="close" class="w-3.5 h-3.5" />
+ </NcButton>
+ </div>
+
+ <!-- Table selection -->
+ <NcListTableSelector
+ disable-label
+ :value="localLevels[arrIdx].fk_model_id"
+ :disabled="isLocked || arrIdx === 0"
+ :filter-table="filterTableForLevel(arrIdx)"
+ @update:value="(val) => onTableSelect(arrIdx, val)"
+ />
+ </div>
+
+ <!-- Link connector between levels (dashed line + link field selector) -->
+ <div v-if="displayIdx < displayOrder.length - 1" class="nc-level-connector flex items-stretch ml-7">
+ <div class="w-0 border-l-2 border-dashed border-nc-border-gray-medium" />
+ <div class="py-2 pl-4 flex-1">
+ <NcListColumnSelector
+ disable-label
+ :table-id="localLevels[arrIdx]?.fk_model_id"
+ :value="localLevels[arrIdx].fk_link_column_id"
+ :disabled="isLocked || !localLevels[arrIdx]?.fk_model_id || !localLevels[arrIdx - 1]?.fk_model_id"
+ :filter-column="filterLinkColumnForLevel(localLevels[arrIdx - 1]?.fk_model_id)"
+ @update:value="
+ (val) => {
+ localLevels[arrIdx].fk_link_column_id = val
+ }
+ "
+ />
+ </div>
+ </div>
+ </template>
+ </div>
+
+ <!-- Enable nested records (for root level) -->
+ <!--
+ <template v-if="localLevels.length > 0">
+ <div class="flex items-center gap-1">
+ <NcSwitch v-model:checked="enableNestedRecords" size="small" class="nc-switch" :disabled="isLocked">
+ <div class="text-sm text-nc-content-gray">
+ {{ $t('labels.enableNestedRecords') || 'Enable nested records' }}
+ </div>
+ </NcSwitch>
+ </div>
+
+ <div v-if="enableNestedRecords" class="nc-level-connector flex items-stretch ml-7">
+ <div class="w-0 border-l-2 border-dashed border-nc-border-gray-medium" />
+ <div class="py-2 pl-4 flex-1">
+ <NcListColumnSelector
+ disable-label
+ :table-id="localLevels[0]?.fk_model_id"
+ :value="localLevels[0]?.fk_self_link_column_id"
+ :disabled="isLocked"
+ :filter-column="filterSelfLinkColumn"
+ @update:value="(val) => { if (localLevels[0]) localLevels[0].fk_self_link_column_id = val }"
+ />
+ </div>
+ </div>
+ </template>
+ -->
+
+ <!-- Save button (visible when dirty) -->
+ <NcButton
+ v-if="isDirty"
+ type="primary"
+ size="small"
+ class="w-full"
+ :loading="isLoading"
+ :disabled="isLocked || !isConfigValid"
+ @click="save"
+ >
+ {{ $t('general.save') || 'Save' }}
+ </NcButton>
+
+ <!-- <div class="flex items-center gap-1 pt-1">
+ <NcSwitch v-model:checked="hideEmptySections" size="small" class="nc-switch" :disabled="isLocked">
+ <div class="text-sm text-nc-content-gray">
+ {{ $t('labels.hideEmptySections') || 'Hide empty sections' }}
+ </div>
+ </NcSwitch>
+ </div> -->
+
+ <GeneralLockedViewFooter v-if="isLocked" class="-mb-4 -mx-4" @on-open="open = false" />
+ </div>
+ </template>
+ </NcDropdown>
+</template>
diff --git a/packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue b/packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue
index 59eb8e026b..86ae25f2ba 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/RowHeight.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { type GridType, ViewTypes } from 'nocodb-sdk'
+import { type GridType, type ListType, ViewTypes } from 'nocodb-sdk'
const rowHeightOptions: { icon: keyof typeof iconMap; heightClass: string }[] = [
{
@@ -36,13 +36,30 @@ const { canUpdateViewMeta } = useViewColumnsOrThrow()
const { addUndo, defineViewScope } = useUndoRedo()
+const { isOutline } = useSmartsheetStoreOrThrow()
+
+const outlineViewStore = isOutline.value ? useOutlineViewStoreOrThrow() : undefined
+
+const isOutlineConfigured = computed(
+ () => (outlineViewStore?.isConfigured.value ?? false) && (outlineViewStore?.levels.value?.length ?? 0) > 1,
+)
+
const open = ref(false)
+const viewType = computed(() => (isOutline.value ? ViewTypes.OUTLINE : ViewTypes.GRID))
+
+const currentRowHeight = computed(() => {
+ if (isOutline.value) {
+ return (view.value?.view as ListType)?.row_height
+ }
+ return (view.value?.view as GridType)?.row_height
+})
+
const updateRowHeight = async (rh: number, undo = false) => {
if (isLocked.value) return
if (view.value?.id) {
- if (rh === (view.value.view as GridType).row_height) return
+ if (rh === currentRowHeight.value) return
if (!undo) {
addUndo({
redo: {
@@ -51,7 +68,7 @@ const updateRowHeight = async (rh: number, undo = false) => {
},
undo: {
fn: (r: number) => updateRowHeight(r, true),
- args: [(view.value.view as GridType).row_height || 0],
+ args: [currentRowHeight.value || 0],
},
scope: defineViewScope({ view: view.value }),
})
@@ -60,7 +77,7 @@ const updateRowHeight = async (rh: number, undo = false) => {
try {
await updateViewMeta(
view.value.id,
- ViewTypes.GRID,
+ viewType.value,
{
row_height: rh,
},
@@ -76,6 +93,21 @@ const updateRowHeight = async (rh: number, undo = false) => {
}
}
+const wrapHeaders = computed({
+ get: () => {
+ if (!isOutline.value || !outlineViewStore?.selectedLevel.value) return false
+ return !!outlineViewStore.selectedLevel.value.wrap_headers
+ },
+ set: async (val: boolean) => {
+ if (isLocked.value || !view.value?.id || !isOutline.value || !outlineViewStore?.selectedLevel.value) return
+
+ const updatedLevels = outlineViewStore.levels.value.map((l) =>
+ l.id === outlineViewStore!.selectedLevel.value?.id ? { ...l, wrap_headers: val } : { ...l },
+ )
+ await outlineViewStore.saveLevelConfiguration({ levels: updatedLevels })
+ },
+})
+
useMenuCloseOnEsc(open)
</script>
@@ -121,11 +153,24 @@ useMenuCloseOnEsc(open)
</div>
<component
:is="iconMap.check"
- v-if="i === 0 ? !(view?.view as GridType).row_height: (view?.view as GridType).row_height === i"
+ v-if="i === 0 ? !currentRowHeight : currentRowHeight === i"
class="text-primary w-4 h-4"
/>
</div>
</div>
+ <!-- <template v-if="isOutline">
+ <div class="border-t border-nc-border-gray-medium">
+ <SmartsheetToolbarOutlineLevelSelector v-if="isOutlineConfigured" class="py-2" />
+ <div class="flex items-center px-2">
+ <NcSwitch v-model:checked="wrapHeaders" size="small" class="nc-switch" :disabled="isLocked">
+ <div class="text-sm text-nc-content-gray">
+ {{ $t('labels.wrapHeaders') || 'Wrap headers' }}
+ </div>
+ </NcSwitch>
+ </div>
+ </div>
+ </template> -->
+
<GeneralLockedViewFooter v-if="isLocked" class="-mx-1.5 -mb-1.5" @on-open="open = false" />
</div>
</template>
diff --git a/packages/nc-gui/components/smartsheet/toolbar/SearchData.vue b/packages/nc-gui/components/smartsheet/toolbar/SearchData.vue
index e44a065023..6a4e20bfcf 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/SearchData.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/SearchData.vue
@@ -9,7 +9,7 @@ const activeView = inject(ActiveViewInj, ref())
const { $e } = useNuxtApp()
-const { meta, eventBus, isGrid, isGallery, totalRowsWithSearchQuery, totalRowsWithoutSearchQuery, gridEditEnabled } =
+const { meta, eventBus, isGrid, isGallery, isOutline, totalRowsWithSearchQuery, totalRowsWithoutSearchQuery, gridEditEnabled } =
useSmartsheetStoreOrThrow()
const { lastOpenedViewId } = storeToRefs(useViewsStore())
@@ -24,6 +24,16 @@ const { search, loadFieldQuery } = useFieldQuery()
const { isMobileMode } = useGlobal()
+const outlineViewStore = isOutline.value ? useOutlineViewStoreOrThrow() : undefined
+const { getMetaByKey } = useMetas()
+
+function getTableTitle(tableId?: string) {
+ if (!tableId) return 'Unknown'
+ const baseId = (meta.value as TableType)?.base_id
+ const tableMeta = getMetaByKey(baseId, tableId)
+ return tableMeta?.title || 'Unknown'
+}
+
const isDropdownOpen = ref(false)
const showSearchBox = ref(!!isMobileMode.value)
@@ -49,7 +59,17 @@ const isSearchResultVisible = computed(() => {
)
})
-const columns = computed(() => (meta.value as TableType)?.columns?.filter((column) => isSearchableColumn(column)) ?? [])
+const columns = computed(() => {
+ if (isOutline.value && outlineViewStore?.selectedLevel.value?.fk_model_id) {
+ const levelTableId = outlineViewStore.selectedLevel.value.fk_model_id
+ const baseId = (meta.value as TableType)?.base_id
+ const levelMeta = getMetaByKey(baseId, levelTableId)
+ if (levelMeta?.columns) {
+ return (levelMeta.columns as ColumnType[]).filter((column) => isSearchableColumn(column))
+ }
+ }
+ return (meta.value as TableType)?.columns?.filter((column) => isSearchableColumn(column)) ?? []
+})
watch(
() => activeView.value?.id,
@@ -68,6 +88,16 @@ watch(
{ immediate: true },
)
+if (isOutline.value && outlineViewStore) {
+ watch(
+ () => outlineViewStore!.selectedLevelId.value,
+ () => {
+ search.value.field = ''
+ search.value.query = ''
+ },
+ )
+}
+
function onPressEnter() {
$e('a:view:search')
reloadData.trigger({ shouldShowLoading: false, offset: 0 })
@@ -210,6 +240,24 @@ watch(
'border-primary shadow-selected': isMobileMode && search.query.length !== 0,
}"
>
+ <div
+ v-if="isOutline && outlineViewStore && outlineViewStore.levels.value.length > 1"
+ class="flex items-center gap-1 px-2 py-1 border-b-1 border-nc-border-gray-medium"
+ >
+ <div
+ v-for="(level, index) in outlineViewStore.levels.value"
+ :key="level.id || index"
+ class="px-1.5 py-0.5 rounded text-[11px] font-medium cursor-pointer transition-colors truncate"
+ :class="{
+ 'bg-nc-bg-brand text-nc-content-brand': outlineViewStore.selectedLevelId.value === level.id,
+ 'text-nc-content-gray-muted hover:bg-nc-bg-gray-medium':
+ outlineViewStore.selectedLevelId.value !== level.id,
+ }"
+ @click="outlineViewStore.setSelectedLevel(level.id ?? null)"
+ >
+ {{ getTableTitle(level.fk_model_id) }}
+ </div>
+ </div>
<div class="flex flex-row h-8 relative">
<NcDropdown
v-model:visible="isDropdownOpen"
diff --git a/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
index 3c6d6ec79d..1beaf5d94a 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
@@ -10,7 +10,13 @@ const isLocked = inject(IsLockedInj, ref(false))
const reloadDataHook = inject(ReloadViewDataHookInj)
const isPublic = inject(IsPublicInj, ref(false))
const clone = rfdc()
-const { eventBus } = useSmartsheetStoreOrThrow()
+const { eventBus, isOutline } = useSmartsheetStoreOrThrow()
+
+const outlineViewStore = isOutline.value ? useOutlineViewStoreOrThrow() : undefined
+const isOutlineConfigured = computed(
+ () => (outlineViewStore?.isConfigured.value ?? false) && (outlineViewStore?.levels.value?.length ?? 0) > 1,
+)
+const { getMetaByKey } = useMetas()
const {
sorts,
@@ -40,8 +46,15 @@ const isRestrictedEditor = computed(() => isLocked.value || !canSyncSort.value)
// True when user is viewing a personal view they don't own
const isPersonalViewNonOwner = computed(() => view.value?.lock_type === ViewLockType.Personal && !isUserViewOwner(view.value))
-const existingSorts = computed(() => sorts.value.filter((s) => s.id))
-const localSorts = computed(() => sorts.value.filter((s) => !s.id))
+const displayedSorts = computed(() => {
+ if (!isOutline.value || !isOutlineConfigured.value || !outlineViewStore?.selectedLevelId.value) {
+ return sorts.value
+ }
+ return sorts.value.filter((s) => s.fk_level_id === outlineViewStore!.selectedLevelId.value)
+})
+
+const displayedExistingSorts = computed(() => displayedSorts.value.filter((s) => s.id))
+const displayedLocalSorts = computed(() => displayedSorts.value.filter((s) => !s.id))
const isToolbarIconMode = inject(
IsToolbarIconMode,
@@ -63,8 +76,20 @@ onBeforeUnmount(() => {
eventBus.off(smartsheetEventHandler)
})
+const levelTableColumns = computed(() => {
+ if (!isOutline.value || !isOutlineConfigured.value || !outlineViewStore?.selectedLevel.value) {
+ return meta.value?.columns || []
+ }
+ const level = outlineViewStore.selectedLevel.value
+ if (level.fk_model_id === meta.value?.id) {
+ return meta.value?.columns || []
+ }
+ const tableMeta = getMetaByKey(meta.value?.base_id, level.fk_model_id)
+ return tableMeta?.columns || []
+})
+
const columns = computed(() =>
- clone(meta.value?.columns || []).map((c) => {
+ clone(levelTableColumns.value).map((c) => {
const isDisabled = [UITypes.QrCode, UITypes.Barcode, UITypes.ID, UITypes.Button].includes(c.uidt)
if (isDisabled) {
@@ -106,7 +131,10 @@ const availableColumns = computed(() => {
/** ignore virtual fields which are system fields ( mm relation ) and qr code fields */
}
})
- .filter((c) => !((isRestrictedEditor.value ? localSorts : sorts).value ?? []).find((s) => s.fk_column_id === c.id))
+ .filter(
+ (c) =>
+ !((isRestrictedEditor.value ? displayedLocalSorts : displayedSorts).value ?? []).find((s) => s.fk_column_id === c.id),
+ )
})
const getColumnUidtByID = (key?: string) => {
@@ -121,6 +149,11 @@ const addSort = (column: ColumnType) => {
_addSort(true, column)
const createdSort = sorts.value[sorts.value.length - 1]
+
+ if (isOutline.value && outlineViewStore?.selectedLevelId.value) {
+ createdSort.fk_level_id = outlineViewStore.selectedLevelId.value
+ }
+
saveOrUpdate(createdSort, sorts.value.length - 1)
showCreateSort.value = false
@@ -196,16 +229,29 @@ watch(
'nc-locked-view': isLocked,
}"
>
+ <div
+ v-if="isOutline && isOutlineConfigured"
+ :class="{
+ 'max-w-64': !displayedSorts.length && !isPersonalViewNonOwner,
+ }"
+ class="px-2 py-2 border-b-1"
+ >
+ <SmartsheetToolbarOutlineLevelSelector />
+ </div>
<SmartsheetToolbarCreateSort
- v-if="!sorts.length && !isPersonalViewNonOwner"
- :sorts="sorts"
+ v-if="!displayedSorts.length && !isPersonalViewNonOwner"
+ :sorts="displayedSorts"
:is-parent-open="open"
@created="addSort"
/>
<div v-else class="pt-2 pb-2 pl-4 nc-filter-list max-h-[max(80vh,30rem)] min-w-102" data-testid="nc-sorts-menu">
<div class="sort-grid max-h-120 nc-scrollbar-thin pr-4 my-2 py-1" @click.stop>
<template v-if="!isRestrictedEditor">
- <div v-for="(sort, i) of sorts" :key="i" class="flex first:mb-0 !mb-1.5 !last:mb-0 items-center">
+ <div
+ v-for="sort of displayedSorts"
+ :key="sort.id || sort.fk_column_id"
+ class="flex first:mb-0 !mb-1.5 !last:mb-0 items-center"
+ >
<SmartsheetToolbarFieldListAutoCompleteDropdown
v-model="sort.fk_column_id"
class="flex caption nc-sort-field-select !w-44 flex-grow"
@@ -214,7 +260,7 @@ watch(
:meta="meta"
:disabled="false"
@click.stop
- @update:model-value="saveOrUpdate(sort, i)"
+ @update:model-value="saveOrUpdate(sort, getSortIndex(sort))"
/>
<NcSelect
@@ -224,7 +270,7 @@ watch(
dropdown-class-name="sort-dir-dropdown nc-dropdown-sort-dir !rounded-lg"
:disabled="false"
@click.stop
- @select="saveOrUpdate(sort, i)"
+ @select="saveOrUpdate(sort, getSortIndex(sort))"
>
<a-select-option
v-for="(option, j) of getSortDirectionOptions(getColumnUidtByID(sort.fk_column_id))"
@@ -252,7 +298,7 @@ watch(
:shadow="false"
:disabled="false"
class="nc-sort-item-remove-btn !max-w-8 !border-l-transparent !rounded-l-none"
- @click.stop="deleteSort(sort, i)"
+ @click.stop="deleteSort(sort, getSortIndex(sort))"
>
<component :is="iconMap.deleteListItem" />
</NcButton>
@@ -262,7 +308,11 @@ watch(
<template v-else>
<!-- Local Sorts (Editable) - hidden for personal view non-owners -->
<template v-if="!isPersonalViewNonOwner">
- <div v-for="(sort, k) of localSorts" :key="`local-${k}`" class="flex first:mb-0 !mb-1.5 !last:mb-0 items-center">
+ <div
+ v-for="(sort, k) of displayedLocalSorts"
+ :key="`local-${k}`"
+ class="flex first:mb-0 !mb-1.5 !last:mb-0 items-center"
+ >
<SmartsheetToolbarFieldListAutoCompleteDropdown
v-model="sort.fk_column_id"
class="flex caption nc-sort-field-select !w-44 flex-grow"
@@ -319,7 +369,7 @@ watch(
<!-- Existing Sorts (Read Only) -->
<div
- v-for="(sort, i) of existingSorts"
+ v-for="(sort, i) of displayedExistingSorts"
:key="`existing-${i}`"
class="flex first:mb-0 !mb-1.5 !last:mb-0 items-center opacity-70"
>
@@ -384,7 +434,7 @@ watch(
<template v-if="isEeUI && !isPublic">
<NcButton
v-if="
- (isRestrictedEditor ? localSorts.length : sorts.length) <
+ (isRestrictedEditor ? displayedLocalSorts.length : displayedSorts.length) <
getPlanLimit(PlanLimitTypes.LIMIT_SORT_PER_VIEW) + 10
"
v-e="['c:sort:add']"
@@ -424,14 +474,14 @@ watch(
</template>
<template #overlay>
<SmartsheetToolbarCreateSort
- :sorts="isRestrictedEditor ? localSorts : sorts"
+ :sorts="isRestrictedEditor ? displayedLocalSorts : displayedSorts"
:is-parent-open="showCreateSort"
@created="addSort"
/>
</template>
</NcDropdown>
<LazyGeneralCopyFromAnotherViewActionBtn
- v-if="view"
+ v-if="view && !isOutline"
:view="view"
:default-options="[ViewSettingOverrideOptions.SORT]"
@open="open = false"
@@ -441,15 +491,16 @@ watch(
<GeneralLockedViewFooter
v-if="isLocked"
:class="{
- '-mt-2': sorts.length,
+ '-mt-2': displayedSorts.length,
}"
@on-open="open = false"
/>
<div
- v-else-if="view && !sorts.length"
+ v-else-if="view && !displayedSorts.length"
class="flex items-center justify-end empty:hidden pl-3 pr-2 py-1.5 border-t-1 border-nc-border-gray-medium"
>
<LazyGeneralCopyFromAnotherViewActionBtn
+ v-if="!isOutline"
:view="view"
:default-options="[ViewSettingOverrideOptions.SORT]"
@open="open = false"
@@ -461,6 +512,15 @@ watch(
</template>
<style scoped lang="scss">
+:deep(.selector-level) {
+ &:has(.level-three) {
+ @apply max-w-20;
+ }
+ &:has(.level-two) {
+ @apply max-w-23;
+ }
+}
+
:deep(.nc-sort-field-select) {
@apply !w-44;
.ant-select-selector {
diff --git a/packages/nc-gui/components/smartsheet/topbar/ViewListDropdown.vue b/packages/nc-gui/components/smartsheet/topbar/ViewListDropdown.vue
index aa5835da6a..7df67fe87c 100644
--- a/packages/nc-gui/components/smartsheet/topbar/ViewListDropdown.vue
+++ b/packages/nc-gui/components/smartsheet/topbar/ViewListDropdown.vue
@@ -13,7 +13,7 @@ const { activeTable } = storeToRefs(useTablesStore())
const viewsStore = useViewsStore()
-const { activeView, views } = storeToRefs(viewsStore)
+const { activeView, views, isOutlineViewEnabled } = storeToRefs(viewsStore)
const { navigateToView, onOpenViewCreateModal } = viewsStore
@@ -25,6 +25,8 @@ const isSqlView = computed(() => (activeTable.value as TableType)?.type === 'vie
const isSyncedTable = computed(() => (activeTable.value as TableType)?.synced)
+const isPgSource = computed(() => activeSource.value?.type === 'pg')
+
const activeSource = computed(() => {
return base.value.sources?.find((s) => s.id === activeView.value?.source_id)
})
@@ -238,6 +240,20 @@ async function onOpenModal({
{{ $t('objects.viewType.calendar') }}
</div>
</a-menu-item>
+ <template v-if="isOutlineViewEnabled">
+ <NcTooltip :title="$t('tooltip.outlineViewOnlyPg')" :disabled="isPgSource" placement="right">
+ <a-menu-item
+ :disabled="!isPgSource"
+ data-testid="topbar-view-create-outline"
+ @click="isPgSource && onOpenModal({ type: ViewTypes.OUTLINE })"
+ >
+ <div class="nc-viewlist-submenu-popup-item" :class="{ 'opacity-50': !isPgSource }">
+ <GeneralViewIcon :meta="{ type: ViewTypes.OUTLINE }" />
+ {{ $t('objects.viewType.outline') }}
+ </div>
+ </a-menu-item>
+ </NcTooltip>
+ </template>
<template v-if="isAiFeaturesEnabled">
<NcDivider />
diff --git a/packages/nc-gui/components/tabs/Smartsheet.vue b/packages/nc-gui/components/tabs/Smartsheet.vue
index ab42bd9976..299638e9a0 100644
--- a/packages/nc-gui/components/tabs/Smartsheet.vue
+++ b/packages/nc-gui/components/tabs/Smartsheet.vue
@@ -35,10 +35,8 @@ const meta = computed<TableType | undefined>(() => {
return viewId && getMetaByKey(activeProjectId.value, viewId)
})
-const { isGallery, isGrid, isForm, isKanban, isLocked, isMap, isCalendar, xWhere, eventBus } = useProvideSmartsheetStore(
- activeView,
- meta,
-)
+const { isGallery, isGrid, isForm, isKanban, isLocked, isMap, isCalendar, isOutline, xWhere, eventBus } =
+ useProvideSmartsheetStore(activeView, meta)
useViewRowColorProvider({ view: activeView, eventBus })
@@ -57,6 +55,7 @@ const activeSource = computed(() => {
useProvideKanbanViewStore(meta, activeView)
useProvideMapViewStore(meta, activeView)
useProvideCalendarViewStore(meta, activeView, false, xWhere)
+useProvideOutlineViewStore(meta, activeView)
// todo: move to store
provide(MetaInj, meta)
@@ -305,6 +304,8 @@ watch(isViewsLoading, async () => {
<SmartsheetCalendar v-else-if="isCalendar" />
<SmartsheetMap v-else-if="isMap" />
+
+ <SmartsheetOutline v-else-if="isOutline" />
</template>
</div>
</div>
diff --git a/packages/nc-gui/composables/useBetaFeatureToggle.ts b/packages/nc-gui/composables/useBetaFeatureToggle.ts
index cd1d7f27a4..b1a417ed3a 100644
--- a/packages/nc-gui/composables/useBetaFeatureToggle.ts
+++ b/packages/nc-gui/composables/useBetaFeatureToggle.ts
@@ -219,6 +219,15 @@ const FEATURES = [
isAdvanced: true,
isEE: true,
},
+ {
+ id: 'outline_view',
+ title: 'Outline View',
+ description: 'Enable the Outline view type for hierarchical data display with parent-child grouping.',
+ enabled: false,
+ version: 1,
+ isEngineering: true,
+ isEE: true,
+ },
] as const
export const FEATURE_FLAG = Object.fromEntries(FEATURES.map((feature) => [feature.id.toUpperCase(), feature.id])) as Record<
diff --git a/packages/nc-gui/composables/useOutlineViewStore.ts b/packages/nc-gui/composables/useOutlineViewStore.ts
new file mode 100644
index 0000000000..1e6ee4de17
--- /dev/null
+++ b/packages/nc-gui/composables/useOutlineViewStore.ts
@@ -0,0 +1,158 @@
+import type { OutlineType, OutlineViewLevelType, TableType, ViewType } from 'nocodb-sdk'
+import { ViewTypes } from 'nocodb-sdk'
+
+export interface OutlineViewRow {
+ __nc_depth: number
+ __nc_pk: string | number
+ __nc_parent_id: string | null
+ __nc_row_type: string
+ __nc_descendant_count: number
+ [key: string]: any
+}
+
+const [useProvideOutlineViewStore, useOutlineViewStore] = useInjectionState(
+ (meta: Ref<TableType | undefined>, viewMeta: Ref<ViewType | undefined>) => {
+ const { updateViewMeta: _updateViewMeta } = useViewsStore()
+ const selectedLevelId = ref<string | null>(null)
+
+ const viewId = computed(() => viewMeta.value?.id)
+
+ const outlineMetaData = computed<OutlineType | undefined>(() => {
+ return viewMeta.value?.view as OutlineType | undefined
+ })
+
+ const levels = computed<OutlineViewLevelType[]>(() => {
+ return outlineMetaData.value?.levels || []
+ })
+
+ const isConfigured = computed(() => levels.value.length >= 1)
+
+ const showEmptyParents = computed(() => {
+ return outlineMetaData.value?.show_empty_parents !== false
+ })
+
+ const selectedLevel = computed<OutlineViewLevelType | undefined>(() => {
+ if (!selectedLevelId.value) return levels.value[0]
+ return levels.value.find((l) => l.id === selectedLevelId.value)
+ })
+
+ // Display levels: reversed so highest level = depth 0
+ const displayLevels = computed(() => [...levels.value].reverse())
+
+ // Map model ID -> depth index in displayLevels
+ const modelIdToDepth = computed<Record<string, number>>(() => {
+ const map: Record<string, number> = {}
+ displayLevels.value.forEach((level, idx) => {
+ if (level.fk_model_id) map[level.fk_model_id] = idx
+ })
+ return map
+ })
+
+ // Map depth index -> level ID
+ const depthToLevelId = computed<Record<number, string>>(() => {
+ const map: Record<number, string> = {}
+ displayLevels.value.forEach((level, depth) => {
+ if (level.id) map[depth] = level.id
+ })
+ return map
+ })
+
+ const collapsedParents = ref<Record<number, string[]>>({})
+
+ function setSelectedLevel(levelId: string | null) {
+ selectedLevelId.value = levelId
+ }
+
+ function toggleCollapse(depth: number, pk: string) {
+ const current = { ...collapsedParents.value }
+ const arr = current[depth] ? [...current[depth]] : []
+ const idx = arr.indexOf(pk)
+ if (idx >= 0) {
+ arr.splice(idx, 1)
+ } else {
+ arr.push(pk)
+ }
+ current[depth] = arr
+ collapsedParents.value = current
+ }
+
+ function isCollapsed(depth: number, pk: string): boolean {
+ return collapsedParents.value[depth]?.includes(pk) ?? false
+ }
+
+ async function saveLevelConfiguration(config: { levels: OutlineViewLevelType[] }) {
+ if (!viewId.value) return
+
+ try {
+ await _updateViewMeta(viewId.value, ViewTypes.OUTLINE, {
+ levels: config.levels,
+ })
+ } catch (e) {
+ console.error('Error saving level configuration:', e)
+ throw e
+ }
+ }
+
+ /** Update view meta (show_empty_parents, etc.) */
+ async function updateViewMeta(updates: Partial<OutlineType>) {
+ if (!viewId.value) return
+
+ try {
+ await _updateViewMeta(viewId.value, ViewTypes.OUTLINE, updates)
+ } catch (e) {
+ console.error('Error updating outline view meta:', e)
+ throw e
+ }
+ }
+
+ watch(
+ levels,
+ (newLevels) => {
+ if (newLevels.length > 0 && !newLevels.find((l) => l.id === selectedLevelId.value)) {
+ selectedLevelId.value = newLevels[0]?.id ?? null
+ } else if (newLevels.length === 0) {
+ selectedLevelId.value = null
+ }
+ },
+ { immediate: true },
+ )
+
+ onMounted(async () => {
+ await waitForCondition(() => levels.value?.length, 100)
+ if (levels.value.length > 0 && !levels.value.find((l) => l.id === selectedLevelId.value)) {
+ selectedLevelId.value = levels.value[0]?.id ?? null
+ } else if (levels.value.length === 0) {
+ selectedLevelId.value = null
+ }
+ })
+
+ return {
+ levels,
+ isConfigured,
+ showEmptyParents,
+ selectedLevelId,
+ selectedLevel,
+ setSelectedLevel,
+ outlineMetaData,
+ displayLevels,
+ modelIdToDepth,
+ depthToLevelId,
+ collapsedParents,
+ toggleCollapse,
+ isCollapsed,
+ saveLevelConfiguration,
+ updateViewMeta,
+ }
+ },
+ 'outlineView',
+)
+
+export { useProvideOutlineViewStore, useOutlineViewStore }
+
+export function useOutlineViewStoreOrThrow() {
+ const state = useOutlineViewStore()
+
+ if (!state) throw new Error('Please call `useProvideOutlineViewStore` on the appropriate parent component')
+
+ return state
+}
diff --git a/packages/nc-gui/composables/useSmartsheetStore.ts b/packages/nc-gui/composables/useSmartsheetStore.ts
index 03f6439462..07df51be64 100644
--- a/packages/nc-gui/composables/useSmartsheetStore.ts
+++ b/packages/nc-gui/composables/useSmartsheetStore.ts
@@ -53,6 +53,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(
const isCalendar = computed(() => view.value?.type === ViewTypes.CALENDAR)
const isKanban = computed(() => view.value?.type === ViewTypes.KANBAN)
const isMap = computed(() => view.value?.type === ViewTypes.MAP)
+ const isOutline = computed(() => view.value?.type === ViewTypes.OUTLINE)
const isSharedForm = computed(() => isForm.value && shared)
const isDefaultView = computed(() => {
const getFirstGridView = getFirstNonPersonalView(views.value, {
@@ -243,6 +244,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState(
isGallery,
isKanban,
isMap,
+ isOutline,
isCalendar,
isSharedForm,
sorts,
diff --git a/packages/nc-gui/composables/useViewColumns.ts b/packages/nc-gui/composables/useViewColumns.ts
index 67a7109704..72f1b53ac3 100644
--- a/packages/nc-gui/composables/useViewColumns.ts
+++ b/packages/nc-gui/composables/useViewColumns.ts
@@ -1,5 +1,5 @@
-import type { ButtonType, ColumnType, GridColumnReqType, GridColumnType, MapType, TableType, ViewType } from 'nocodb-sdk'
-import { CommonAggregations, ViewTypes, getFirstNonPersonalView, isHiddenCol, isSystemColumn } from 'nocodb-sdk'
+import type { ButtonType, ColumnType, GridColumnReqType, GridColumnType, MapType, OutlineType, TableType, ViewType } from 'nocodb-sdk'
+import { CommonAggregations, ViewLockType, ViewTypes, getFirstNonPersonalView, isHiddenCol, isSystemColumn } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
const [useProvideViewColumns, useViewColumns] = useInjectionState(
@@ -26,6 +26,8 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
const { $api, $e, $eventBus } = useNuxtApp()
+ const { getMeta: _getMeta, getMetaByKey: _getMetaByKey } = useMetas()
+
const { t } = useI18n()
const { isUIAllowed } = useRoles()
@@ -70,15 +72,28 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
}
const metaColumnById = computed<Record<string, ColumnType>>(() => {
- if (!meta.value?.columns) return {}
+ const result: Record<string, ColumnType> = {}
- return (meta.value.columns as ColumnType[]).reduce(
- (acc, curr) => ({
- ...acc,
- [curr.id!]: curr,
- }),
- {},
- ) as Record<string, ColumnType>
+ for (const col of (meta.value?.columns || []) as ColumnType[]) {
+ if (col.id) result[col.id] = col
+ }
+
+ // Include level table columns for outline views (from shared metas cache)
+ if (view.value?.type === ViewTypes.OUTLINE) {
+ const levels = (view.value?.view as OutlineType)?.levels || []
+ for (const level of levels) {
+ if (level.fk_model_id && level.fk_model_id !== meta.value?.id) {
+ const tableMeta = _getMetaByKey(meta.value?.base_id, level.fk_model_id)
+ if (tableMeta?.columns) {
+ for (const col of tableMeta.columns as ColumnType[]) {
+ if (col.id) result[col.id] = col
+ }
+ }
+ }
+ }
+ }
+
+ return result
})
const gridViewCols = ref<Record<string, GridColumnType>>({})
@@ -108,13 +123,56 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
}
}, {})
- fields.value = (meta.value?.columns || [])
- .filter((column: ColumnType) => {
+ // For outline views with levels, ensure metas for non-root level tables are loaded
+ if (view.value?.type === ViewTypes.OUTLINE) {
+ const levels = (view.value?.view as OutlineType)?.levels || []
+
+ for (const level of levels) {
+ if (level.fk_model_id && level.fk_model_id !== meta.value?.id) {
+ try {
+ await _getMeta(meta.value!.base_id!, level.fk_model_id)
+ } catch (e) {
+ console.error(`Failed to load meta for level table ${level.fk_model_id}:`, e)
+ }
+ }
+ }
+ }
+
+ // Build combined columns: root table + level tables (for list views)
+ const allTableColumns: { column: ColumnType; tableMeta: TableType }[] = (meta.value?.columns || []).map(
+ (col: ColumnType) => ({
+ column: col,
+ tableMeta: meta.value!,
+ }),
+ )
+
+ if (view.value?.type === ViewTypes.OUTLINE) {
+ const levels = (view.value?.view as OutlineType)?.levels || []
+ // Track existing column IDs to avoid duplicates
+ // (public views already include level columns in meta.value?.columns)
+ const existingColIds = new Set(allTableColumns.map(({ column }) => column.id))
+ for (const level of levels) {
+ if (level.fk_model_id && level.fk_model_id !== meta.value?.id) {
+ const tableMeta = _getMetaByKey(meta.value?.base_id, level.fk_model_id)
+ if (tableMeta?.columns) {
+ for (const col of tableMeta.columns as ColumnType[]) {
+ if (!existingColIds.has(col.id)) {
+ allTableColumns.push({ column: col, tableMeta })
+ existingColIds.add(col.id)
+ }
+ }
+ }
+ }
+ }
+ }
+
+ fields.value = allTableColumns
+ .filter(({ column, tableMeta }) => {
// filter created by and last modified by system columns
- if (isHiddenCol(column, meta.value)) return false
+ if (isHiddenCol(column, tableMeta)) return false
return true
})
- .map((column: ColumnType) => {
+ .map(({ column }) => {
const currentColumnField = fieldById[column.id!] || {}
return {
@@ -187,7 +245,7 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
}
}
- const showAll = async (ignoreIds?: any) => {
+ const showAll = async (ignoreIds?: any, levelId?: string) => {
if (isLocalMode.value) {
const fieldById = (fields.value || []).reduce<Record<string, any>>((acc, curr) => {
if (curr.fk_column_id) {
@@ -222,18 +280,12 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
}
if (view?.value?.id) {
- if (ignoreIds) {
- await $api.internal.postOperation(view.value.fk_workspace_id!, view.value.base_id!, {
- operation: 'showAllColumns',
- viewId: view.value.id,
- ignoreIds,
- })
- } else {
- await $api.internal.postOperation(view.value.fk_workspace_id!, view.value.base_id!, {
- operation: 'showAllColumns',
- viewId: view.value.id,
- })
- }
+ await $api.internal.postOperation(view.value.fk_workspace_id!, view.value.base_id!, {
+ operation: 'showAllColumns',
+ viewId: view.value.id,
+ ...(ignoreIds ? { ignoreIds } : {}),
+ ...(levelId ? { levelId } : {}),
+ })
if (isDefaultView.value) {
updateDefaultViewColumnMeta(undefined, { defaultViewColVisibility: true }, true)
@@ -245,7 +297,7 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
$e('a:fields:show-all')
}
- const hideAll = async (ignoreIds?: any) => {
+ const hideAll = async (ignoreIds?: any, levelId?: string) => {
if (isLocalMode.value) {
const fieldById = (fields.value || []).reduce<Record<string, any>>((acc, curr) => {
if (curr.fk_column_id) {
@@ -279,18 +331,12 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
return
}
if (view?.value?.id) {
- if (ignoreIds) {
- await $api.internal.postOperation(view.value.fk_workspace_id!, view.value.base_id!, {
- operation: 'hideAllColumns',
- viewId: view.value.id,
- ignoreIds,
- })
- } else {
- await $api.internal.postOperation(view.value.fk_workspace_id!, view.value.base_id!, {
- operation: 'hideAllColumns',
- viewId: view.value.id,
- })
- }
+ await $api.internal.postOperation(view.value.fk_workspace_id!, view.value.base_id!, {
+ operation: 'hideAllColumns',
+ viewId: view.value.id,
+ ...(ignoreIds ? { ignoreIds } : {}),
+ ...(levelId ? { levelId } : {}),
+ })
if (isDefaultView.value) {
updateDefaultViewColumnMeta(undefined, { defaultViewColVisibility: false }, true)
diff --git a/packages/nc-gui/composables/useViewFilters.ts b/packages/nc-gui/composables/useViewFilters.ts
index 37e0b2ffcc..3eaeda54cb 100644
--- a/packages/nc-gui/composables/useViewFilters.ts
+++ b/packages/nc-gui/composables/useViewFilters.ts
@@ -161,11 +161,23 @@ export function useViewFilters(
const activeView = inject(ActiveViewInj, ref())
- const { showSystemFields, fieldsMap } =
- isWidget || isWorkflow || isRlsPolicy ? { showSystemFields: ref(false), fieldsMap: ref({}) } : useViewColumnsOrThrow()
+ const {
+ showSystemFields,
+ fieldsMap,
+ metaColumnById: _metaColumnById,
+ } = isWidget || isWorkflow || isRlsPolicy
+ ? { showSystemFields: ref(false), fieldsMap: ref({}), metaColumnById: computed(() => ({} as Record<string, ColumnType>)) }
+ : useViewColumnsOrThrow()
+
+ // Use metaColumnById (includes outline view level table columns) with fallback to meta.columns
+ const allMetaColumns = computed(() => {
+ if (isLink) return meta.value?.columns || []
+ const byId = _metaColumnById.value
+ return Object.keys(byId).length ? Object.values(byId) : (meta.value?.columns as ColumnType[]) || []
+ })
const options = computed<SelectProps['options']>(() =>
- meta.value?.columns?.filter((c: ColumnType) => {
+ allMetaColumns.value.filter((c: ColumnType) => {
if (isSystemColumn(c)) {
/** hide system columns if not enabled */
return showSystemFields.value
@@ -179,11 +191,11 @@ export function useViewFilters(
)
const types = computed(() => {
- if (!meta.value?.columns?.length) {
+ if (!allMetaColumns.value.length) {
return {}
}
- return meta.value?.columns?.reduce((obj: any, col: any) => {
+ return allMetaColumns.value.reduce((obj: any, col: any) => {
if (col.uidt === UITypes.Formula) {
const formulaUIType = getEquivalentUIType({
formulaColumn: col,
@@ -1008,7 +1020,14 @@ export function useViewFilters(
// Preserve 'logical_op' from the draft when provided (e.g. AI-generated filters may use 'or'),
// otherwise normalizeFilterNode falls back to placeholderFilter's default.
{ ...placeholderFilter(), ...normalizeFilterNode(draftFilter, ['order']) }
- : placeholderFilter()) as ColumnFilterType,
+ : {
+ ...placeholderFilter(),
+ ...(draftFilter.fk_level_id
+ ? {
+ fk_level_id: draftFilter.fk_level_id,
+ }
+ : {}),
+ }) as ColumnFilterType,
)
if (!undo && !(isForm.value && !isWebhook)) {
addUndo({
@@ -1050,7 +1069,10 @@ export function useViewFilters(
const addFilterGroup = async (draftFilter: Partial<ColumnFilterType> = {}) => {
isFilterUpdated.value = true
- const placeHolderGroupFilter: ColumnFilterType = placeholderGroupFilter()
+ const placeHolderGroupFilter: ColumnFilterType = {
+ ...placeholderGroupFilter(),
+ ...(draftFilter?.fk_level_id ? { fk_level_id: draftFilter.fk_level_id } : {}),
+ } as ColumnFilterType
const draftFilterHasChildren = draftFilter && ncIsArray(draftFilter.children) && draftFilter.children.length > 0
diff --git a/packages/nc-gui/context/index.ts b/packages/nc-gui/context/index.ts
index 5be7f98d67..564f1610ea 100644
--- a/packages/nc-gui/context/index.ts
+++ b/packages/nc-gui/context/index.ts
@@ -22,6 +22,7 @@ export const IsGridInj: InjectionKey<Ref<boolean>> = Symbol('is-grid-injection')
export const IsGroupByInj: InjectionKey<Ref<boolean>> = Symbol('is-group-by-injection')
export const IsGroupByLabelInj: InjectionKey<Ref<boolean>> = Symbol('is-group-by-label-injection')
export const IsGalleryInj: InjectionKey<Ref<boolean>> = Symbol('is-gallery-injection')
+export const IsListInj: InjectionKey<Ref<boolean>> = Symbol('is-list-injection')
export const IsKanbanInj: InjectionKey<Ref<boolean>> = Symbol('is-kanban-injection')
export const IsDashboardInj: InjectionKey<Ref<boolean>> = Symbol('is-dashboard-injection')
export const IsLockedInj: InjectionKey<Ref<boolean>> = Symbol('is-locked-injection')
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json
index 7d6acf05c3..ecab9c045d 100644
--- a/packages/nc-gui/lang/en.json
+++ b/packages/nc-gui/lang/en.json
@@ -271,6 +271,9 @@
"permissionsNotAvailable": "Permissions not available",
"changeIcon": "Change Icon",
"save": "Save",
+ "addLevel": "Add Level",
+ "addLevelAbove": "Add level above",
+ "levelN": "Level {n}",
"available": "Available",
"abort": "Abort",
"saving": "Saving",
@@ -555,7 +558,8 @@
"form": "Form",
"kanban": "Kanban",
"calendar": "Calendar",
- "map": "Map"
+ "map": "Map",
+ "outline": "Outline"
},
"user": "User",
"users": "Users",
@@ -887,6 +891,9 @@
"noFiltersAdded": "No filters added",
"noFieldsSelected": "No fields selected",
"editCards": "Edit Cards",
+ "outlineView": "Outline View",
+ "setLevels": "Set Levels",
+ "levels": "Levels",
"noFieldsFound": "No fields found",
"displayValue": "Display Value",
"expand": "Expand",
@@ -1563,8 +1570,11 @@
"createFormViewPlural": "Create Form View(s)",
"duplicateKanbanView": "Duplicate Kanban View",
"duplicateCalendarView": "Duplicate Calendar View",
+ "duplicateOutlineView": "Duplicate Outline View",
"createKanbanView": "Create Kanban View",
+ "createOutlineView": "Create Outline View",
"createKanbanViewPlural": "Create Kanban View(s)",
+ "createOutlineViewPlural": "Create Outline View(s)",
"createCalendarView": "Create Calendar View",
"createCalendarViewPlural": "Create Calendar View(s)",
"createViewUsingAi": "Create View(s) using NocoAI",
@@ -1756,8 +1766,13 @@
"showThousandsSeparator": "Show thousands separator",
"signUpForFree": "Sign up for free",
"coverImageField": "Cover image",
+ "prefixField": "Prefix field",
+ "noPrefix": "No prefix",
"fitImage": "Fit image",
"coverImageArea": "Cover image",
+ "hideEmptySections": "Hide empty sections",
+ "enableNestedRecords": "Enable nested records",
+ "wrapHeaders": "Wrap headers",
"syncData": "Sync data",
"syncDataModalSubtitle": "Register the services you are interested in to get notified when they become available",
"redirectToUrl": "Redirect to URL",
@@ -2195,6 +2210,7 @@
"cantAssignLastNonPersonalView": "Cannot assign last collaborative grid view as personal view",
"includeUserHint": "The user who triggered the webhook will be included in the payload as a 'user' object.",
"crossBase": "Link records from a table in a different base",
+ "levelOneTable": "Each level corresponds to a table in your base. Level 1 must be set to the table the view was created from.",
"leaveWorkspace": "Each workspace must have at least one owner. Please assign another user as the Owner before leaving the workspace. If you are the last member, consider deleting the workspace instead.",
"currentDateNotAvail": "Current date option not available for the data source or the data type",
"privateConnection": "Enable to make this connection private and hidden from other creators in this workspace.",
@@ -2271,6 +2287,7 @@
"youDontHaveAccessToCreateNewWorkflow": "You don't have access to create new workflow",
"youDontHaveAccessToCreateNewDashboard": "You don't have access to create new dashboard",
"formViewCreationNotSupportedForSyncedTable": "Form view creation is not supported for synced table",
+ "outlineViewOnlyPg": "Outline view is only available for PostgreSQL and Default source",
"dataInThisFieldCantBeManuallyEdited": "Data in this field can't be manually edited",
"fieldPermissionsNotAvailableForSyncedColumns": "Field permissions are not available for synced field",
"viewAndEditPermissionsForAllFieldsInThisTable": "View and edit permissions for all fields in this table",
@@ -2723,7 +2740,8 @@
"form": "Add Form View",
"kanban": "Add Kanban View",
"map": "Add Map View",
- "calendar": "Add Calendar View"
+ "calendar": "Add Calendar View",
+ "outline": "Add Outline View"
},
"tablesMetadataInSync": "Tables metadata is in Sync",
"addMultipleUsers": "You can add multiple comma(,) separated emails",
diff --git a/packages/nc-gui/pages/index/[typeOrId]/outline/[viewId]/index.vue b/packages/nc-gui/pages/index/[typeOrId]/outline/[viewId]/index.vue
new file mode 100644
index 0000000000..c7cc0b25b1
--- /dev/null
+++ b/packages/nc-gui/pages/index/[typeOrId]/outline/[viewId]/index.vue
@@ -0,0 +1,44 @@
+<script setup lang="ts">
+import { ViewTypes } from 'nocodb-sdk'
+
+definePageMeta({
+ public: true,
+ requiresAuth: false,
+ layout: 'shared-view',
+ hasSidebar: false,
+ pageType: 'shared-view',
+})
+
+const route = useRoute()
+
+const { loadSharedView, triggerNotFound } = useSharedView()
+
+const showPassword = ref(false)
+
+const showPageNotFound = ref(false)
+
+try {
+ await loadSharedView(route.params.viewId as string)
+} catch (e: any) {
+ if (e?.response?.status === 403) {
+ showPassword.value = true
+ } else if (e?.response?.status === 404) {
+ showPageNotFound.value = true
+ } else {
+ message.error(await extractSdkResponseErrorMsg(e))
+ }
+}
+
+onMounted(() => {
+ if (!showPageNotFound.value) return
+
+ triggerNotFound()
+})
+</script>
+
+<template>
+ <div v-if="showPassword">
+ <LazySharedViewAskPassword v-model="showPassword" :view-type="ViewTypes.OUTLINE" />
+ </div>
+ <LazySharedViewOutline v-else />
+</template>
diff --git a/packages/nc-gui/store/views.ts b/packages/nc-gui/store/views.ts
index e4bffe56a7..7284b55b32 100644
--- a/packages/nc-gui/store/views.ts
+++ b/packages/nc-gui/store/views.ts
@@ -203,6 +203,8 @@ export const useViewsStore = defineStore('viewsStore', () => {
return parseProp((activeView.value?.view as GalleryType | KanbanType)?.meta)?.is_field_header_visible ?? true
})
+ const isOutlineViewEnabled = computed(() => isEeUI && isFeatureEnabled(FEATURE_FLAG.OUTLINE_VIEW))
+
const isShowEveryonePersonalViewsEnabled = computed({
get: () => {
if (!isEeUI || !isFeatureEnabled(FEATURE_FLAG.SHOW_EVERYONES_PERSONAL_VIEWS)) {
@@ -484,6 +486,17 @@ export const useViewsStore = defineStore('viewsStore', () => {
},
)
break
+ case ViewTypes.OUTLINE:
+ data = await $api.internal.postOperation(
+ activeWorkspaceId.value!,
+ openedProject.value!.id!,
+ {
+ operation: 'outlineViewCreate',
+ tableId,
+ },
+ form,
+ )
+ break
}
if (data) {
@@ -796,6 +809,14 @@ export const useViewsStore = defineStore('viewsStore', () => {
updates,
)
break
+ case ViewTypes.OUTLINE:
+ updatedView = await $api.internal.postOperation(
+ activeView.value!.fk_workspace_id!,
+ activeView.value!.base_id!,
+ { operation: 'outlineViewUpdate', viewId },
+ updates,
+ )
+ break
default:
throw new Error(`Unsupported view type for meta update: ${viewType}`)
}
@@ -1378,6 +1399,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
isUserViewOwner,
getCopyViewConfigBtnAccessStatus,
isShowEveryonePersonalViewsEnabled,
+ isOutlineViewEnabled,
}
})
diff --git a/packages/nc-gui/utils/viewUtils.ts b/packages/nc-gui/utils/viewUtils.ts
index 7d12c60756..ed57a2dbf6 100644
--- a/packages/nc-gui/utils/viewUtils.ts
+++ b/packages/nc-gui/utils/viewUtils.ts
@@ -13,6 +13,7 @@ export const viewIcons: Record<number | string, { icon: any; color: string; dark
[ViewTypes.GALLERY]: { icon: iconMap.gallery, color: 'var(--color-view-icon-gallery)' },
[ViewTypes.MAP]: { icon: iconMap.map, color: 'var(--color-view-icon-map)' },
[ViewTypes.KANBAN]: { icon: iconMap.kanban, color: 'var(--color-view-icon-kanban)' },
+ [ViewTypes.OUTLINE]: { icon: iconMap.ncList, color: 'var(--color-view-icon-outline)' },
view: { icon: iconMap.view, color: 'var(--color-view-icon-view)' },
}
diff --git a/packages/nocodb-sdk/src/lib/enums.ts b/packages/nocodb-sdk/src/lib/enums.ts
index 27652103f4..63b0a19207 100644
--- a/packages/nocodb-sdk/src/lib/enums.ts
+++ b/packages/nocodb-sdk/src/lib/enums.ts
@@ -203,6 +203,10 @@ export enum AppEvents {
GALLERY_DELETE = 'gallery.delete',
GALLERY_DUPLICATE = 'gallery.duplicate',
+ OUTLINE_CREATE = 'outline.create',
+ OUTLINE_UPDATE = 'outline.update',
+ OUTLINE_DELETE = 'outline.delete',
+
BASE_DUPLICATE_START = 'base.duplicate.start',
BASE_DUPLICATE_COMPLETE = 'base.duplicate.complete',
BASE_DUPLICATE_FAIL = 'base.duplicate.fail',
diff --git a/packages/nocodb-sdk/src/lib/globals.ts b/packages/nocodb-sdk/src/lib/globals.ts
index 8c0a14f00c..a1dfb2fc6c 100644
--- a/packages/nocodb-sdk/src/lib/globals.ts
+++ b/packages/nocodb-sdk/src/lib/globals.ts
@@ -40,6 +40,7 @@ export enum ViewTypes {
KANBAN = 4,
MAP = 5,
CALENDAR = 6,
+ OUTLINE = 7,
}
export const viewTypeAlias: Record<ViewTypes, string> = {
@@ -49,6 +50,7 @@ export const viewTypeAlias: Record<ViewTypes, string> = {
[ViewTypes.KANBAN]: 'kanban',
[ViewTypes.MAP]: 'map',
[ViewTypes.CALENDAR]: 'calendar',
+ [ViewTypes.OUTLINE]: 'outline',
};
export const viewTypeToStringMap: Record<ViewTypes, string> = {
diff --git a/packages/nocodb/src/controllers/internal/modules/UiGet.operations.ts b/packages/nocodb/src/controllers/internal/modules/UiGet.operations.ts
index 8286e50ee9..c19404b046 100644
--- a/packages/nocodb/src/controllers/internal/modules/UiGet.operations.ts
+++ b/packages/nocodb/src/controllers/internal/modules/UiGet.operations.ts
@@ -20,7 +20,6 @@ import { MapsService } from '~/services/maps.service';
import { CommentsService } from '~/services/comments.service';
import { SyncService } from '~/services/sync.service';
import { ExtensionsService } from '~/services/extensions.service';
-
@Injectable()
export class UiGetOperations
implements InternalApiModule<InternalGETResponseType>
@@ -68,6 +67,8 @@ export class UiGetOperations
'syncSourceList' as const,
'extensionList' as const,
'extensionRead' as const,
+ 'outlineViewDataList' as const,
+ 'outlineViewDataCount' as const
];
httpMethod = 'GET' as const;
diff --git a/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts b/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
index 2be10822a3..f23a9b6f75 100644
--- a/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
+++ b/packages/nocodb/src/controllers/internal/modules/UiPost.operations.ts
@@ -133,6 +133,8 @@ export class UiPostOperations
'extensionCreate' as const,
'extensionUpdate' as const,
'extensionDelete' as const,
+ 'outlineViewCreate' as const,
+ 'outlineViewUpdate' as const,
];
httpMethod = 'POST' as const;
@@ -239,11 +241,13 @@ export class UiPostOperations
return await this.viewsService.showAllColumns(context, {
viewId: req.query.viewId,
ignoreIds: req.query.ignoreIds,
+ levelId: req.query.levelId,
});
case 'hideAllColumns':
return await this.viewsService.hideAllColumns(context, {
viewId: req.query.viewId,
ignoreIds: req.query.ignoreIds,
+ levelId: req.query.levelId,
});
case 'viewColumnUpdate':
return await this.viewColumnsService.columnUpdate(context, {
diff --git a/packages/nocodb/src/controllers/internal/operationScopes.ts b/packages/nocodb/src/controllers/internal/operationScopes.ts
index 270d6da972..b27a4c650a 100644
--- a/packages/nocodb/src/controllers/internal/operationScopes.ts
+++ b/packages/nocodb/src/controllers/internal/operationScopes.ts
@@ -144,4 +144,10 @@ export const OPERATION_SCOPES = {
managedAppDeployments: 'base',
managedAppVersionDeployments: 'base',
managedAppDeploymentLogs: 'base',
+
+ // Outline View
+ outlineViewDataList: 'base',
+ outlineViewDataCount: 'base',
+ outlineViewCreate: 'base',
+ outlineViewUpdate: 'base',
} as const;
diff --git a/packages/nocodb/src/meta/meta.service.ts b/packages/nocodb/src/meta/meta.service.ts
index 18e25e394c..9bb8eb55a4 100644
--- a/packages/nocodb/src/meta/meta.service.ts
+++ b/packages/nocodb/src/meta/meta.service.ts
@@ -127,6 +127,9 @@ export class MetaService {
[MetaTable.DASHBOARDS]: 'dash',
[MetaTable.WIDGETS]: 'wgt',
[MetaTable.WORKSPACE]: 'w',
+ [MetaTable.OUTLINE_VIEW]: 'ov',
+ [MetaTable.OUTLINE_VIEW_COLUMNS]: 'ovc',
+ [MetaTable.OUTLINE_VIEW_LEVELS]: 'ovl',
[MetaTable.DEPENDENCY_TRACKER]: 'dt',
[MetaTable.INSTALLATIONS]: 'inst',
[MetaTable.AUTOMATIONS]: 'aut',
diff --git a/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts b/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
index 8288f8e192..c1e4d73e29 100644
--- a/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
+++ b/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
@@ -22,6 +22,7 @@ import * as nc_021_scim_support from './v0/nc_021_scim_support';
import * as nc_022_record_templates from './v0/nc_022_record_templates';
import * as nc_023_rls_policies from './v0/nc_023_rls_policies';
import * as nc_202601010000_placeholder from './v0/nc_202601010000_placeholder';
+import * as nc_024_outline_view from './v0/nc_024_outline_view';
// Create a custom migration source class
export default class XcMigrationSourcev0 {
@@ -55,6 +56,7 @@ export default class XcMigrationSourcev0 {
'nc_022_record_templates',
'nc_023_rls_policies',
'nc_202601010000_placeholder',
+ 'nc_024_outline_view',
]);
}
@@ -112,6 +114,8 @@ export default class XcMigrationSourcev0 {
return nc_023_rls_policies;
case 'nc_202601010000_placeholder':
return nc_202601010000_placeholder;
+ case 'nc_024_outline_view':
+ return nc_024_outline_view;
}
}
}
diff --git a/packages/nocodb/src/meta/migrations/v0/nc_024_outline_view.ts b/packages/nocodb/src/meta/migrations/v0/nc_024_outline_view.ts
new file mode 100644
index 0000000000..4eb46ff163
--- /dev/null
+++ b/packages/nocodb/src/meta/migrations/v0/nc_024_outline_view.ts
@@ -0,0 +1,137 @@
+import type { Knex } from 'knex';
+import { MetaTable } from '~/utils/globals';
+
+const up = async (knex: Knex) => {
+ await knex.schema.createTable(MetaTable.OUTLINE_VIEW, (table) => {
+ table.string('fk_view_id', 20);
+
+ table.string('base_id', 20);
+
+ table.string('source_id', 128);
+
+ table.string('title');
+
+ table.boolean('show_empty_parents');
+
+ table.integer('row_height');
+
+ table.string('fk_prefix_column_id', 20);
+
+ table.text('meta');
+
+ table.string('fk_workspace_id', 20);
+
+ table.timestamps(true, true);
+
+ table.primary(['base_id', 'fk_view_id']);
+ });
+
+ await knex.schema.createTable(MetaTable.OUTLINE_VIEW_COLUMNS, (table) => {
+ table.string('id', 20);
+
+ table.string('base_id', 20);
+
+ table.string('source_id', 128);
+
+ table.string('fk_view_id', 20);
+
+ table.string('fk_column_id', 20);
+
+ table.string('fk_level_id', 20);
+
+ table.boolean('show');
+
+ table.float('order');
+
+ table.string('width', 255);
+
+ table.string('fk_workspace_id', 20);
+
+ table.timestamps(true, true);
+
+ table.primary(['base_id', 'id']);
+ });
+
+ await knex.schema.createTable(MetaTable.OUTLINE_VIEW_LEVELS, (table) => {
+ table.string('id', 20);
+
+ table.string('fk_view_id', 20);
+
+ table.integer('level');
+
+ table.string('fk_model_id', 20);
+
+ table.string('fk_link_column_id', 20);
+
+ table.boolean('enable_nested_records');
+
+ table.string('fk_self_link_column_id', 20);
+
+ table.boolean('wrap_headers');
+
+ table.text('meta');
+
+ table.string('base_id', 20);
+
+ table.string('fk_workspace_id', 20);
+
+ table.timestamps(true, true);
+
+ table.primary(['base_id', 'id']);
+ });
+
+ // Add indexes β€” matching pattern from calendar/grid/kanban view tables
+ await knex.schema.alterTable(MetaTable.OUTLINE_VIEW, (table) => {
+ table.index(
+ ['base_id', 'fk_workspace_id'],
+ 'nc_outline_view_v2_base_id_fk_workspace_id_index',
+ );
+ table.index(['fk_view_id'], 'nc_outline_view_v2_fk_view_id_index');
+ });
+
+ await knex.schema.alterTable(MetaTable.OUTLINE_VIEW_COLUMNS, (table) => {
+ table.index(
+ ['base_id', 'fk_workspace_id'],
+ 'nc_outline_view_columns_v2_base_id_fk_workspace_id_index',
+ );
+ table.index(
+ ['fk_view_id', 'fk_column_id'],
+ 'nc_outline_view_columns_v2_fk_view_id_fk_column_id_index',
+ );
+ table.index(['fk_view_id'], 'nc_outline_view_columns_v2_fk_view_id_index');
+ });
+
+ await knex.schema.alterTable(MetaTable.OUTLINE_VIEW_LEVELS, (table) => {
+ table.index(
+ ['base_id', 'fk_workspace_id'],
+ 'nc_outline_view_levels_v2_base_id_fk_workspace_id_index',
+ );
+ table.index(['fk_view_id'], 'nc_outline_view_levels_v2_fk_view_id_index');
+ });
+
+ await knex.schema.alterTable(MetaTable.SORT, (table) => {
+ table.string('fk_level_id', 20);
+ table.index(['fk_level_id'], 'nc_sort_v2_fk_level_id_index');
+ });
+
+ await knex.schema.alterTable(MetaTable.FILTER_EXP, (table) => {
+ table.string('fk_level_id', 20);
+ table.index(['fk_level_id'], 'nc_filter_exp_v2_fk_level_id_index');
+ });
+};
+
+const down = async (knex: Knex) => {
+ await knex.schema.alterTable(MetaTable.FILTER_EXP, (table) => {
+ table.dropIndex([], 'nc_filter_exp_v2_fk_level_id_index');
+ table.dropColumn('fk_level_id');
+ });
+ await knex.schema.alterTable(MetaTable.SORT, (table) => {
+ table.dropIndex([], 'nc_sort_v2_fk_level_id_index');
+ table.dropColumn('fk_level_id');
+ });
+ await knex.schema.dropTable(MetaTable.OUTLINE_VIEW_LEVELS);
+ await knex.schema.dropTable(MetaTable.OUTLINE_VIEW_COLUMNS);
+ await knex.schema.dropTable(MetaTable.OUTLINE_VIEW);
+};
+
+export { up, down };
diff --git a/packages/nocodb/src/middlewares/extract-ids/extract-ids.helpers.ts b/packages/nocodb/src/middlewares/extract-ids/extract-ids.helpers.ts
index 19d8cd3ffc..4669bcc3f2 100644
--- a/packages/nocodb/src/middlewares/extract-ids/extract-ids.helpers.ts
+++ b/packages/nocodb/src/middlewares/extract-ids/extract-ids.helpers.ts
@@ -37,6 +37,7 @@ const PERSONAL_VIEW_MANAGEMENT_PERMISSIONS = [
'kanbanViewUpdate',
'mapViewUpdate',
'calendarViewUpdate',
+ 'outlineViewUpdate',
'viewRowColorConditionAdd',
'viewRowColorConditionUpdate',
'viewRowColorConditionDelete',
@@ -96,6 +97,7 @@ export const personalViewOwnerAllowedPermissions = [
'kanbanViewUpdate',
'mapViewUpdate',
'calendarViewUpdate',
+ 'outlineViewUpdate',
'viewRowColorConditionAdd',
'viewRowColorConditionUpdate',
'viewRowColorConditionDelete',
diff --git a/packages/nocodb/src/models/Filter.ts b/packages/nocodb/src/models/Filter.ts
index 1e8b508397..664d110f3a 100644
--- a/packages/nocodb/src/models/Filter.ts
+++ b/packages/nocodb/src/models/Filter.ts
@@ -9,6 +9,7 @@ import Model from '~/models/Model';
import Column from '~/models/Column';
import Hook from '~/models/Hook';
import View from '~/models/View';
+import OutlineViewLevel from '~/models/OutlineViewLevel';
import Noco from '~/Noco';
import {
CacheDelDirection,
@@ -29,6 +30,7 @@ export default class Filter implements FilterType {
fk_model_id?: string;
fk_view_id?: string;
fk_hook_id?: string;
+ fk_level_id?: string;
fk_parent_column_id?: string;
fk_column_id?: string;
fk_parent_id?: string;
@@ -96,6 +98,7 @@ export default class Filter implements FilterType {
'id',
'fk_view_id',
'fk_hook_id',
+ 'fk_level_id',
'fk_link_col_id',
'fk_value_col_id',
'fk_parent_column_id',
@@ -151,6 +154,15 @@ export default class Filter implements FilterType {
{ colId: filter.fk_column_id },
ncMeta,
);
+ } else if (filter.fk_level_id) {
+ const level = await OutlineViewLevel.get(
+ context,
+ filter.fk_level_id,
+ ncMeta,
+ );
+ if (level?.fk_model_id) {
+ model = await Model.get(context, level.fk_model_id, ncMeta);
+ }
} else {
NcError.invalidFilter(JSON.stringify(filter));
}
@@ -197,11 +209,14 @@ export default class Filter implements FilterType {
if (
!(
id &&
- (filter.fk_view_id || filter.fk_hook_id || filter.fk_parent_column_id)
+ (filter.fk_view_id ||
+ filter.fk_hook_id ||
+ filter.fk_parent_column_id ||
+ filter.fk_level_id)
)
) {
NcError.get(context).badRequest(
- `Mandatory fields missing in FILTER_EXP cache population : id(${id}), fk_view_id(${filter.fk_view_id}), fk_hook_id(${filter.fk_hook_id}), fk_parent_column_id(${filter.fk_parent_column_id})`,
+ `Mandatory fields missing in FILTER_EXP cache population : id(${id}), fk_view_id(${filter.fk_view_id}), fk_hook_id(${filter.fk_hook_id}), fk_parent_column_id(${filter.fk_parent_column_id}), fk_level_id(${filter.fk_level_id})`,
);
}
const key = `${CacheScope.FILTER_EXP}:${id}`;
diff --git a/packages/nocodb/src/models/OutlineView.ts b/packages/nocodb/src/models/OutlineView.ts
new file mode 100644
index 0000000000..11b32c79a6
--- /dev/null
+++ b/packages/nocodb/src/models/OutlineView.ts
@@ -0,0 +1,21 @@
+import type { OutlineType } from 'nocodb-sdk';
+
+export default class OutlineView implements OutlineType {
+ fk_view_id: string;
+
+ constructor(data: OutlineView) {
+ Object.assign(this, data);
+ }
+
+ public static async get(..._args) {
+ return null;
+ }
+
+ static async insert(..._args) {
+ return null;
+ }
+
+ static async update(..._args) {
+ return null;
+ }
+}
diff --git a/packages/nocodb/src/models/OutlineViewColumn.ts b/packages/nocodb/src/models/OutlineViewColumn.ts
new file mode 100644
index 0000000000..7eb144279e
--- /dev/null
+++ b/packages/nocodb/src/models/OutlineViewColumn.ts
@@ -0,0 +1,23 @@
+export default class OutlineViewColumn {
+ id: string;
+
+ constructor(data: OutlineViewColumn) {
+ Object.assign(this, data);
+ }
+
+ public static async get(..._args) {
+ return null;
+ }
+
+ static async list(..._args) {
+ return [];
+ }
+
+ static async insert(..._args) {
+ return null;
+ }
+
+ static async update(..._args) {
+ return null;
+ }
+}
diff --git a/packages/nocodb/src/models/OutlineViewLevel.ts b/packages/nocodb/src/models/OutlineViewLevel.ts
new file mode 100644
index 0000000000..e9ac3b6550
--- /dev/null
+++ b/packages/nocodb/src/models/OutlineViewLevel.ts
@@ -0,0 +1,33 @@
+import type { OutlineViewLevelType } from 'nocodb-sdk';
+
+export default class OutlineViewLevel implements OutlineViewLevelType {
+ id: string;
+
+ constructor(data: OutlineViewLevel) {
+ Object.assign(this, data);
+ }
+
+ public static async get(..._args) {
+ return null;
+ }
+
+ static async list(..._args) {
+ return [];
+ }
+
+ static async insert(..._args) {
+ return null;
+ }
+
+ static async update(..._args) {
+ return null;
+ }
+
+ static async delete(..._args) {
+ return null;
+ }
+
+ static async bulkInsertOrUpdate(..._args) {
+ return [];
+ }
+}
diff --git a/packages/nocodb/src/models/Sort.ts b/packages/nocodb/src/models/Sort.ts
index 53ca570281..4b7f8edad7 100644
--- a/packages/nocodb/src/models/Sort.ts
+++ b/packages/nocodb/src/models/Sort.ts
@@ -18,6 +18,7 @@ export default class Sort {
fk_view_id: string;
fk_column_id?: string;
+ fk_level_id?: string;
direction?: 'asc' | 'desc' | 'count-desc' | 'count-asc';
fk_workspace_id?: string;
base_id?: string;
@@ -68,6 +69,7 @@ export default class Sort {
'id',
'fk_view_id',
'fk_column_id',
+ 'fk_level_id',
'direction',
'base_id',
'source_id',
diff --git a/packages/nocodb/src/models/View.ts b/packages/nocodb/src/models/View.ts
index fa416489a7..1ecc7bcdf1 100644
--- a/packages/nocodb/src/models/View.ts
+++ b/packages/nocodb/src/models/View.ts
@@ -41,6 +41,9 @@ import KanbanViewColumn from '~/models/KanbanViewColumn';
import Column from '~/models/Column';
import MapView from '~/models/MapView';
import MapViewColumn from '~/models/MapViewColumn';
+import OutlineView from '~/models/OutlineView';
+import OutlineViewColumn from '~/models/OutlineViewColumn';
+import OutlineViewLevel from '~/models/OutlineViewLevel';
import { extractProps } from '~/helpers/extractProps';
import NocoCache from '~/cache/NocoCache';
import {
@@ -358,6 +361,9 @@ export default class View implements ViewType {
await Model.getByIdOrName(context, { id: view.fk_model_id }, ncMeta)
).getColumns(context, ncMeta);
+ const levelIdMap = new Map<string, string>();
+ let defaultLevelId: string | undefined;
+
// insert view metadata based on view type
switch (view.type) {
case ViewTypes.GRID:
@@ -381,6 +387,61 @@ export default class View implements ViewType {
ncMeta,
);
break;
+ case ViewTypes.OUTLINE: {
+ await OutlineView.insert(
+ context,
+ {
+ ...(copyFromView?.view || {}),
+ ...view,
+ fk_view_id: view_id,
+ },
+ ncMeta,
+ );
+
+ if (copyFromView?.view) {
+ const sourceLevels = await OutlineViewLevel.list(
+ context,
+ copyFromView.id,
+ ncMeta,
+ );
+ for (const level of sourceLevels) {
+ const newLevel = await OutlineViewLevel.insert(
+ context,
+ {
+ ...extractProps(level, [
+ 'level',
+ 'fk_model_id',
+ 'fk_link_column_id',
+ 'enable_nested_records',
+ 'fk_self_link_column_id',
+ 'wrap_headers',
+ 'meta',
+ ]),
+ fk_view_id: view_id,
+ },
+ ncMeta,
+ );
+ if (level.id && newLevel?.id) {
+ levelIdMap.set(level.id, newLevel.id);
+ }
+ if (level.fk_model_id === view.fk_model_id && newLevel?.id) {
+ defaultLevelId = newLevel.id;
+ }
+ }
+ } else {
+ const defaultLevel = await OutlineViewLevel.insert(
+ context,
+ {
+ fk_view_id: view_id,
+ level: 0,
+ fk_model_id: view.fk_model_id,
+ },
+ ncMeta,
+ );
+ defaultLevelId = defaultLevel?.id;
+ }
+ break;
+ }
case ViewTypes.GALLERY:
await GalleryView.insert(
context,
@@ -457,16 +518,22 @@ export default class View implements ViewType {
columns = await copyFromView.getColumns(context, ncMeta);
for (const sort of sorts) {
+ const sortProps = extractProps(sort, [
+ 'fk_column_id',
+ 'fk_level_id',
+ 'direction',
+ 'base_id',
+ 'source_id',
+ 'order',
+ ]);
+ if (sortProps.fk_level_id) {
+ sortProps.fk_level_id =
+ levelIdMap.get(sortProps.fk_level_id) || sortProps.fk_level_id;
+ }
await Sort.insert(
context,
{
- ...extractProps(sort, [
- 'fk_column_id',
- 'direction',
- 'base_id',
- 'source_id',
- 'order',
- ]),
+ ...sortProps,
fk_view_id: view_id,
id: null,
},
@@ -484,23 +551,29 @@ export default class View implements ViewType {
}
for (const filter of filters.children) {
+ const filterProps = extractProps(filter, [
+ 'id',
+ 'fk_level_id',
+ 'fk_parent_column_id',
+ 'fk_column_id',
+ 'comparison_op',
+ 'comparison_sub_op',
+ 'value',
+ 'fk_parent_id',
+ 'is_group',
+ 'logical_op',
+ 'base_id',
+ 'source_id',
+ 'order',
+ ]);
+ if (filterProps.fk_level_id) {
+ filterProps.fk_level_id =
+ levelIdMap.get(filterProps.fk_level_id) || filterProps.fk_level_id;
+ }
const createdFilter = await Filter.insert(
context,
{
- ...extractProps(filter, [
- 'id',
- 'fk_parent_column_id',
- 'fk_column_id',
- 'comparison_op',
- 'comparison_sub_op',
- 'value',
- 'fk_parent_id',
- 'is_group',
- 'logical_op',
- 'base_id',
- 'source_id',
- 'order',
- ]),
+ ...filterProps,
fk_view_id: view_id,
id: null,
},
@@ -632,6 +705,7 @@ export default class View implements ViewType {
bold,
italic,
id: null,
+ ...(defaultLevelId ? { fk_level_id: defaultLevelId } : {}),
},
ncMeta,
);
@@ -782,6 +856,31 @@ export default class View implements ViewType {
ncMeta,
);
break;
+ case ViewTypes.OUTLINE: {
+ // Insert the column to the outline view level matching the model id
+ const level = (
+ (await OutlineViewLevel.list(context, view.id, ncMeta)) || []
+ ).find((l) => l.fk_model_id === param.fk_model_id);
+ const outlineOrder = level?.id
+ ? await OutlineViewColumn.getNextOrderForLevel(
+ context,
+ view.id,
+ level.id,
+ ncMeta,
+ )
+ : undefined;
+ await OutlineViewColumn.insert(
+ context,
+ {
+ ...insertObj,
+ fk_level_id: level?.id,
+ fk_view_id: view.id,
+ order: outlineOrder,
+ },
+ ncMeta,
+ );
+ break;
+ }
case ViewTypes.KANBAN:
await KanbanViewColumn.insert(context, modifiedInsertObj, ncMeta);
break;
@@ -857,6 +956,18 @@ export default class View implements ViewType {
);
}
break;
+ case ViewTypes.OUTLINE:
+ {
+ col = await OutlineViewColumn.insert(
+ context,
+ {
+ ...param,
+ fk_view_id: view.id,
+ },
+ ncMeta,
+ );
+ }
+ break;
case ViewTypes.FORM:
{
col = await FormViewColumn.insert(
@@ -938,6 +1049,9 @@ export default class View implements ViewType {
case ViewTypes.MAP:
columns = await MapViewColumn.list(context, viewId, ncMeta);
break;
+ case ViewTypes.OUTLINE:
+ columns = await OutlineViewColumn.list(context, viewId, ncMeta);
+ break;
case ViewTypes.FORM:
columns = await FormViewColumn.list(context, viewId, ncMeta);
break;
@@ -983,6 +1097,11 @@ export default class View implements ViewType {
tableName = MetaTable.MAP_VIEW_COLUMNS;
cacheScope = CacheScope.MAP_VIEW_COLUMN;
+ break;
+ case ViewTypes.OUTLINE:
+ tableName = MetaTable.OUTLINE_VIEW_COLUMNS;
+ cacheScope = CacheScope.OUTLINE_VIEW_COLUMN;
+
break;
case ViewTypes.FORM:
tableName = MetaTable.FORM_VIEW_COLUMNS;
@@ -1046,6 +1165,10 @@ export default class View implements ViewType {
table = MetaTable.MAP_VIEW_COLUMNS;
cacheScope = CacheScope.MAP_VIEW_COLUMN;
break;
+ case ViewTypes.OUTLINE:
+ table = MetaTable.OUTLINE_VIEW_COLUMNS;
+ cacheScope = CacheScope.OUTLINE_VIEW_COLUMN;
+ break;
case ViewTypes.GALLERY:
table = MetaTable.GALLERY_VIEW_COLUMNS;
cacheScope = CacheScope.GALLERY_VIEW_COLUMN;
@@ -1154,6 +1277,8 @@ export default class View implements ViewType {
return GridViewColumn.get(context, colId, ncMeta);
case ViewTypes.MAP:
return MapViewColumn.get(context, colId, ncMeta);
+ case ViewTypes.OUTLINE:
+ return OutlineViewColumn.get(context, colId, ncMeta);
case ViewTypes.GALLERY:
return GalleryViewColumn.get(context, colId, ncMeta);
case ViewTypes.KANBAN:
@@ -1263,6 +1388,17 @@ export default class View implements ViewType {
},
ncMeta,
);
+ case ViewTypes.OUTLINE:
+ return await OutlineViewColumn.insert(
+ context,
+ {
+ fk_view_id: viewId,
+ fk_column_id: fkColId,
+ order: colData.order,
+ show: colData.show,
+ },
+ ncMeta,
+ );
case ViewTypes.FORM:
return await FormViewColumn.insert(
context,
@@ -1578,6 +1714,23 @@ export default class View implements ViewType {
CacheDelDirection.CHILD_TO_PARENT,
);
}
+
+ // For Outline View, delete the levels associated with viewId
+ if (view.type === ViewTypes.OUTLINE) {
+ await ncMeta.metaDelete(
+ context.workspace_id,
+ context.base_id,
+ MetaTable.OUTLINE_VIEW_LEVELS,
+ {
+ fk_view_id: viewId,
+ },
+ );
+ await NocoCache.deepDel(
+ context,
+ `${CacheScope.OUTLINE_VIEW_LEVEL}:${viewId}`,
+ CacheDelDirection.CHILD_TO_PARENT,
+ );
+ }
await NocoCache.deepDel(
context,
`${columnTableScope}:${viewId}`,
@@ -1664,6 +1817,7 @@ export default class View implements ViewType {
viewId,
ignoreColdIds = [],
ncMeta = Noco.ncMeta,
+ levelId?: string,
) {
const view = await this.get(context, viewId);
const table = this.extractViewColumnsTableName(view);
@@ -1683,6 +1837,7 @@ export default class View implements ViewType {
const { isNoneList } = cachedList;
if (!isNoneList && dataList?.length) {
for (const o of dataList) {
+ if (levelId && o.fk_level_id !== levelId) continue;
if (!ignoreColdIds?.length || !ignoreColdIds.includes(o.fk_column_id)) {
// set data
o.show = true;
@@ -1698,6 +1853,10 @@ export default class View implements ViewType {
const colIndex = availableColumnsInView.indexOf(col.id);
if (colIndex > -1) {
+ // Skip columns not belonging to the specified level
+ if (levelId && (viewColumns[colIndex] as any).fk_level_id !== levelId)
+ continue;
+
await this.updateColumn(
context,
viewId,
@@ -1705,7 +1864,8 @@ export default class View implements ViewType {
{ show: true },
ncMeta,
);
- } else {
+ } else if (!levelId) {
+ // Only insert new columns when not level-scoped
await this.insertColumn(
context,
{
@@ -1746,6 +1906,7 @@ export default class View implements ViewType {
viewId,
ignoreColdIds = [],
ncMeta = Noco.ncMeta,
+ levelId?: string,
) {
const view = await this.get(context, viewId, ncMeta);
const table = this.extractViewColumnsTableName(view);
@@ -1782,6 +1943,7 @@ export default class View implements ViewType {
if (!isNoneList && dataList?.length) {
for (const o of dataList) {
+ if (levelId && o.fk_level_id !== levelId) continue;
if (
!mergedIgnoreColdIds?.length ||
!mergedIgnoreColdIds.includes(o.fk_column_id)
@@ -1793,15 +1955,21 @@ export default class View implements ViewType {
}
}
}
+
// set meta
+ const condition: Record<string, any> = {
+ fk_view_id: viewId,
+ };
+ if (levelId) {
+ condition.fk_level_id = levelId;
+ }
+
return await ncMeta.metaUpdate(
context.workspace_id,
context.base_id,
table,
{ show: false },
- {
- fk_view_id: viewId,
- },
+ condition,
mergedIgnoreColdIds?.length
? {
_not: {
@@ -1836,6 +2004,9 @@ export default class View implements ViewType {
case ViewTypes.MAP:
viewType = 'map';
break;
+ case ViewTypes.OUTLINE:
+ viewType = 'outline';
+ break;
case ViewTypes.CALENDAR:
viewType = 'calendar';
break;
@@ -2274,6 +2445,14 @@ export default class View implements ViewType {
insertObjs,
);
break;
+ case ViewTypes.OUTLINE:
+ await ncMeta.bulkMetaInsert(
+ context.workspace_id,
+ context.base_id,
+ MetaTable.OUTLINE_VIEW_COLUMNS,
+ insertObjs,
+ );
+ break;
case ViewTypes.KANBAN:
await ncMeta.bulkMetaInsert(
context.workspace_id,
@@ -2399,6 +2578,10 @@ export default class View implements ViewType {
const { id: view_id } = insertedView;
+ // Map old level IDs to new level IDs for sort/filter duplication (outline view)
+ const levelIdMap = new Map<string, string>();
+ let defaultLevelId: string | undefined;
+
// insert view metadata based on view type
switch (view.type) {
case ViewTypes.GRID:
@@ -2422,6 +2605,62 @@ export default class View implements ViewType {
ncMeta,
);
break;
+ case ViewTypes.OUTLINE: {
+ await OutlineView.insert(
+ context,
+ {
+ ...(copyFromView?.view || {}),
+ ...view,
+ fk_view_id: view_id,
+ },
+ ncMeta,
+ );
+
+ if (copyFromView?.view) {
+ const sourceLevels = await OutlineViewLevel.list(
+ context,
+ copyFromView.id,
+ ncMeta,
+ );
+ for (const level of sourceLevels) {
+ const newLevel = await OutlineViewLevel.insert(
+ context,
+ {
+ ...extractProps(level, [
+ 'level',
+ 'fk_model_id',
+ 'fk_link_column_id',
+ 'enable_nested_records',
+ 'fk_self_link_column_id',
+ 'row_height',
+ 'meta',
+ ]),
+ fk_view_id: view_id,
+ },
+ ncMeta,
+ );
+ if (level.id && newLevel?.id) {
+ levelIdMap.set(level.id, newLevel.id);
+ }
+ if (level.fk_model_id === view.fk_model_id && newLevel?.id) {
+ defaultLevelId = newLevel.id;
+ }
+ }
+ } else {
+ // Auto-create level 0 with the view's table
+ const defaultLevel = await OutlineViewLevel.insert(
+ context,
+ {
+ fk_view_id: view_id,
+ level: 0,
+ fk_model_id: view.fk_model_id,
+ },
+ ncMeta,
+ );
+ defaultLevelId = defaultLevel?.id;
+ }
+ break;
+ }
case ViewTypes.GALLERY:
await GalleryView.insert(
context,
@@ -2515,13 +2754,19 @@ export default class View implements ViewType {
const filterInsertObjs = [];
for (const sort of sorts) {
+ const sortProps = extractProps(sort, [
+ 'fk_column_id',
+ 'fk_level_id',
+ 'direction',
+ 'base_id',
+ 'source_id',
+ ]);
+ if (sortProps.fk_level_id) {
+ sortProps.fk_level_id =
+ levelIdMap.get(sortProps.fk_level_id) || sortProps.fk_level_id;
+ }
sortInsertObjs.push({
- ...extractProps(sort, [
- 'fk_column_id',
- 'direction',
- 'base_id',
- 'source_id',
- ]),
+ ...sortProps,
fk_view_id: view_id,
id: undefined,
});
@@ -2544,22 +2789,29 @@ export default class View implements ViewType {
const fn = async (filter, parentId: string = null) => {
const generatedId = await ncMeta.genNanoid(MetaTable.FILTER_EXP);
+ const filterProps = extractProps(filter, [
+ 'fk_level_id',
+ 'fk_parent_column_id',
+ 'fk_row_color_condition_id',
+ 'fk_column_id',
+ 'comparison_op',
+ 'comparison_sub_op',
+ 'value',
+ 'fk_parent_id',
+ 'is_group',
+ 'logical_op',
+ 'base_id',
+ 'source_id',
+ 'order',
+ 'meta',
+ ]);
+ if (filterProps.fk_level_id) {
+ filterProps.fk_level_id =
+ levelIdMap.get(filterProps.fk_level_id) ||
+ filterProps.fk_level_id;
+ }
filterInsertObjs.push({
- ...extractProps(filter, [
- 'fk_parent_column_id',
- 'fk_row_color_condition_id',
- 'fk_column_id',
- 'comparison_op',
- 'comparison_sub_op',
- 'value',
- 'fk_parent_id',
- 'is_group',
- 'logical_op',
- 'base_id',
- 'source_id',
- 'order',
- 'meta',
- ]),
+ ...filterProps,
fk_view_id: view_id,
id: generatedId,
fk_parent_id: parentId,
@@ -2625,6 +2877,17 @@ export default class View implements ViewType {
);
}
+ // Associate bulk-inserted outline view columns with the default level
+ if (view.type === ViewTypes.OUTLINE && defaultLevelId) {
+ await ncMeta.metaUpdate(
+ context.workspace_id,
+ context.base_id,
+ MetaTable.OUTLINE_VIEW_COLUMNS,
+ { fk_level_id: defaultLevelId },
+ { fk_view_id: view_id },
+ );
+ }
+
if (copyFromView) {
Noco.appHooksService.emit(AppEvents.VIEW_DUPLICATE_COMPLETE, {
sourceView: copyFromView,
@@ -2671,6 +2934,9 @@ export default class View implements ViewType {
case ViewTypes.MAP:
table = MetaTable.MAP_VIEW_COLUMNS;
break;
+ case ViewTypes.OUTLINE:
+ table = MetaTable.OUTLINE_VIEW_COLUMNS;
+ break;
case ViewTypes.CALENDAR:
table = MetaTable.CALENDAR_VIEW_COLUMNS;
break;
@@ -2696,6 +2962,9 @@ export default class View implements ViewType {
case ViewTypes.MAP:
table = MetaTable.MAP_VIEW;
break;
+ case ViewTypes.OUTLINE:
+ table = MetaTable.OUTLINE_VIEW;
+ break;
case ViewTypes.CALENDAR:
table = MetaTable.CALENDAR_VIEW;
break;
@@ -2715,6 +2984,9 @@ export default class View implements ViewType {
case ViewTypes.MAP:
scope = CacheScope.MAP_VIEW_COLUMN;
break;
+ case ViewTypes.OUTLINE:
+ scope = CacheScope.OUTLINE_VIEW_COLUMN;
+ break;
case ViewTypes.KANBAN:
scope = CacheScope.KANBAN_VIEW_COLUMN;
break;
@@ -2740,6 +3012,9 @@ export default class View implements ViewType {
case ViewTypes.MAP:
scope = CacheScope.MAP_VIEW;
break;
+ case ViewTypes.OUTLINE:
+ scope = CacheScope.OUTLINE_VIEW;
+ break;
case ViewTypes.KANBAN:
scope = CacheScope.KANBAN_VIEW;
break;
@@ -2786,6 +3061,9 @@ export default class View implements ViewType {
case ViewTypes.MAP:
this.view = await MapView.get(context, this.id, ncMeta);
break;
+ case ViewTypes.OUTLINE:
+ this.view = await OutlineView.get(context, this.id, ncMeta);
+ break;
case ViewTypes.FORM:
this.view = await FormView.getWithInfo(context, this.id, ncMeta);
break;
@@ -2813,6 +3091,9 @@ export default class View implements ViewType {
case ViewTypes.MAP:
this.view = await MapView.get(context, this.id, ncMeta);
break;
+ case ViewTypes.OUTLINE:
+ this.view = await OutlineView.get(context, this.id, ncMeta);
+ break;
case ViewTypes.FORM:
this.view = await FormView.get(context, this.id, ncMeta);
break;
diff --git a/packages/nocodb/src/models/index.ts b/packages/nocodb/src/models/index.ts
index e369516458..dd1b68b778 100644
--- a/packages/nocodb/src/models/index.ts
+++ b/packages/nocodb/src/models/index.ts
@@ -21,6 +21,9 @@ export { default as KanbanView } from './KanbanView';
export { default as KanbanViewColumn } from './KanbanViewColumn';
export { default as LinkToAnotherRecordColumn } from './LinkToAnotherRecordColumn';
export { default as LookupColumn } from './LookupColumn';
+export { default as OutlineView } from './OutlineView';
+export { default as OutlineViewColumn } from './OutlineViewColumn';
+export { default as OutlineViewLevel } from './OutlineViewLevel';
export { default as MapView } from './MapView';
export { default as MapViewColumn } from './MapViewColumn';
export { default as Model } from './Model';
diff --git a/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts b/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts
index 806e97b4b1..746c5bbdc5 100644
--- a/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts
+++ b/packages/nocodb/src/modules/jobs/jobs/export-import/export.service.ts
@@ -470,8 +470,29 @@ export class ExportService {
case 'fk_column_id':
case 'fk_cover_image_col_id':
case 'fk_grp_col_id':
+ case 'fk_prefix_column_id':
view.view[k] = idMap.get(v as string);
break;
+ case 'levels':
+ if (view.type === ViewTypes.OUTLINE) {
+ view.view[k] = (v as any[]).map((level) => ({
+ level: level.level,
+ fk_model_id:
+ idMap.get(level.fk_model_id) ?? level.fk_model_id,
+ fk_link_column_id: level.fk_link_column_id
+ ? idMap.get(level.fk_link_column_id) ??
+ level.fk_link_column_id
+ : null,
+ fk_self_link_column_id: level.fk_self_link_column_id
+ ? idMap.get(level.fk_self_link_column_id) ??
+ level.fk_self_link_column_id
+ : null,
+ enable_nested_records: level.enable_nested_records,
+ wrap_headers: level.wrap_headers,
+ meta: level.meta,
+ }));
+ }
+ break;
case 'meta':
if (view.type === ViewTypes.KANBAN) {
const meta = parseMetaProp(view.view) as Record<string, any>;
diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json
index bb542e8baa..1eb7e35e4d 100644
--- a/packages/nocodb/src/schema/swagger.json
+++ b/packages/nocodb/src/schema/swagger.json
@@ -22837,6 +22837,10 @@
"enabled": {
"$ref": "#/components/schemas/Bool",
"description": "Whether this filter is enabled. Disabled filters are skipped during evaluation."
+ },
+ "fk_level_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "Foreign Key to Outline View Level"
}
},
"readOnly": true,
@@ -23152,6 +23156,10 @@
"enabled": {
"$ref": "#/components/schemas/Bool",
"description": "Whether this filter is enabled. Disabled filters are skipped during evaluation."
+ },
+ "fk_level_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "Foreign Key to Outline View Level"
}
},
"readOnly": true
@@ -27659,6 +27667,10 @@
"description": "Base ID",
"example": "p_9sx43moxhqtjm3",
"readOnly": true
+ },
+ "fk_level_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "Foreign Key to Outline View Level"
}
},
"x-stoplight": {
@@ -27772,6 +27784,10 @@
"desc"
],
"type": "string"
+ },
+ "fk_level_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "Foreign Key to Outline View Level"
}
},
"x-stoplight": {
@@ -28936,6 +28952,9 @@
},
{
"$ref": "#/components/schemas/Calendar"
+ },
+ {
+ "$ref": "#/components/schemas/Outline"
}
],
"description": "Associated View Model"
@@ -30267,6 +30286,217 @@
"description": "Custom url path"
}
}
+ },
+ "OutlineViewLevel": {
+ "description": "Model for Outline View Level",
+ "title": "OutlineViewLevel Model",
+ "type": "object",
+ "properties": {
+ "id": {
+ "description": "Unique ID for Level",
+ "type": "string"
+ },
+ "fk_view_id": {
+ "description": "Foreign Key to View",
+ "type": "string"
+ },
+ "level": {
+ "description": "Level number (1, 2, or 3)",
+ "type": "number"
+ },
+ "fk_model_id": {
+ "description": "Foreign Key to Model (table) for this level",
+ "type": "string"
+ },
+ "fk_link_column_id": {
+ "description": "Foreign Key to Link Column connecting levels",
+ "type": "string"
+ },
+ "enable_nested_records": {
+ "$ref": "#/components/schemas/Bool",
+ "description": "Enable nested records (Level 1 only)"
+ },
+ "fk_self_link_column_id": {
+ "description": "Foreign Key to Self-Link Column",
+ "type": "string"
+ },
+ "wrap_headers": {
+ "$ref": "#/components/schemas/Bool",
+ "description": "Wrap column headers in this level"
+ },
+ "meta": {
+ "$ref": "#/components/schemas/Meta",
+ "description": "Meta data for this level"
+ }
+ }
+ },
+ "Outline": {
+ "description": "Model for Outline View",
+ "title": "Outline Model",
+ "type": "object",
+ "properties": {
+ "source_id": {
+ "description": "The ID of the source that this view belongs to",
+ "type": "string"
+ },
+ "columns": {
+ "description": "Columns in this view",
+ "items": {
+ "$ref": "#/components/schemas/OutlineColumn"
+ },
+ "type": "array"
+ },
+ "fk_view_id": {
+ "description": "Foreign Key to View",
+ "type": "string"
+ },
+ "meta": {
+ "$ref": "#/components/schemas/Meta",
+ "description": "Meta data for this view"
+ },
+ "order": {
+ "description": "The order of the list",
+ "type": "number"
+ },
+ "base_id": {
+ "description": "The ID of the base that this view belongs to",
+ "type": "string"
+ },
+ "show": {
+ "description": "To show this view or not",
+ "type": "boolean"
+ },
+ "title": {
+ "description": "Title of Outline View",
+ "type": "string"
+ },
+ "show_empty_parents": {
+ "$ref": "#/components/schemas/Bool",
+ "description": "Show empty parent sections"
+ },
+ "row_height": {
+ "description": "Row height for this outline view",
+ "type": "number"
+ },
+ "fk_prefix_column_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "Foreign Key to Prefix Column"
+ },
+ "levels": {
+ "description": "Levels configuration for this outline view",
+ "items": {
+ "$ref": "#/components/schemas/OutlineViewLevel"
+ },
+ "type": "array"
+ }
+ }
+ },
+ "OutlineColumn": {
+ "description": "Model for Outline Column",
+ "title": "OutlineColumn Model",
+ "type": "object",
+ "properties": {
+ "source_id": {
+ "description": "The ID of the source",
+ "type": "string"
+ },
+ "fk_column_id": {
+ "description": "Foreign Key to Column",
+ "type": "string"
+ },
+ "fk_view_id": {
+ "description": "Foreign Key to View",
+ "type": "string"
+ },
+ "fk_level_id": {
+ "description": "Foreign Key to Level",
+ "type": "string"
+ },
+ "id": {
+ "description": "Unique ID of Outline Column",
+ "type": "string"
+ },
+ "order": {
+ "description": "The order in the list of columns",
+ "type": "number"
+ },
+ "base_id": {
+ "description": "The ID of the base",
+ "type": "string"
+ },
+ "show": {
+ "description": "Whether to show this column or not",
+ "type": "number"
+ },
+ "width": {
+ "description": "Column width",
+ "type": "string"
+ }
+ }
+ },
+ "OutlineUpdateReq": {
+ "description": "Model for Outline View Update Request",
+ "title": "OutlineUpdateReq Model",
+ "type": "object",
+ "properties": {
+ "meta": {
+ "$ref": "#/components/schemas/Meta",
+ "description": "Meta data for this view"
+ },
+ "show_empty_parents": {
+ "$ref": "#/components/schemas/Bool",
+ "description": "Show empty parent sections"
+ },
+ "row_height": {
+ "description": "Row height for this outline view",
+ "type": "number"
+ },
+ "fk_prefix_column_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "Foreign Key to Prefix Column"
+ },
+ "levels": {
+ "description": "Levels configuration for this outline view",
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/OutlineViewLevelReq"
+ }
+ }
+ }
+ },
+ "OutlineViewLevelReq": {
+ "description": "Model for Outline View Level Request",
+ "title": "OutlineViewLevelReq Model",
+ "type": "object",
+ "required": [
+ "level",
+ "fk_model_id"
+ ],
+ "properties": {
+ "level": {
+ "description": "Level number (1, 2, or 3)",
+ "type": "number"
+ },
+ "fk_model_id": {
+ "description": "Foreign Key to Model (table) for this level",
+ "type": "string"
+ },
+ "fk_link_column_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "Foreign Key to Link Column"
+ },
+ "enable_nested_records": {
+ "$ref": "#/components/schemas/Bool"
+ },
+ "fk_self_link_column_id": {
+ "$ref": "#/components/schemas/StringOrNull",
+ "description": "Foreign Key to Self-Link Column"
+ },
+ "wrap_headers": {
+ "$ref": "#/components/schemas/Bool",
+ "description": "Wrap column headers in this level"
+ }
+ }
}
},
"responses": {
diff --git a/packages/nocodb/src/services/app-hooks-listener.service.ts b/packages/nocodb/src/services/app-hooks-listener.service.ts
index b236c94aaa..453fd7ac83 100644
--- a/packages/nocodb/src/services/app-hooks-listener.service.ts
+++ b/packages/nocodb/src/services/app-hooks-listener.service.ts
@@ -165,6 +165,7 @@ export class AppHooksListenerService implements OnModuleInit, OnModuleDestroy {
case AppEvents.CALENDAR_UPDATE:
case AppEvents.GALLERY_UPDATE:
case AppEvents.KANBAN_UPDATE:
+ case AppEvents.OUTLINE_UPDATE:
case AppEvents.VIEW_UPDATE:
break;
case AppEvents.FORM_DELETE:
@@ -181,6 +182,10 @@ export class AppHooksListenerService implements OnModuleInit, OnModuleDestroy {
break;
case AppEvents.CALENDAR_DELETE:
break;
+ case AppEvents.OUTLINE_CREATE:
+ break;
+ case AppEvents.OUTLINE_DELETE:
+ break;
case AppEvents.FILTER_CREATE:
break;
diff --git a/packages/nocodb/src/services/app-hooks/app-hooks.service.ts b/packages/nocodb/src/services/app-hooks/app-hooks.service.ts
index a2174c352d..8ddeef9f75 100644
--- a/packages/nocodb/src/services/app-hooks/app-hooks.service.ts
+++ b/packages/nocodb/src/services/app-hooks/app-hooks.service.ts
@@ -23,6 +23,7 @@ import type {
GridViewUpdateEvent,
IntegrationUpdateEvent,
KanbanViewUpdateEvent,
+ OutlineViewUpdateEvent,
MetaDiffEvent,
OrgUserInviteEvent,
PluginEvent,
@@ -333,7 +334,8 @@ export class AppHooksService {
| AppEvents.CALENDAR_CREATE
| AppEvents.GALLERY_CREATE
| AppEvents.KANBAN_CREATE
- | AppEvents.MAP_CREATE,
+ | AppEvents.MAP_CREATE
+ | AppEvents.OUTLINE_CREATE,
data: ViewCreateEvent,
): void;
emit(
@@ -343,7 +345,8 @@ export class AppHooksService {
| AppEvents.CALENDAR_DELETE
| AppEvents.GALLERY_DELETE
| AppEvents.KANBAN_DELETE
- | AppEvents.MAP_DELETE,
+ | AppEvents.MAP_DELETE
+ | AppEvents.OUTLINE_DELETE,
data: ViewDeleteEvent,
): void;
emit(
@@ -352,14 +355,16 @@ export class AppHooksService {
| AppEvents.CALENDAR_UPDATE
| AppEvents.GALLERY_UPDATE
| AppEvents.KANBAN_UPDATE
- | AppEvents.MAP_UPDATE,
+ | AppEvents.MAP_UPDATE
+ | AppEvents.OUTLINE_UPDATE,
data:
| ViewUpdateEvent
| GridViewUpdateEvent
| GalleryViewUpdateEvent
| KanbanViewUpdateEvent
| CalendarViewUpdateEvent
- | FormViewUpdateEvent,
+ | FormViewUpdateEvent
+ | OutlineViewUpdateEvent,
): void;
emit(
event:
@@ -404,14 +409,16 @@ export class AppHooksService {
| AppEvents.CALENDAR_UPDATE
| AppEvents.GALLERY_UPDATE
| AppEvents.KANBAN_UPDATE
- | AppEvents.MAP_UPDATE,
+ | AppEvents.MAP_UPDATE
+ | AppEvents.OUTLINE_UPDATE,
data:
| ViewUpdateEvent
| GridViewUpdateEvent
| GalleryViewUpdateEvent
| KanbanViewUpdateEvent
| CalendarViewUpdateEvent
- | FormViewUpdateEvent,
+ | FormViewUpdateEvent
+ | OutlineViewUpdateEvent,
): void;
emit(
event:
diff --git a/packages/nocodb/src/services/app-hooks/interfaces.ts b/packages/nocodb/src/services/app-hooks/interfaces.ts
index 206c512b5f..3f354c8b0f 100644
--- a/packages/nocodb/src/services/app-hooks/interfaces.ts
+++ b/packages/nocodb/src/services/app-hooks/interfaces.ts
@@ -220,6 +220,13 @@ export interface FormViewUpdateEvent extends NcBaseEvent {
owner: UserType;
}
+export interface OutlineViewUpdateEvent extends NcBaseEvent {
+ view: ViewType;
+ outlineView: any;
+ oldOutlineView: any;
+ owner: UserType;
+}
+
type FilterEventAdditionalProp =
| {
hook: HookType;
diff --git a/packages/nocodb/src/services/views.service.ts b/packages/nocodb/src/services/views.service.ts
index d17a5e1656..a5f4491881 100644
--- a/packages/nocodb/src/services/views.service.ts
+++ b/packages/nocodb/src/services/views.service.ts
@@ -401,6 +401,8 @@ export class ViewsService {
deleteEvent = AppEvents.KANBAN_DELETE;
} else if (view.type === ViewTypes.MAP) {
deleteEvent = AppEvents.MAP_DELETE;
+ } else if (view.type === ViewTypes.OUTLINE) {
+ deleteEvent = AppEvents.OUTLINE_DELETE;
}
let owner = param.req.user;
@@ -546,6 +548,7 @@ export class ViewsService {
param: {
viewId: string;
ignoreIds?: string[];
+ levelId?: string;
viewWebhookManager?: ViewWebhookManager;
},
ncMeta?: MetaService,
@@ -563,7 +566,13 @@ export class ViewsService {
).withViewId(view.id)
).forUpdate();
}
- await View.showAllColumns(context, param.viewId, param.ignoreIds || []);
+ await View.showAllColumns(
+ context,
+ param.viewId,
+ param.ignoreIds || [],
+ undefined,
+ param.levelId,
+ );
NocoSocket.broadcastEvent(
context,
@@ -593,6 +602,7 @@ export class ViewsService {
param: {
viewId: string;
ignoreIds?: string[];
+ levelId?: string;
viewWebhookManager?: ViewWebhookManager;
},
ncMeta?: MetaService,
@@ -616,6 +626,7 @@ export class ViewsService {
param.viewId,
param.ignoreIds || [],
ncMeta,
+ param.levelId,
);
NocoSocket.broadcastEvent(
diff --git a/packages/nocodb/src/utils/audit.ts b/packages/nocodb/src/utils/audit.ts
index 97d25875e0..b6befc637e 100644
--- a/packages/nocodb/src/utils/audit.ts
+++ b/packages/nocodb/src/utils/audit.ts
@@ -546,6 +546,61 @@ export const extractViewRelatedProps = async ({
}
}
+ if ((view as { fk_prefix_column_id?: string }).fk_prefix_column_id) {
+ const prefixCol = await Column.get(context, {
+ colId: (view as { fk_prefix_column_id: string }).fk_prefix_column_id,
+ });
+ result.prefix_field_id = prefixCol?.id;
+ result.prefix_field_title = prefixCol?.title;
+ result.fk_prefix_column_id = undefined;
+ }
+
+ // extract outline view level column references
+ if (Array.isArray(view.levels) && view.levels.length) {
+ result.levels = await Promise.all(
+ view.levels.map(
+ async (level: {
+ fk_model_id?: string;
+ fk_link_column_id?: string;
+ fk_self_link_column_id?: string;
+ level?: number;
+ enable_nested_records?: any;
+ wrap_headers?: any;
+ }) => {
+ const levelResult: Record<string, any> = {
+ level: level.level,
+ enable_nested_records: level.enable_nested_records,
+ wrap_headers: level.wrap_headers,
+ };
+
+ if (level.fk_model_id) {
+ const model = await Model.get(context, level.fk_model_id);
+ levelResult.model_id = model?.id;
+ levelResult.model_title = model?.title;
+ }
+
+ if (level.fk_link_column_id) {
+ const col = await Column.get(context, {
+ colId: level.fk_link_column_id,
+ });
+ levelResult.link_field_id = col?.id;
+ levelResult.link_field_title = col?.title;
+ }
+
+ if (level.fk_self_link_column_id) {
+ const col = await Column.get(context, {
+ colId: level.fk_self_link_column_id,
+ });
+ levelResult.self_link_field_id = col?.id;
+ levelResult.self_link_field_title = col?.title;
+ }
+
+ return levelResult;
+ },
+ ),
+ );
+ }
+
return result;
};
diff --git a/packages/nocodb/src/utils/globals.ts b/packages/nocodb/src/utils/globals.ts
index a62b80c22a..f621184aff 100644
--- a/packages/nocodb/src/utils/globals.ts
+++ b/packages/nocodb/src/utils/globals.ts
@@ -47,6 +47,9 @@ export enum MetaTable {
SYNC_LOGS = 'nc_sync_logs_v2',
MAP_VIEW = 'nc_map_view_v2',
MAP_VIEW_COLUMNS = 'nc_map_view_columns_v2',
+ OUTLINE_VIEW = 'nc_outline_view_v2',
+ OUTLINE_VIEW_COLUMNS = 'nc_outline_view_columns_v2',
+ OUTLINE_VIEW_LEVELS = 'nc_outline_view_levels_v2',
STORE = 'nc_store',
NOTIFICATION = 'notification',
USER_REFRESH_TOKENS = 'nc_user_refresh_tokens',
@@ -149,6 +152,9 @@ export const BaseRelatedMetaTables = [
MetaTable.KANBAN_VIEW,
MetaTable.MAP_VIEW_COLUMNS,
MetaTable.MAP_VIEW,
+ MetaTable.OUTLINE_VIEW_COLUMNS,
+ MetaTable.OUTLINE_VIEW_LEVELS,
+ MetaTable.OUTLINE_VIEW,
MetaTable.MCP_TOKENS,
MetaTable.MODELS,
MetaTable.PERMISSIONS,
@@ -194,6 +200,9 @@ export const orderedMetaTables = [
MetaTable.USERS,
MetaTable.MAP_VIEW,
MetaTable.MAP_VIEW_COLUMNS,
+ MetaTable.OUTLINE_VIEW,
+ MetaTable.OUTLINE_VIEW_COLUMNS,
+ MetaTable.OUTLINE_VIEW_LEVELS,
MetaTable.KANBAN_VIEW_COLUMNS,
MetaTable.KANBAN_VIEW,
MetaTable.CALENDAR_VIEW,
@@ -282,6 +291,9 @@ export enum CacheScope {
MAP_VIEW = 'mapView',
MAP_VIEW_COLUMN = 'mapViewColumn',
KANBAN_VIEW_COLUMN = 'kanbanViewColumn',
+ OUTLINE_VIEW = 'outlineView',
+ OUTLINE_VIEW_COLUMN = 'outlineViewColumn',
+ OUTLINE_VIEW_LEVEL = 'outlineViewLevel',
USER = 'user',
ORGS_OLD = 'orgs',
TEAM = 'team',
diff --git a/packages/nocodb/src/utils/internal-type.ts b/packages/nocodb/src/utils/internal-type.ts
index 2e4430704e..33e4a9ddfe 100644
--- a/packages/nocodb/src/utils/internal-type.ts
+++ b/packages/nocodb/src/utils/internal-type.ts
@@ -38,6 +38,7 @@ export type InternalGETResponseType = Promise<
| Extension
| Extension[]
| { workspaces: any[] }
+ | { totalRows: number; counts: Record<string, number> }
>;
export type InternalPOSTResponseType = Promise<