From a888539bd4eff582b4a8128a0470b86cddc7b32b Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sun, 6 Nov 2022 12:55:16 +0530 Subject: [PATCH] fix(gui): reset attachment cell value on update Signed-off-by: Pranav C --- .../components/cell/attachment/index.vue | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/packages/nc-gui/components/cell/attachment/index.vue b/packages/nc-gui/components/cell/attachment/index.vue index 7c785e32d6..b8d7a271d9 100644 --- a/packages/nc-gui/components/cell/attachment/index.vue +++ b/packages/nc-gui/components/cell/attachment/index.vue @@ -115,36 +115,45 @@ watch( attachments.value = [] } } + } else { + if (isPublic.value && isForm.value) { + storedFiles.value = [] + } else { + attachments.value = [] + } } }, - { immediate: true }, -) - -/** updates attachments array for autosave */ -function updateModelValue(data: string | Record[]) { - emits('update:modelValue', data) -} - -/** Close modal on escape press, disable dropzone as well */ -onKeyDown('Escape', () => { - modalVisible.value = false - isOverDropZone.value = false -}) + { + immediate: true + } + , + ) -/** sync storedFiles state with row state */ -watch( - () => storedFiles.value.length || 0, - () => { - rowState.value[column.value!.title!] = storedFiles.value - }, -) + /** updates attachments array for autosave */ + function updateModelValue(data: string | Record[]) { + emits('update:modelValue', data) + } -useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e) => { - if (e.key === 'Enter' && !isReadonly.value) { - e.stopPropagation() - modalVisible.value = true - } -}) + /** Close modal on escape press, disable dropzone as well */ + onKeyDown('Escape', () => { + modalVisible.value = false + isOverDropZone.value = false + }) + + /** sync storedFiles state with row state */ + watch( + () => storedFiles.value.length || 0, + () => { + rowState.value[column.value!.title!] = storedFiles.value + }, + ) + + useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e) => { + if (e.key === 'Enter' && !isReadonly.value) { + e.stopPropagation() + modalVisible.value = true + } + })