atst/js/components/options_input.js
2019-04-06 16:57:12 -04:00

34 lines
691 B
JavaScript

export default {
name: 'optionsinput',
props: {
name: String,
initialErrors: {
type: Array,
default: () => [],
},
initialValue: String,
},
data: function() {
const showError = (this.initialErrors && this.initialErrors.length) || false
return {
showError: showError,
showValid: !showError && !!this.initialValue,
validationError: this.initialErrors.join(' '),
}
},
methods: {
onInput: function(e) {
this.$root.$emit('field-change', {
value: e.target.value,
name: this.name,
parent_uid: this.$parent._uid,
})
this.showError = false
this.showValid = true
},
},
}