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