|
|
@ -51,6 +51,7 @@ const { |
|
|
|
galleryData, |
|
|
|
galleryData, |
|
|
|
changePage, |
|
|
|
changePage, |
|
|
|
addEmptyRow, |
|
|
|
addEmptyRow, |
|
|
|
|
|
|
|
deleteRow, |
|
|
|
navigateToSiblingRow, |
|
|
|
navigateToSiblingRow, |
|
|
|
} = useViewData(meta, view) |
|
|
|
} = useViewData(meta, view) |
|
|
|
|
|
|
|
|
|
|
@ -85,6 +86,30 @@ const isRowEmpty = (record: any, col: any) => { |
|
|
|
return Array.isArray(val) && val.length === 0 |
|
|
|
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[] => { |
|
|
|
const attachments = (record: any): Attachment[] => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (coverImageColumn?.title && record.row[coverImageColumn.title]) { |
|
|
|
if (coverImageColumn?.title && record.row[coverImageColumn.title]) { |
|
|
@ -175,113 +200,138 @@ watch(view, async (nextView) => { |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div class="flex flex-col h-full w-full overflow-auto nc-gallery" data-testid="nc-gallery-wrapper"> |
|
|
|
<a-dropdown |
|
|
|
<div class="nc-gallery-container grid gap-2 my-4 px-3"> |
|
|
|
v-model:visible="contextMenu" |
|
|
|
<div v-for="record in data" :key="`record-${record.row.id}`"> |
|
|
|
:trigger="isSqlView ? [] : ['contextmenu']" |
|
|
|
<LazySmartsheetRow :row="record"> |
|
|
|
overlay-class-name="nc-dropdown-grid-context-menu" |
|
|
|
<a-card |
|
|
|
> |
|
|
|
hoverable |
|
|
|
<template #overlay> |
|
|
|
class="!rounded-lg h-full overflow-hidden break-all max-w-[450px]" |
|
|
|
<a-menu class="shadow !rounded !py-0" @click="contextMenu = false"> |
|
|
|
:data-testid="`nc-gallery-card-${record.row.id}`" |
|
|
|
<a-menu-item v-if="contextMenuTarget" @click="deleteRow(contextMenuTarget.row)"> |
|
|
|
@click="expandFormClick($event, record)" |
|
|
|
<div v-e="['a:row:delete']" class="nc-project-menu-item"> |
|
|
|
> |
|
|
|
<!-- Delete Row --> |
|
|
|
<template v-if="galleryData?.fk_cover_image_col_id" #cover> |
|
|
|
{{ $t('activity.deleteRow') }} |
|
|
|
<a-carousel v-if="!reloadAttachments && attachments(record).length" autoplay class="gallery-carousel" arrows> |
|
|
|
</div> |
|
|
|
<template #customPaging> |
|
|
|
</a-menu-item> |
|
|
|
<a> |
|
|
|
|
|
|
|
<div class="pt-[12px]"> |
|
|
|
<a-menu-item v-if="contextMenuTarget" @click="openNewRecordFormHook.trigger()"> |
|
|
|
<div></div> |
|
|
|
<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="flex flex-col h-full w-full overflow-auto nc-gallery" data-testid="nc-gallery-wrapper"> |
|
|
|
|
|
|
|
<div class="nc-gallery-container grid gap-2 my-4 px-3"> |
|
|
|
|
|
|
|
<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> |
|
|
|
|
|
|
|
<template #customPaging> |
|
|
|
|
|
|
|
<a> |
|
|
|
|
|
|
|
<div class="pt-[12px]"> |
|
|
|
|
|
|
|
<div></div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</a> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #prevArrow> |
|
|
|
|
|
|
|
<div style="z-index: 1"></div> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #nextArrow> |
|
|
|
|
|
|
|
<div style="z-index: 1"></div> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template v-for="(attachment, index) in attachments(record)"> |
|
|
|
|
|
|
|
<LazyCellAttachmentImage |
|
|
|
|
|
|
|
v-if="isImage(attachment.title, attachment.mimetype ?? attachment.type)" |
|
|
|
|
|
|
|
:key="`carousel-${record.row.id}-${index}`" |
|
|
|
|
|
|
|
class="h-52 object-contain" |
|
|
|
|
|
|
|
:srcs="getPossibleAttachmentSrc(attachment)" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
</a-carousel> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<MdiFileImageBox v-else class="w-full h-48 my-4 text-cool-gray-200" /> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div v-for="col in fieldsWithoutCover" :key="`record-${record.row.id}-${col.id}`"> |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
v-if="!isRowEmpty(record, col) || isLTAR(col.uidt)" |
|
|
|
|
|
|
|
class="flex flex-col space-y-1 px-4 mb-6 bg-gray-50 rounded-lg w-full" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<div class="flex flex-row w-full justify-start border-b-1 border-gray-100 py-2.5"> |
|
|
|
|
|
|
|
<div class="w-full text-gray-600"> |
|
|
|
|
|
|
|
<LazySmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" :hide-menu="true" /> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<LazySmartsheetHeaderCell v-else :column="col" :hide-menu="true" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</a> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #prevArrow> |
|
|
|
|
|
|
|
<div style="z-index: 1"></div> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template #nextArrow> |
|
|
|
|
|
|
|
<div style="z-index: 1"></div> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<template v-for="(attachment, index) in attachments(record)"> |
|
|
|
|
|
|
|
<LazyCellAttachmentImage |
|
|
|
|
|
|
|
v-if="isImage(attachment.title, attachment.mimetype ?? attachment.type)" |
|
|
|
|
|
|
|
:key="`carousel-${record.row.id}-${index}`" |
|
|
|
|
|
|
|
class="h-52 object-contain" |
|
|
|
|
|
|
|
:srcs="getPossibleAttachmentSrc(attachment)" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
</a-carousel> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<MdiFileImageBox v-else class="w-full h-48 my-4 text-cool-gray-200" /> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div v-for="col in fieldsWithoutCover" :key="`record-${record.row.id}-${col.id}`"> |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
v-if="!isRowEmpty(record, col) || isLTAR(col.uidt)" |
|
|
|
|
|
|
|
class="flex flex-col space-y-1 px-4 mb-6 bg-gray-50 rounded-lg w-full" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<div class="flex flex-row w-full justify-start border-b-1 border-gray-100 py-2.5"> |
|
|
|
|
|
|
|
<div class="w-full text-gray-600"> |
|
|
|
|
|
|
|
<LazySmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" :hide-menu="true" /> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<LazySmartsheetHeaderCell v-else :column="col" :hide-menu="true" /> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-row w-full pb-3 pt-2 pl-2 items-center justify-start"> |
|
|
|
<div class="flex flex-row w-full pb-3 pt-2 pl-2 items-center justify-start"> |
|
|
|
<LazySmartsheetVirtualCell |
|
|
|
<LazySmartsheetVirtualCell |
|
|
|
v-if="isVirtualCol(col)" |
|
|
|
v-if="isVirtualCol(col)" |
|
|
|
v-model="record.row[col.title]" |
|
|
|
v-model="record.row[col.title]" |
|
|
|
:column="col" |
|
|
|
:column="col" |
|
|
|
:row="record" |
|
|
|
:row="record" |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<LazySmartsheetCell |
|
|
|
<LazySmartsheetCell |
|
|
|
v-else |
|
|
|
v-else |
|
|
|
v-model="record.row[col.title]" |
|
|
|
v-model="record.row[col.title]" |
|
|
|
:column="col" |
|
|
|
:column="col" |
|
|
|
:edit-enabled="false" |
|
|
|
:edit-enabled="false" |
|
|
|
:read-only="true" |
|
|
|
:read-only="true" |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</a-card> |
|
|
|
</a-card> |
|
|
|
</LazySmartsheetRow> |
|
|
|
</LazySmartsheetRow> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="flex-1" /> |
|
|
|
<div class="flex-1" /> |
|
|
|
|
|
|
|
|
|
|
|
<LazySmartsheetPagination /> |
|
|
|
<LazySmartsheetPagination /> |
|
|
|
|
|
|
|
</div> |
|
|
|
<Suspense> |
|
|
|
</a-dropdown> |
|
|
|
<LazySmartsheetExpandedForm |
|
|
|
|
|
|
|
v-if="expandedFormRow && expandedFormDlg" |
|
|
|
<Suspense> |
|
|
|
v-model="expandedFormDlg" |
|
|
|
<LazySmartsheetExpandedForm |
|
|
|
:row="expandedFormRow" |
|
|
|
v-if="expandedFormRow && expandedFormDlg" |
|
|
|
:state="expandedFormRowState" |
|
|
|
v-model="expandedFormDlg" |
|
|
|
:meta="meta" |
|
|
|
:row="expandedFormRow" |
|
|
|
:view="view" |
|
|
|
:state="expandedFormRowState" |
|
|
|
/> |
|
|
|
:meta="meta" |
|
|
|
</Suspense> |
|
|
|
:view="view" |
|
|
|
|
|
|
|
/> |
|
|
|
<Suspense> |
|
|
|
</Suspense> |
|
|
|
<LazySmartsheetExpandedForm |
|
|
|
|
|
|
|
v-if="expandedFormOnRowIdDlg" |
|
|
|
<Suspense> |
|
|
|
:key="route.query.rowId" |
|
|
|
<LazySmartsheetExpandedForm |
|
|
|
v-model="expandedFormOnRowIdDlg" |
|
|
|
v-if="expandedFormOnRowIdDlg" |
|
|
|
:row="{ row: {}, oldRow: {}, rowMeta: {} }" |
|
|
|
:key="route.query.rowId" |
|
|
|
:meta="meta" |
|
|
|
v-model="expandedFormOnRowIdDlg" |
|
|
|
:row-id="route.query.rowId" |
|
|
|
:row="{ row: {}, oldRow: {}, rowMeta: {} }" |
|
|
|
:view="view" |
|
|
|
:meta="meta" |
|
|
|
show-next-prev-icons |
|
|
|
:row-id="route.query.rowId" |
|
|
|
@next="navigateToSiblingRow(NavigateDir.NEXT)" |
|
|
|
:view="view" |
|
|
|
@prev="navigateToSiblingRow(NavigateDir.PREV)" |
|
|
|
show-next-prev-icons |
|
|
|
/> |
|
|
|
@next="navigateToSiblingRow(NavigateDir.NEXT)" |
|
|
|
</Suspense> |
|
|
|
@prev="navigateToSiblingRow(NavigateDir.PREV)" |
|
|
|
</div> |
|
|
|
/> |
|
|
|
|
|
|
|
</Suspense> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<style scoped> |
|
|
|
<style scoped> |
|
|
|