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>
import { getContext, onMount, tick } from "svelte"
import { FieldType, FieldSubtype } from "@budibase/types"
import GridCell from "./GridCell.svelte"
import { Icon, Popover, Menu, MenuItem, clickOutside } from "@budibase/bbui"
import { getColumnIcon } from "../lib/utils"
@ -24,14 +25,6 @@
datasource,
} = getContext("grid")
const bannedDisplayColumnTypes = [
"link",
"array",
"attachment",
"boolean",
"json",
]
let anchor
let open = 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))
</script>
@ -231,8 +246,7 @@
<MenuItem
icon="Label"
on:click={makeDisplayColumn}
disabled={idx === "sticky" ||
bannedDisplayColumnTypes.includes(column.schema.type)}
disabled={idx === "sticky" || !canBeDisplayColumn(column)}
>
Use as display column
</MenuItem>