1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-28 06:22:24 +00:00
bramw_baserow/web-frontend/modules/database/mixins/tableFields.js
2025-03-24 17:10:06 +01:00

47 lines
1.1 KiB
JavaScript

import FieldService from '@baserow/modules/database/services/field'
import { notifyIf } from '@baserow/modules/core/utils/error'
/**
* This mixin request the fields of the given table Id.
*/
export default {
props: {},
data() {
return { tableFields: [], fieldsLoading: false }
},
computed: {
tableId() {
return this.getTableId()
},
},
watch: {
tableId: {
async handler(newValue, oldValue) {
if (newValue !== oldValue) {
this.tableFields = []
if (newValue) {
this.fieldsLoading = true
try {
const { data } = await FieldService(this.$client).fetchAll(
newValue
)
this.tableFields = data
} catch (e) {
notifyIf(e, 'application')
} finally {
this.fieldsLoading = false
}
}
}
},
immediate: true,
},
},
methods: {
getTableId() {
throw new Error(
'Not implemented error. This method should the table id we want the field for.'
)
},
},
}