1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-16 10:01:05 +00:00
bramw_baserow/web-frontend/modules/database/components/field/UpdateFieldContext.vue
2020-12-01 08:38:51 +00:00

71 lines
1.4 KiB
Vue

<template>
<Context ref="context">
<FieldForm
ref="form"
:table="table"
:default-values="field"
:primary="field.primary"
@submitted="submit"
>
<div class="context__form-actions">
<button
class="button"
:class="{ 'button--loading': loading }"
:disabled="loading"
>
Change
</button>
</div>
</FieldForm>
</Context>
</template>
<script>
import context from '@baserow/modules/core/mixins/context'
import FieldForm from '@baserow/modules/database/components/field/FieldForm'
import { notifyIf } from '@baserow/modules/core/utils/error'
export default {
name: 'UpdateFieldContext',
components: { FieldForm },
mixins: [context],
props: {
table: {
type: Object,
required: true,
},
field: {
type: Object,
required: true,
},
},
data() {
return {
loading: false,
}
},
methods: {
async submit(values) {
this.loading = true
const type = values.type
delete values.type
try {
await this.$store.dispatch('field/update', {
field: this.field,
type,
values,
})
this.loading = false
this.$refs.form.reset()
this.hide()
this.$emit('update')
} catch (error) {
this.loading = false
notifyIf(error, 'field')
}
},
},
}
</script>