Don't allow users column as primary display

This commit is contained in:
Adria Navarro 2023-10-09 13:05:57 +02:00
parent afedd560fd
commit 065e633742
1 changed files with 24 additions and 10 deletions

View File

@ -1,5 +1,6 @@
<script> <script>
import { getContext, onMount, tick } from "svelte" import { getContext, onMount, tick } from "svelte"
import { FieldType, FieldSubtype } from "@budibase/types"
import GridCell from "./GridCell.svelte" import GridCell from "./GridCell.svelte"
import { Icon, Popover, Menu, MenuItem, clickOutside } from "@budibase/bbui" import { Icon, Popover, Menu, MenuItem, clickOutside } from "@budibase/bbui"
import { getColumnIcon } from "../lib/utils" import { getColumnIcon } from "../lib/utils"
@ -24,14 +25,6 @@
datasource, datasource,
} = getContext("grid") } = getContext("grid")
const bannedDisplayColumnTypes = [
"link",
"array",
"attachment",
"boolean",
"json",
]
let anchor let anchor
let open = false let open = false
let editIsOpen = false let editIsOpen = false
@ -147,6 +140,28 @@
}) })
} }
const canBeDisplayColumn = column => {
const bannedDisplayColumnTypes = [
"link",
"array",
"attachment",
"boolean",
"json",
]
if (bannedDisplayColumnTypes.includes(column.schema.type)) {
return false
}
if (
column.schema.type === FieldType.BB_REFERENCE &&
column.schema.subtype === FieldSubtype.USERS
) {
return false
}
return true
}
onMount(() => subscribe("close-edit-column", cancelEdit)) onMount(() => subscribe("close-edit-column", cancelEdit))
</script> </script>
@ -231,8 +246,7 @@
<MenuItem <MenuItem
icon="Label" icon="Label"
on:click={makeDisplayColumn} on:click={makeDisplayColumn}
disabled={idx === "sticky" || disabled={idx === "sticky" || !canBeDisplayColumn(column)}
bannedDisplayColumnTypes.includes(column.schema.type)}
> >
Use as display column Use as display column
</MenuItem> </MenuItem>