1
0
Fork 0
mirror of synced 2024-09-03 11:11:49 +12:00

Allow delete attachments from builder data section

This commit is contained in:
Mel O'Hagan 2022-08-15 15:46:55 +01:00
parent 9fb5b2a37d
commit 1200f4d2a0
5 changed files with 34 additions and 3 deletions

View file

@ -95,9 +95,11 @@
"change", "change",
value.filter((x, idx) => idx !== selectedImageIdx) value.filter((x, idx) => idx !== selectedImageIdx)
) )
await deleteAttachments( if (deleteAttachments) {
value.filter((x, idx) => idx === selectedImageIdx).map(item => item.key) await deleteAttachments(
) value.filter((x, idx) => idx === selectedImageIdx).map(item => item.key)
)
}
selectedImageIdx = 0 selectedImageIdx = 0
} }

View file

@ -10,6 +10,7 @@
export let error = null export let error = null
export let fileSizeLimit = undefined export let fileSizeLimit = undefined
export let processFiles = undefined export let processFiles = undefined
export let deleteAttachments = undefined
export let handleFileTooLarge = undefined export let handleFileTooLarge = undefined
export let handleTooManyFiles = undefined export let handleTooManyFiles = undefined
export let gallery = true export let gallery = true
@ -30,6 +31,7 @@
{value} {value}
{fileSizeLimit} {fileSizeLimit}
{processFiles} {processFiles}
{deleteAttachments}
{handleFileTooLarge} {handleFileTooLarge}
{handleTooManyFiles} {handleTooManyFiles}
{gallery} {gallery}

View file

@ -27,6 +27,14 @@
return [] return []
} }
} }
async function deleteAttachments(fileList) {
try {
return await API.deleteBuilderAttachments(fileList)
} catch (error) {
return []
}
}
</script> </script>
<Dropzone <Dropzone
@ -34,5 +42,6 @@
{label} {label}
{...$$restProps} {...$$restProps}
{processFiles} {processFiles}
{deleteAttachments}
{handleFileTooLarge} {handleFileTooLarge}
/> />

View file

@ -75,5 +75,18 @@ export const buildAttachmentEndpoints = API => {
}, },
}) })
}, },
/**
* Deletes attachments from the builder bucket.
* @param keys the attachments to delete
*/
deleteBuilderAttachments: async keys => {
return await API.post({
url: `/api/attachments/delete`,
body: {
keys,
},
})
},
} }
} }

View file

@ -38,6 +38,11 @@ router
// TODO: for now this builder endpoint is not authorized/secured, will need to be // TODO: for now this builder endpoint is not authorized/secured, will need to be
.get("/builder/:file*", controller.serveBuilder) .get("/builder/:file*", controller.serveBuilder)
.post("/api/attachments/process", authorized(BUILDER), controller.uploadFile) .post("/api/attachments/process", authorized(BUILDER), controller.uploadFile)
.post(
"/api/attachments/delete",
authorized(BUILDER),
controller.deleteObjects
)
.post("/api/beta/:feature", controller.toggleBetaUiFeature) .post("/api/beta/:feature", controller.toggleBetaUiFeature)
.post( .post(
"/api/attachments/:tableId/upload", "/api/attachments/:tableId/upload",