atst/js/components/options_input.js
2019-04-19 11:49:41 -04:00

35 lines
696 B
JavaScript

import { emitEvent } from '../lib/emitters'
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) {
emitEvent('field-change', this, {
value: e.target.value,
name: this.name,
})
this.showError = false
this.showValid = true
},
},
}