- Populate the POSTed form with additional data from the existing TO model. This way the pdf attachment has to be explicitly overwritten. - Adjust the frontend so that if there is an existing PDF, it only sends a file input back if the user removes the existing PDF.
67 lines
1.3 KiB
JavaScript
67 lines
1.3 KiB
JavaScript
import createNumberMask from 'text-mask-addons/dist/createNumberMask'
|
|
import { conformToMask } from 'vue-text-mask'
|
|
|
|
import FormMixin from '../mixins/form'
|
|
import textinput from './text_input'
|
|
import optionsinput from './options_input'
|
|
|
|
export default {
|
|
name: 'uploadinput',
|
|
|
|
mixins: [FormMixin],
|
|
|
|
components: {
|
|
textinput,
|
|
optionsinput,
|
|
},
|
|
|
|
props: {
|
|
initialData: {
|
|
type: String,
|
|
},
|
|
initialErrors: {
|
|
type: Boolean,
|
|
},
|
|
},
|
|
|
|
data: function() {
|
|
return {
|
|
hasInitialData: !!this.initialData,
|
|
attachment: this.initialData || null,
|
|
showErrors: this.initialErrors,
|
|
changed: false,
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
addAttachment: function(e) {
|
|
this.attachment = e.target.value
|
|
this.showErrors = false
|
|
this.changed = true
|
|
},
|
|
removeAttachment: function(e) {
|
|
e.preventDefault()
|
|
this.attachment = null
|
|
if (this.$refs.attachmentInput) {
|
|
this.$refs.attachmentInput.value = null
|
|
}
|
|
this.showErrors = false
|
|
this.changed = true
|
|
},
|
|
},
|
|
|
|
computed: {
|
|
baseName: function() {
|
|
if (this.attachment) {
|
|
return this.attachment.split(/[\\/]/).pop()
|
|
}
|
|
},
|
|
hasAttachment: function() {
|
|
return !!this.attachment
|
|
},
|
|
hideInput: function() {
|
|
return this.hasInitialData && !this.changed
|
|
},
|
|
},
|
|
}
|