Export bannedDisplayColumnTypes

This commit is contained in:
Adria Navarro 2023-10-10 15:50:12 +02:00
parent 48afa2aa0d
commit 36909ff7f6
2 changed files with 28 additions and 13 deletions

View File

@ -1,8 +1,8 @@
<script>
import { getContext, onMount, tick } from "svelte"
import { FieldType } from "@budibase/types"
import GridCell from "./GridCell.svelte"
import { canBeDisplayColumn } from "@budibase/shared-core"
import { Icon, Popover, Menu, MenuItem, clickOutside } from "@budibase/bbui"
import GridCell from "./GridCell.svelte"
import { getColumnIcon } from "../lib/utils"
export let column
@ -25,15 +25,6 @@
datasource,
} = getContext("grid")
const bannedDisplayColumnTypes = [
FieldType.LINK,
FieldType.ARRAY,
FieldType.ATTACHMENT,
FieldType.BOOLEAN,
FieldType.JSON,
FieldType.BB_REFERENCE,
]
let anchor
let open = false
let editIsOpen = false
@ -233,8 +224,7 @@
<MenuItem
icon="Label"
on:click={makeDisplayColumn}
disabled={idx === "sticky" ||
bannedDisplayColumnTypes.includes(column.schema.type)}
disabled={idx === "sticky" || !canBeDisplayColumn(column.schema.type)}
>
Use as display column
</MenuItem>

View File

@ -0,0 +1,25 @@
import { FieldType } from "types/dist"
const allowDisplayColumnByType: Record<FieldType, boolean> = {
[FieldType.STRING]: true,
[FieldType.LONGFORM]: true,
[FieldType.OPTIONS]: true,
[FieldType.NUMBER]: true,
[FieldType.DATETIME]: true,
[FieldType.FORMULA]: true,
[FieldType.AUTO]: true,
[FieldType.INTERNAL]: true,
[FieldType.BARCODEQR]: true,
[FieldType.BIGINT]: true,
[FieldType.BOOLEAN]: false,
[FieldType.ARRAY]: false,
[FieldType.ATTACHMENT]: false,
[FieldType.LINK]: false,
[FieldType.JSON]: false,
[FieldType.BB_REFERENCE]: false,
}
export function canBeDisplayColumn(type: FieldType): boolean {
return !!allowDisplayColumnByType[type]
}