aboutsummaryrefslogtreecommitdiff
path: root/src/components/importer/importer.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/importer/importer.js')
-rw-r--r--src/components/importer/importer.js42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/components/importer/importer.js b/src/components/importer/importer.js
index 44d02c93..c5f9e4d2 100644
--- a/src/components/importer/importer.js
+++ b/src/components/importer/importer.js
@@ -1,10 +1,34 @@
const Importer = {
+ props: {
+ submitHandler: {
+ type: Function,
+ required: true
+ },
+ submitButtonLabel: {
+ type: String,
+ default () {
+ return this.$t('importer.submit')
+ }
+ },
+ successMessage: {
+ type: String,
+ default () {
+ return this.$t('importer.success')
+ }
+ },
+ errorMessage: {
+ type: String,
+ default () {
+ return this.$t('importer.error')
+ }
+ }
+ },
data () {
return {
file: null,
error: false,
success: false,
- uploading: false
+ submitting: false
}
},
methods: {
@@ -12,16 +36,12 @@ const Importer = {
this.file = this.$refs.input.files[0]
},
submit () {
- this.uploading = true
- this.$store.state.api.backendInteractor.followImport(this.file)
- .then((status) => {
- if (status) {
- this.success = true
- } else {
- this.error = true
- }
- this.uploading = false
- })
+ this.dismiss()
+ this.submitting = true
+ this.submitHandler(this.file)
+ .then(() => { this.success = true })
+ .catch(() => { this.error = true })
+ .finally(() => { this.submitting = false })
},
dismiss () {
this.success = false