This commit is contained in:
Adria Navarro 2023-10-09 15:36:17 +02:00
parent 0909e0547e
commit 6f77be622f
1 changed files with 12 additions and 24 deletions

View File

@ -1,6 +1,6 @@
<script> <script>
import { getContext, onMount, tick } from "svelte" import { getContext, onMount, tick } from "svelte"
import { FieldType, FieldSubtype } from "@budibase/types" import { FieldType } 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"
@ -25,6 +25,15 @@
datasource, datasource,
} = getContext("grid") } = getContext("grid")
const bannedDisplayColumnTypes = [
FieldType.LINK,
FieldType.ARRAY,
FieldType.ATTACHMENT,
FieldType.BOOLEAN,
FieldType.JSON,
FieldType.BB_REFERENCE,
]
let anchor let anchor
let open = false let open = false
let editIsOpen = false let editIsOpen = false
@ -140,28 +149,6 @@
}) })
} }
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>
@ -246,7 +233,8 @@
<MenuItem <MenuItem
icon="Label" icon="Label"
on:click={makeDisplayColumn} on:click={makeDisplayColumn}
disabled={idx === "sticky" || !canBeDisplayColumn(column)} disabled={idx === "sticky" ||
bannedDisplayColumnTypes.includes(column.schema.type)}
> >
Use as display column Use as display column
</MenuItem> </MenuItem>