mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-28 06:22:24 +00:00
47 lines
1.1 KiB
JavaScript
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.'
|
|
)
|
|
},
|
|
},
|
|
}
|