generate pdfs from images
This commit is contained in:
@@ -18,20 +18,27 @@ export default targetable(class extends HTMLElement {
|
||||
this.toggleState()
|
||||
|
||||
fetch(this.dataset.src).then((response) => response.json()).then((urls) => {
|
||||
urls.forEach((url) => {
|
||||
fetch(url).then(async (resp) => {
|
||||
const blobUrl = URL.createObjectURL(await resp.blob())
|
||||
const link = document.createElement('a')
|
||||
const fileRequests = urls.map((url) => {
|
||||
return () => {
|
||||
return fetch(url).then(async (resp) => {
|
||||
const blobUrl = URL.createObjectURL(await resp.blob())
|
||||
const link = document.createElement('a')
|
||||
|
||||
link.href = blobUrl
|
||||
link.setAttribute('download', resp.headers.get('content-disposition').split('"')[1])
|
||||
link.href = blobUrl
|
||||
link.setAttribute('download', decodeURI(resp.headers.get('content-disposition').split('"')[1]))
|
||||
|
||||
link.click()
|
||||
link.click()
|
||||
|
||||
URL.revokeObjectURL(url)
|
||||
})
|
||||
URL.revokeObjectURL(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
}).finally(() => {
|
||||
|
||||
fileRequests.reduce(
|
||||
(prevPromise, request) => prevPromise.then(() => request()),
|
||||
Promise.resolve()
|
||||
)
|
||||
|
||||
this.toggleState()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -90,20 +90,27 @@ export default {
|
||||
this.isDownloading = true
|
||||
|
||||
fetch(`/submitters/${this.submitterSlug}/download`).then((response) => response.json()).then((urls) => {
|
||||
urls.forEach((url) => {
|
||||
fetch(url).then(async (resp) => {
|
||||
const blobUrl = URL.createObjectURL(await resp.blob())
|
||||
const link = document.createElement('a')
|
||||
const fileRequests = urls.map((url) => {
|
||||
return () => {
|
||||
return fetch(url).then(async (resp) => {
|
||||
const blobUrl = URL.createObjectURL(await resp.blob())
|
||||
const link = document.createElement('a')
|
||||
|
||||
link.href = blobUrl
|
||||
link.setAttribute('download', resp.headers.get('content-disposition').split('"')[1])
|
||||
link.href = blobUrl
|
||||
link.setAttribute('download', decodeURI(resp.headers.get('content-disposition').split('"')[1]))
|
||||
|
||||
link.click()
|
||||
link.click()
|
||||
|
||||
URL.revokeObjectURL(url)
|
||||
})
|
||||
URL.revokeObjectURL(url)
|
||||
})
|
||||
}
|
||||
})
|
||||
}).finally(() => {
|
||||
|
||||
fileRequests.reduce(
|
||||
(prevPromise, request) => prevPromise.then(() => request()),
|
||||
Promise.resolve()
|
||||
)
|
||||
|
||||
this.isDownloading = false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@
|
||||
:field="currentField"
|
||||
:attachments-index="attachmentsIndex"
|
||||
:submitter-slug="submitterSlug"
|
||||
@attached="attachments.push($event)"
|
||||
@attached="[attachments.push($event), $refs.areas.scrollIntoField(currentField)]"
|
||||
/>
|
||||
<SignatureStep
|
||||
v-else-if="currentField.type === 'signature'"
|
||||
@@ -208,7 +208,7 @@
|
||||
:field="currentField"
|
||||
:attachments-index="attachmentsIndex"
|
||||
:submitter-slug="submitterSlug"
|
||||
@attached="attachments.push($event)"
|
||||
@attached="[attachments.push($event), $refs.areas.scrollIntoField(currentField)]"
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-8">
|
||||
|
||||
Reference in New Issue
Block a user