diff --git a/src/api/communication.js b/src/api/communication.js
index 9ab36961..f3430ae3 100644
--- a/src/api/communication.js
+++ b/src/api/communication.js
@@ -1,21 +1,17 @@
-
+import { post } from 'src/api/common'
import _ from 'lodash'
-import Vue from 'vue'
-export function createFax (options) {
- return new Promise((resolve, reject) => {
- var formData = new FormData()
- var fields = _.clone(options)
- delete fields.file
- var json = JSON.stringify(fields)
- formData.append('json', json)
- if (options.file) {
- formData.append('faxfile', options.file)
- }
- Vue.http.post('api/faxes/', formData).then(() => {
- resolve()
- }).catch((err) => {
- reject(err)
- })
+export async function createFax (options) {
+ const formData = new FormData()
+ const fields = _.clone(options)
+ delete fields.faxfile
+ const json = JSON.stringify(fields)
+ formData.append('json', json)
+ if (options.faxfile) {
+ formData.append('faxfile', options.faxfile)
+ }
+ return await post({
+ resource: 'faxes',
+ body: formData
})
}
diff --git a/src/components/CscSendFax.vue b/src/components/CscSendFax.vue
index 67b89ee6..a64be5a2 100644
--- a/src/components/CscSendFax.vue
+++ b/src/components/CscSendFax.vue
@@ -51,7 +51,7 @@
/>
@@ -61,6 +61,7 @@
icon="clear"
color="default"
:label="$t('Cancel')"
+ @click="resetFormData"
/>
0) || this.form.faxfile
},
formDisabled () {
return !this.$v.form.$anyDirty ||
@@ -172,9 +166,12 @@ export default {
})
}
},
+ mounted () {
+ this.resetFormData()
+ },
methods: {
toggleFileSelected (value) {
- this.selectedFile = value
+ this.form.faxfile = value
},
sendFax () {
if (this.$v.form.$error ||
@@ -182,10 +179,21 @@ export default {
showGlobalError(this.$t('You have invalid form input. Please check and try again.'))
} else {
this.$store.dispatch('communication/createFax', this.form)
+ this.resetFormData()
}
},
error (state) {
this.destinationError = state
+ },
+ resetFormData () {
+ this.form = {
+ destination: '',
+ pageHeader: null,
+ data: null,
+ quality: this.$faxQualityOptionsDefault.value,
+ faxfile: null
+ }
+ this.$v.$reset()
}
}
}
diff --git a/src/components/form/CscInputFile.vue b/src/components/form/CscInputFile.vue
index a90401d8..3bc51e3f 100644
--- a/src/components/form/CscInputFile.vue
+++ b/src/components/form/CscInputFile.vue
@@ -32,11 +32,12 @@
size="sm"
unelevated
:label="$t('Reset')"
- @click="selectedFile = null; $refs.fileInput.$el.value = null"
+ @click="resetFile"
/>