|
|
|
@ -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,18 +172,66 @@ 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 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
|
<div class="flex flex-col h-full w-full overflow-auto nc-gallery" data-testid="nc-gallery-wrapper"> |
|
|
|
|
<a-dropdown |
|
|
|
|
v-model:visible="contextMenu" |
|
|
|
|
:trigger="isSqlView ? [] : ['contextmenu']" |
|
|
|
|
overlay-class-name="nc-dropdown-grid-context-menu" |
|
|
|
|
> |
|
|
|
|
<template #overlay> |
|
|
|
|
<a-menu class="shadow !rounded !py-0" @click="contextMenu = false"> |
|
|
|
|
<a-menu-item v-if="contextMenuTarget" @click="deleteRow(contextMenuTarget.row)"> |
|
|
|
|
<div v-e="['a:row:delete']" class="nc-project-menu-item"> |
|
|
|
|
<!-- Delete Row --> |
|
|
|
|
{{ $t('activity.deleteRow') }} |
|
|
|
|
</div> |
|
|
|
|
</a-menu-item> |
|
|
|
|
|
|
|
|
|
<a-menu-item v-if="contextMenuTarget" @click="openNewRecordFormHook.trigger()"> |
|
|
|
|
<div v-e="['a:row:insert']" class="nc-project-menu-item"> |
|
|
|
|
<!-- Insert New Row --> |
|
|
|
|
{{ $t('activity.insertRow') }} |
|
|
|
|
</div> |
|
|
|
|
</a-menu-item> |
|
|
|
|
</a-menu> |
|
|
|
|
</template> |
|
|
|
|
<div class="nc-gallery-container grid gap-2 my-4 px-3"> |
|
|
|
|
<div v-for="record in data" :key="`record-${record.row.id}`"> |
|
|
|
|
<!-- v-for="(row, rowIndex) of data --> |
|
|
|
|
<div v-for="(record, rowIndex) in data" :key="`record-${record.row.id}`"> |
|
|
|
|
<LazySmartsheetRow :row="record"> |
|
|
|
|
<a-card |
|
|
|
|
hoverable |
|
|
|
|
class="!rounded-lg h-full overflow-hidden break-all max-w-[450px]" |
|
|
|
|
:data-testid="`nc-gallery-card-${record.row.id}`" |
|
|
|
|
@click="expandFormClick($event, record)" |
|
|
|
|
@contextmenu="showContextMenu($event, { row: rowIndex })" |
|
|
|
|
> |
|
|
|
|
<template v-if="galleryData?.fk_cover_image_col_id" #cover> |
|
|
|
|
<a-carousel v-if="!reloadAttachments && attachments(record).length" autoplay class="gallery-carousel" arrows> |
|
|
|
@ -247,6 +299,7 @@ watch(view, async (nextView) => {
|
|
|
|
|
</LazySmartsheetRow> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</a-dropdown> |
|
|
|
|
|
|
|
|
|
<div class="flex-1" /> |
|
|
|
|
|
|
|
|
|