mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-09 23:27:51 +00:00
34 lines
689 B
JavaScript
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()
|
|
}
|
|
}
|
|
}
|