diff --git a/packages/nc-gui/components/smartsheet/Gallery.vue b/packages/nc-gui/components/smartsheet/Gallery.vue index 2ca93ab3f8..480b2b7bbb 100644 --- a/packages/nc-gui/components/smartsheet/Gallery.vue +++ b/packages/nc-gui/components/smartsheet/Gallery.vue @@ -51,6 +51,7 @@ const { galleryData, changePage, addEmptyRow, + deleteRow, navigateToSiblingRow, } = useViewData(meta, view) @@ -85,6 +86,30 @@ const isRowEmpty = (record: any, col: any) => { return Array.isArray(val) && val.length === 0 } +const { isSqlView } = useSmartsheetStoreOrThrow() + +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 + } +} + const attachments = (record: any): Attachment[] => { try { if (coverImageColumn?.title && record.row[coverImageColumn.title]) { @@ -175,113 +200,138 @@ watch(view, async (nextView) => {