|
|
|
@ -3,7 +3,6 @@ import { onKeyDown } from '@vueuse/core'
|
|
|
|
|
import { useProvideAttachmentCell } from './utils' |
|
|
|
|
import { useSortable } from './sort' |
|
|
|
|
import { |
|
|
|
|
IsFormInj, |
|
|
|
|
IsGalleryInj, |
|
|
|
|
inject, |
|
|
|
|
isImage, |
|
|
|
@ -22,24 +21,26 @@ interface Props {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface Emits { |
|
|
|
|
(event: 'update:modelValue', value: string | Record<string, any>): void |
|
|
|
|
(event: 'update:modelValue', value: string | Record<string, any>[]): void |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const { modelValue, rowIndex } = defineProps<Props>() |
|
|
|
|
|
|
|
|
|
const emits = defineEmits<Emits>() |
|
|
|
|
|
|
|
|
|
const isForm = inject(IsFormInj, ref(false)) |
|
|
|
|
|
|
|
|
|
const isGallery = inject(IsGalleryInj, ref(false)) |
|
|
|
|
|
|
|
|
|
const attachmentCellRef = ref<HTMLDivElement>() |
|
|
|
|
|
|
|
|
|
const sortableRef = ref<HTMLDivElement>() |
|
|
|
|
|
|
|
|
|
const { cellRefs } = useSmartsheetStoreOrThrow()! |
|
|
|
|
const currentCellRef = ref() |
|
|
|
|
|
|
|
|
|
const { cellRefs, isSharedForm } = useSmartsheetStoreOrThrow()! |
|
|
|
|
|
|
|
|
|
const { |
|
|
|
|
isPublic, |
|
|
|
|
isForm, |
|
|
|
|
column, |
|
|
|
|
modalVisible, |
|
|
|
|
attachments, |
|
|
|
@ -53,8 +54,6 @@ const {
|
|
|
|
|
storedFiles, |
|
|
|
|
} = useProvideAttachmentCell(updateModelValue) |
|
|
|
|
|
|
|
|
|
const currentCellRef = ref() |
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
[() => rowIndex, isForm, attachmentCellRef], |
|
|
|
|
() => { |
|
|
|
@ -91,19 +90,29 @@ watch(
|
|
|
|
|
(nextModel) => { |
|
|
|
|
if (nextModel) { |
|
|
|
|
try { |
|
|
|
|
attachments.value = ((typeof nextModel === 'string' ? JSON.parse(nextModel) : nextModel) || []).filter(Boolean) |
|
|
|
|
const nextAttachments = ((typeof nextModel === 'string' ? JSON.parse(nextModel) : nextModel) || []).filter(Boolean) |
|
|
|
|
|
|
|
|
|
if (isPublic.value && isForm.value) { |
|
|
|
|
storedFiles.value = nextAttachments |
|
|
|
|
} else { |
|
|
|
|
attachments.value = nextAttachments |
|
|
|
|
} |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error(e) |
|
|
|
|
if (isPublic.value && isForm.value) { |
|
|
|
|
storedFiles.value = [] |
|
|
|
|
} else { |
|
|
|
|
attachments.value = [] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ immediate: true }, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
/** updates attachments array for autosave */ |
|
|
|
|
function updateModelValue(data: string | Record<string, any>) { |
|
|
|
|
emits('update:modelValue', typeof data !== 'string' ? JSON.stringify(data) : data) |
|
|
|
|
function updateModelValue(data: string | Record<string, any>[]) { |
|
|
|
|
emits('update:modelValue', data) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** Close modal on escape press, disable dropzone as well */ |
|
|
|
@ -119,8 +128,6 @@ watch(
|
|
|
|
|
rowState.value[column.value!.title!] = storedFiles.value |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const { isSharedForm } = useSmartsheetStoreOrThrow() |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
@ -159,6 +166,7 @@ const { isSharedForm } = useSmartsheetStoreOrThrow()
|
|
|
|
|
</div> |
|
|
|
|
</a-tooltip> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div v-else class="flex" /> |
|
|
|
|
|
|
|
|
|
<template v-if="visibleItems.length"> |
|
|
|
|