2020-10-21 00:01:28 +03:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import {
|
|
|
|
faCircleNotch,
|
|
|
|
faTimes
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
faCircleNotch,
|
|
|
|
faTimes
|
|
|
|
)
|
|
|
|
|
2019-03-29 21:58:20 -04:00
|
|
|
const Importer = {
|
2019-03-30 05:10:57 -04:00
|
|
|
props: {
|
|
|
|
submitHandler: {
|
|
|
|
type: Function,
|
|
|
|
required: true
|
|
|
|
},
|
2021-04-25 14:12:34 +03:00
|
|
|
submitButtonLabel: { type: String },
|
|
|
|
successMessage: { type: String },
|
|
|
|
errorMessage: { type: String }
|
2019-03-30 05:10:57 -04:00
|
|
|
},
|
2019-03-29 21:58:20 -04:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
file: null,
|
|
|
|
error: false,
|
|
|
|
success: false,
|
2019-03-30 05:10:57 -04:00
|
|
|
submitting: false
|
2019-03-29 21:58:20 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
change () {
|
|
|
|
this.file = this.$refs.input.files[0]
|
|
|
|
},
|
|
|
|
submit () {
|
2019-03-30 05:10:57 -04:00
|
|
|
this.dismiss()
|
|
|
|
this.submitting = true
|
|
|
|
this.submitHandler(this.file)
|
|
|
|
.then(() => { this.success = true })
|
|
|
|
.catch(() => { this.error = true })
|
|
|
|
.finally(() => { this.submitting = false })
|
2019-03-29 21:58:20 -04:00
|
|
|
},
|
|
|
|
dismiss () {
|
|
|
|
this.success = false
|
|
|
|
this.error = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Importer
|