Handle lack of IDs from calculation views
This commit is contained in:
parent
7a0b0ccb34
commit
6e0b5341b1
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,14 @@ export const deriveStores = context => {
|
||||||
// Disable some features if we're editing a view
|
// Disable some features if we're editing a view
|
||||||
if (type === "viewV2") {
|
if (type === "viewV2") {
|
||||||
config.canEditColumns = false
|
config.canEditColumns = false
|
||||||
|
|
||||||
|
// Disable features for calculation views
|
||||||
|
if ($definition?.type === ViewV2Type.CALCULATION) {
|
||||||
|
config.canAddRows = false
|
||||||
|
config.canEditRows = false
|
||||||
|
config.canDeleteRows = false
|
||||||
|
config.canExpandRows = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable adding rows if we don't have any valid columns
|
// Disable adding rows if we don't have any valid columns
|
||||||
|
@ -60,19 +68,7 @@ export const deriveStores = context => {
|
||||||
config.canEditColumns = false
|
config.canEditColumns = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable features for calculation views
|
|
||||||
if (type === "viewV2" && $definition?.type === ViewV2Type.CALCULATION) {
|
|
||||||
config.canAddRows = false
|
|
||||||
config.canEditRows = false
|
|
||||||
config.canDeleteRows = false
|
|
||||||
config.canExpandRows = false
|
|
||||||
}
|
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
|
||||||
config,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { derived, get } from "svelte/store"
|
||||||
import { getDatasourceDefinition, getDatasourceSchema } from "../../../fetch"
|
import { getDatasourceDefinition, getDatasourceSchema } from "../../../fetch"
|
||||||
import { enrichSchemaWithRelColumns, memo } from "../../../utils"
|
import { enrichSchemaWithRelColumns, memo } from "../../../utils"
|
||||||
import { cloneDeep } from "lodash"
|
import { cloneDeep } from "lodash"
|
||||||
|
import { ViewV2Type } from "@budibase/types"
|
||||||
|
|
||||||
export const createStores = () => {
|
export const createStores = () => {
|
||||||
const definition = memo(null)
|
const definition = memo(null)
|
||||||
|
@ -81,13 +82,20 @@ export const deriveStores = context => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const hasBudibaseIdentifiers = derived(datasource, $datasource => {
|
const hasBudibaseIdentifiers = derived(
|
||||||
let type = $datasource?.type
|
[datasource, definition],
|
||||||
if (type === "provider") {
|
([$datasource, $definition]) => {
|
||||||
type = $datasource.value?.datasource?.type
|
let type = $datasource?.type
|
||||||
|
if (type === "provider") {
|
||||||
|
type = $datasource.value?.datasource?.type
|
||||||
|
}
|
||||||
|
// Handle calculation views
|
||||||
|
if (type === "viewV2" && $definition?.type === ViewV2Type.CALCULATION) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return ["table", "viewV2", "link"].includes(type)
|
||||||
}
|
}
|
||||||
return ["table", "viewV2", "link"].includes(type)
|
)
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
schema,
|
schema,
|
||||||
|
|
|
@ -39,18 +39,6 @@ export default class ViewV2Fetch extends DataFetch {
|
||||||
this.options
|
this.options
|
||||||
const { cursor, query, definition } = get(this.store)
|
const { cursor, query, definition } = get(this.store)
|
||||||
|
|
||||||
// If this is a calculation view and there are no schema fields then do nothing
|
|
||||||
console.log(definition)
|
|
||||||
if (
|
|
||||||
definition.calculation &&
|
|
||||||
!Object.keys(definition.schema || {}).length
|
|
||||||
) {
|
|
||||||
return {
|
|
||||||
rows: [],
|
|
||||||
hasNextPage: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If sort/filter params are not defined, update options to store the
|
// If sort/filter params are not defined, update options to store the
|
||||||
// params built in to this view. This ensures that we can accurately
|
// params built in to this view. This ensures that we can accurately
|
||||||
// compare old and new params and skip a redundant API call.
|
// compare old and new params and skip a redundant API call.
|
||||||
|
|
Loading…
Reference in New Issue