diff --git a/packages/nc-gui/components/smartsheet/Gallery.vue b/packages/nc-gui/components/smartsheet/Gallery.vue index 0128997248..0af5bdc9d9 100644 --- a/packages/nc-gui/components/smartsheet/Gallery.vue +++ b/packages/nc-gui/components/smartsheet/Gallery.vue @@ -49,6 +49,7 @@ const { galleryData, changePage, addEmptyRow, + deleteRow, navigateToSiblingRow, } = useViewData(meta, view) @@ -81,6 +82,9 @@ const isRowEmpty = (record: any, col: any) => { return Array.isArray(val) && val.length === 0 } +// const { xWhere, isPkAvail, isSqlView, eventBus } = useSmartsheetStoreOrThrow() +const { isSqlView } = useSmartsheetStoreOrThrow() + const attachments = (record: any): Attachment[] => { try { if (coverImageColumn?.title && record.row[coverImageColumn.title]) { @@ -168,85 +172,134 @@ watch(view, async (nextView) => { await loadGalleryData() } }) + +const { isUIAllowed } = useUIPermission() +const hasEditPermission = $computed(() => isUIAllowed('xcDatatableEditable')) +// TODO: extract this code (which is duplicated in grid and gallery) into a separate component +const _contextMenu = ref(false) +const contextMenu = computed({ + get: () => _contextMenu.value, + set: (val) => { + if (hasEditPermission) { + _contextMenu.value = val + } + }, +}) +const contextMenuTarget = ref<{ row: number } | null>(null) + +const showContextMenu = (e: MouseEvent, target?: { row: number }) => { + if (isSqlView.value) return + e.preventDefault() + if (target) { + contextMenuTarget.value = target + } +} + +