Last active
October 29, 2018 15:07
-
-
Save boutell/bf0fba19af031e1055115e4b32f639e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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