2025-03-24 17:10:06 +01:00
|
|
|
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(
|
2025-03-24 16:37:20 +00:00
|
|
|
'Not implemented error. This method should return the table id we want the field for.'
|
2025-03-24 17:10:06 +01:00
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|