mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-04 05:05:24 +00:00
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import { mapGetters } from 'vuex'
|
|
|
|
export default {
|
|
computed: {
|
|
dataSources() {
|
|
return this.$store.getters['dataSource/getPageDataSources'](this.page)
|
|
},
|
|
availableDataSources() {
|
|
return this.dataSources.filter(
|
|
(dataSource) =>
|
|
dataSource.type &&
|
|
this.$registry.get('service', dataSource.type).returnsList
|
|
)
|
|
},
|
|
selectedDataSource() {
|
|
if (!this.values.data_source_id) {
|
|
return null
|
|
}
|
|
return this.$store.getters['dataSource/getPageDataSourceById'](
|
|
this.page,
|
|
this.values.data_source_id
|
|
)
|
|
},
|
|
selectedDataSourceType() {
|
|
if (!this.selectedDataSource || !this.selectedDataSource.type) {
|
|
return null
|
|
}
|
|
return this.$registry.get('service', this.selectedDataSource.type)
|
|
},
|
|
maxItemPerPage() {
|
|
if (!this.selectedDataSourceType) {
|
|
return 20
|
|
}
|
|
return this.selectedDataSourceType.maxResultLimit
|
|
},
|
|
...mapGetters({
|
|
element: 'element/getSelected',
|
|
}),
|
|
},
|
|
watch: {
|
|
'dataSources.length'(newValue, oldValue) {
|
|
if (this.values.data_source_id && oldValue > newValue) {
|
|
if (
|
|
!this.dataSources.some(({ id }) => id === this.values.data_source_id)
|
|
) {
|
|
// Remove the data_source_id if the related dataSource has been deleted.
|
|
this.values.data_source_id = null
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|