1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-09 23:27:51 +00:00
bramw_baserow/web-frontend/mixins/form.js
2019-08-26 17:49:28 +00:00

34 lines
689 B
JavaScript

/**
* This mixin introduces some helper functions for form components where the
* whole component existence is based on being a form.
*/
export default {
props: {
defaultValues: {
type: Object,
required: false,
default: () => {
return {}
}
}
},
mounted() {
Object.assign(this.values, this.values, this.defaultValues)
},
methods: {
submit() {
this.$v.$touch()
if (!this.$v.$invalid) {
this.$emit('submitted', this.values)
}
},
reset() {
Object.assign(
this.values,
this.$options.data.call(this).values,
this.defaultValues
)
this.$v.$reset()
}
}
}