Browse Source

fix(gui): reset attachment cell value on update

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4222/head
Pranav C 2 years ago
parent
commit
a888539bd4
  1. 61
      packages/nc-gui/components/cell/attachment/index.vue

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

@ -115,36 +115,45 @@ watch(
attachments.value = [] attachments.value = []
} }
} }
} else {
if (isPublic.value && isForm.value) {
storedFiles.value = []
} else {
attachments.value = []
}
} }
}, },
{ immediate: true }, {
) immediate: true
}
/** updates attachments array for autosave */ ,
function updateModelValue(data: string | Record<string, any>[]) { )
emits('update:modelValue', data)
}
/** Close modal on escape press, disable dropzone as well */
onKeyDown('Escape', () => {
modalVisible.value = false
isOverDropZone.value = false
})
/** sync storedFiles state with row state */ /** updates attachments array for autosave */
watch( function updateModelValue(data: string | Record<string, any>[]) {
() => storedFiles.value.length || 0, emits('update:modelValue', data)
() => { }
rowState.value[column.value!.title!] = storedFiles.value
},
)
useSelectedCellKeyupListener(inject(ActiveCellInj, ref(false)), (e) => { /** Close modal on escape press, disable dropzone as well */
if (e.key === 'Enter' && !isReadonly.value) { onKeyDown('Escape', () => {
e.stopPropagation() modalVisible.value = false
modalVisible.value = true 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
}
})
</script> </script>
<template> <template>

Loading…
Cancel
Save