Export bannedDisplayColumnTypes
This commit is contained in:
parent
48afa2aa0d
commit
36909ff7f6
|
@ -1,8 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext, onMount, tick } from "svelte"
|
import { getContext, onMount, tick } from "svelte"
|
||||||
import { FieldType } from "@budibase/types"
|
import { canBeDisplayColumn } from "@budibase/shared-core"
|
||||||
import GridCell from "./GridCell.svelte"
|
|
||||||
import { Icon, Popover, Menu, MenuItem, clickOutside } from "@budibase/bbui"
|
import { Icon, Popover, Menu, MenuItem, clickOutside } from "@budibase/bbui"
|
||||||
|
import GridCell from "./GridCell.svelte"
|
||||||
import { getColumnIcon } from "../lib/utils"
|
import { getColumnIcon } from "../lib/utils"
|
||||||
|
|
||||||
export let column
|
export let column
|
||||||
|
@ -25,15 +25,6 @@
|
||||||
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
|
||||||
|
@ -233,8 +224,7 @@
|
||||||
<MenuItem
|
<MenuItem
|
||||||
icon="Label"
|
icon="Label"
|
||||||
on:click={makeDisplayColumn}
|
on:click={makeDisplayColumn}
|
||||||
disabled={idx === "sticky" ||
|
disabled={idx === "sticky" || !canBeDisplayColumn(column.schema.type)}
|
||||||
bannedDisplayColumnTypes.includes(column.schema.type)}
|
|
||||||
>
|
>
|
||||||
Use as display column
|
Use as display column
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
|
@ -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]
|
||||||
|
}
|
Loading…
Reference in New Issue