Browse Source

fix: add comments and review fixes

pull/8990/head
DarkPhoenix2704 4 months ago
parent
commit
f0b22f7c53
No known key found for this signature in database
GPG Key ID: 3F76B10622A07849
  1. 37
      packages/nc-gui/components/cell/attachment/Carousel.vue
  2. 2
      packages/nc-gui/components/cell/attachment/index.vue

37
packages/nc-gui/components/cell/attachment/Carousel.vue

@ -45,7 +45,7 @@ const { getPossibleAttachmentSrc } = useAttachment()
useEventListener(container, 'click', (e) => { useEventListener(container, 'click', (e) => {
const target = e.target as HTMLElement const target = e.target as HTMLElement
if (!target.closest('.keep-open') && !target.closest('.nc-button') && !target?.closest('img') && !target?.closest('video')) { if (!target.closest('.keep-open') && !target.closest('.nc-button') && !target.closest('img') && !target.closest('video')) {
selectedFile.value = false selectedFile.value = false
} }
}) })
@ -81,9 +81,12 @@ const goNext = () => {
emblaThumbnailApi.value.scrollNext() emblaThumbnailApi.value.scrollNext()
} }
// When the carousel is initialized, we set the selected index to the index of the selected file
// and scroll to that index. We only need to do this once, so we use watchOnce.
watchOnce(emblaMainApi, async (emblaMainApi) => { watchOnce(emblaMainApi, async (emblaMainApi) => {
if (!emblaMainApi) return if (!emblaMainApi) return
// The focus is set to the container so that the keyboard navigation works
container.value?.focus() container.value?.focus()
emblaThumbnailApi.value?.on('reInit', onSelect) emblaThumbnailApi.value?.on('reInit', onSelect)
@ -131,7 +134,7 @@ function onKeyDown(event: KeyboardEvent) {
/* const toggleComment = () => { /* const toggleComment = () => {
openComments.value = !openComments.value openComments.value = !openComments.value
} */ }
onMounted(() => { onMounted(() => {
if (!isPublic.value && !isExpandedFormOpen.value && isUIAllowed('commentList')) { if (!isPublic.value && !isExpandedFormOpen.value && isUIAllowed('commentList')) {
@ -139,6 +142,11 @@ onMounted(() => {
loadComments() loadComments()
} }
}) })
*/
const initEmblaApi = (val: any) => {
emblaMainApi.value = val
}
</script> </script>
<template> <template>
@ -170,10 +178,7 @@ onMounted(() => {
</h3> </h3>
</div> </div>
<NcCarousel <NcCarousel class="!absolute inset-y-16 inset-x-24 keep-open flex justify-center items-center" @init-api="initEmblaApi">
class="!absolute inset-y-16 inset-x-24 keep-open flex justify-center items-center"
@init-api="(val) => (emblaMainApi = val)"
>
<NcCarouselContent> <NcCarouselContent>
<NcCarouselItem v-for="(item, index) in visibleItems" :key="index"> <NcCarouselItem v-for="(item, index) in visibleItems" :key="index">
<div v-if="selectedIndex === index" class="justify-center w-full h-full flex items-center"> <div v-if="selectedIndex === index" class="justify-center w-full h-full flex items-center">
@ -211,18 +216,10 @@ onMounted(() => {
</NcCarouselContent> </NcCarouselContent>
</NcCarousel> </NcCarousel>
<div <div v-if="emblaMainApi?.canScrollPrev()" class="left-2 carousel-navigation" @click="goPrev">
v-if="emblaMainApi?.canScrollPrev()"
class="absolute keep-open text-gray-400 hover:text-white cursor-pointer text-white left-2 h-full flex items-center inset-y-0 my-0"
@click="goPrev"
>
<component :is="iconMap.arrowLeft" class="text-7xl" /> <component :is="iconMap.arrowLeft" class="text-7xl" />
</div> </div>
<div <div v-if="emblaMainApi?.canScrollNext()" class="right-2 carousel-navigation" @click="goNext">
v-if="emblaMainApi?.canScrollNext()"
class="absolute keep-open text-gray-400 hover:text-white cursor-pointer text-white right-2 h-full flex items-center inset-y-0 my-0"
@click="goNext"
>
<component :is="iconMap.arrowRight" class="text-7xl" /> <component :is="iconMap.arrowRight" class="text-7xl" />
</div> </div>
@ -346,9 +343,15 @@ onMounted(() => {
</GeneralOverlay> </GeneralOverlay>
</template> </template>
<style scoped lang="scss">
.carousel-navigation {
@apply absolute keep-open text-gray-400 hover:text-white cursor-pointer text-white h-full flex items-center inset-y-0 my-0;
}
</style>
<style lang="scss"> <style lang="scss">
.nc-attachment-carousel { .nc-attachment-carousel {
width: max-content; @apply w-max;
} }
.carousel-container { .carousel-container {

2
packages/nc-gui/components/cell/attachment/index.vue

@ -229,7 +229,7 @@ const handleFileDelete = (i: number) => {
v-if="isImage(item.title, item.mimetype)" v-if="isImage(item.title, item.mimetype)"
:srcs="getPossibleAttachmentSrc(item)" :srcs="getPossibleAttachmentSrc(item)"
object-fit="cover" object-fit="cover"
class="!w-full h-42 object-cover !m-0 rounded-t-[5px] justify-center" class="!w-full !h-42 object-cover !m-0 rounded-t-[5px] justify-center"
@click="selectedFile = item" @click="selectedFile = item"
/> />

Loading…
Cancel
Save