You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/app/javascript/submission_form/completed.vue

71 lines
1.5 KiB

<template>
<div>
<p>
Form completed - thanks!
</p>
<button @click.prevent="sendCopyToEmail">
<span v-if="isSendingCopy">
Sending
</span>
<span>
Send copy to email
</span>
</button>
<button @click.prevent="download">
<span v-if="isDownloading">
Downloading
</span>
<span>
Download copy
</span>
</button>
</div>
</template>
<script>
export default {
name: 'FormCompleted',
props: {
submissionSlug: {
type: String,
required: true
}
},
data () {
return {
isSendingCopy: false,
isDownloading: false
}
},
methods: {
sendCopyToEmail () {
this.isSendingCopy = true
fetch(`/send_submission_email.json?submission_slug=${this.submissionSlug}`, {
method: 'POST'
}).finally(() => {
this.isSendingCopy = false
})
},
download () {
this.isDownloading = true
fetch(`/submissions/${this.submissionSlug}/download`).then(async (response) => {
const blob = new Blob([await response.text()], { type: `${response.headers.get('content-type')};charset=utf-8;` })
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.setAttribute('download', response.headers.get('content-disposition').split('"')[1])
link.click()
URL.revokeObjectURL(url)
}).finally(() => {
this.isDownloading = false
})
}
}
}
</script>