Browse Source

fix: rename modal, cursors not working

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

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

@ -3,13 +3,16 @@ import type { CarouselApi } from '../../nc/Carousel/interface'
import { useAttachmentCell } from './utils'
import { isOffice } from '~/utils/fileUtils'
const { selectedFile, visibleItems, downloadAttachment, removeFile, renameFile, isPublic, isReadonly } = useAttachmentCell()!
const { selectedFile, visibleItems, downloadAttachment, removeFile, renameFile, isPublic, isReadonly, isRenameModalOpen } =
useAttachmentCell()!
const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))
const { isSharedForm } = useSmartsheetStoreOrThrow()
/*
const openComments = ref(false)
*/
const { isUIAllowed } = useRoles()
@ -99,10 +102,35 @@ watchOnce(emblaMainApi, async (emblaMainApi) => {
})
})
const toggleComment = () => {
openComments.value = !openComments.value
onMounted(() => {
document.addEventListener('keydown', onKeyDown)
})
onUnmounted(() => {
document.removeEventListener('keydown', onKeyDown)
})
function onKeyDown(event: KeyboardEvent) {
if (isRenameModalOpen.value) return
const prevKey = ['ArrowLeft', 'Left', 'a', 'A']
const nextKey = ['ArrowRight', 'Right', 'd', 'D']
if (prevKey.includes(event.key)) {
event.preventDefault()
emblaMainApi.value?.scrollPrev()
return
}
if (nextKey.includes(event.key)) {
event.preventDefault()
emblaMainApi.value?.scrollNext()
}
}
/* const toggleComment = () => {
openComments.value = !openComments.value
} */
onMounted(() => {
if (!isPublic.value && !isExpandedFormOpen.value && isUIAllowed('commentList')) {
const { loadComments } = useRowCommentsOrThrow()

6
packages/nc-gui/components/cell/attachment/utils.ts

@ -56,6 +56,8 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
reset: true,
})
const isRenameModalOpen = ref(false)
const { appInfo } = useGlobal()
const defaultAttachmentMeta = {
@ -266,6 +268,7 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
async function renameFile(attachment: AttachmentType, idx: number, updateSelectedFile?: boolean) {
return new Promise<boolean>((resolve) => {
isRenameModalOpen.value = true
const { close } = useDialog(RenameFile, {
title: attachment.title,
onRename: (newTitle: string) => {
@ -277,10 +280,12 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
selectedFile.value = { ...attachment, title: newTitle }
}
isRenameModalOpen.value = false
resolve(true)
},
onCancel: () => {
close()
isRenameModalOpen.value = false
resolve(true)
},
})
@ -429,6 +434,7 @@ export const [useProvideAttachmentCell, useAttachmentCell] = useInjectionState(
stopCamera,
videoStream,
permissionGranted,
isRenameModalOpen,
}
},
'useAttachmentCell',

24
packages/nc-gui/components/nc/Carousel/index.vue

@ -10,30 +10,6 @@ const emits = defineEmits<CarouselEmits>()
const carouselArgs = useProvideCarousel(props, emits)
onMounted(() => {
document.addEventListener('keydown', onKeyDown)
})
onUnmounted(() => {
document.removeEventListener('keydown', onKeyDown)
})
function onKeyDown(event: KeyboardEvent) {
const prevKey = props.orientation === 'vertical' ? ['ArrowUp', 'Up', 'w', 'W'] : ['ArrowLeft', 'Left', 'a', 'A']
const nextKey = props.orientation === 'vertical' ? ['ArrowDown', 'Down', 's', 'S'] : ['ArrowRight', 'Right', 'd', 'D']
if (prevKey.includes(event.key)) {
event.preventDefault()
carouselArgs.scrollPrev()
return
}
if (nextKey.includes(event.key)) {
event.preventDefault()
carouselArgs.scrollNext()
}
}
defineExpose(carouselArgs)
</script>

Loading…
Cancel
Save