Basic frontend uploader component

This commit is contained in:
dandds
2019-06-05 17:10:05 -04:00
parent e327a0bada
commit fb430e76e9
8 changed files with 114 additions and 20 deletions

View File

@@ -9,6 +9,7 @@ import levelofwarrant from '../levelofwarrant'
import multicheckboxinput from '../multi_checkbox_input'
import optionsinput from '../options_input'
import textinput from '../text_input'
import uploadinput from '../upload_input'
import toggler from '../toggler'
export default {
@@ -23,6 +24,7 @@ export default {
optionsinput,
textinput,
toggler,
uploadinput,
},
mixins: [FormMixin],
}

View File

@@ -29,7 +29,7 @@ export default {
const pdf = this.initialData
return {
showUpload: !pdf || this.uploadErrors.length > 0,
attachment: pdf || null,
}
},
@@ -37,5 +37,24 @@ export default {
showUploadInput: function() {
this.showUpload = true
},
addAttachment: function(e) {
this.attachment = e.target.value
},
removeAttachment: function(e) {
e.preventDefault()
this.attachment = null
this.$refs.attachmentInput.value = null
},
},
computed: {
baseName: function() {
if (this.attachment) {
return this.attachment.split(/[\\/]/).pop()
}
},
hasAttachment: function() {
return !!this.attachment
},
},
}