Allow delete attachments from builder data section
This commit is contained in:
parent
df620fb9f7
commit
1f66cf9a83
|
@ -95,9 +95,11 @@
|
||||||
"change",
|
"change",
|
||||||
value.filter((x, idx) => idx !== selectedImageIdx)
|
value.filter((x, idx) => idx !== selectedImageIdx)
|
||||||
)
|
)
|
||||||
|
if (deleteAttachments) {
|
||||||
await deleteAttachments(
|
await deleteAttachments(
|
||||||
value.filter((x, idx) => idx === selectedImageIdx).map(item => item.key)
|
value.filter((x, idx) => idx === selectedImageIdx).map(item => item.key)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
selectedImageIdx = 0
|
selectedImageIdx = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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}
|
||||||
|
|
|
@ -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}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -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,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in New Issue