Skip to content

Instantly share code, notes, and snippets.

@boutell
Last active October 29, 2018 15:07
Show Gist options
  • Save boutell/bf0fba19af031e1055115e4b32f639e5 to your computer and use it in GitHub Desktop.
Save boutell/bf0fba19af031e1055115e4b32f639e5 to your computer and use it in GitHub Desktop.
module.exports = {
props: {
value: Object,
field: Object,
context: Object
},
data() {
return {
next: (this.value.data !== undefined) ? this.value.data : (this.field.def || ''),
error: false
};
},
mounted() {
this.validateAndEmit();
},
computed: {
options() {
return window.apos.schemas;
}
},
watch: {
value: {
deep: true,
handler(value) {
this.watchValue();
}
},
next(value) {
this.watchNext();
}
},
methods: {
validateAndEmit() {
this.$emit('input', {
data: this.next,
error: this.validate(this.next)
});
},
watchValue() {
this.error = this.value.error;
this.next = this.value.data;
},
watchNext() {
this.validateAndEmit();
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment