Merge pull request #12020 from Budibase/restrict-display-on-import-table
Restrict display on import table
This commit is contained in:
commit
54b94f041c
|
@ -3,6 +3,7 @@
|
|||
import { FIELDS } from "constants/backend"
|
||||
import { API } from "api"
|
||||
import { parseFile } from "./utils"
|
||||
import { canBeDisplayColumn } from "@budibase/shared-core"
|
||||
|
||||
export let rows = []
|
||||
export let schema = {}
|
||||
|
@ -97,9 +98,13 @@
|
|||
let selectedColumnTypes = {}
|
||||
|
||||
$: displayColumnOptions = Object.keys(schema || {}).filter(column => {
|
||||
return validation[column]
|
||||
return validation[column] && canBeDisplayColumn(schema[column].type)
|
||||
})
|
||||
|
||||
$: if (displayColumn && !canBeDisplayColumn(schema[displayColumn].type)) {
|
||||
displayColumn = null
|
||||
}
|
||||
|
||||
$: {
|
||||
// binding in consumer is causing double renders here
|
||||
const newValidateHash = JSON.stringify(rows) + JSON.stringify(schema)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -3,3 +3,4 @@ export * as dataFilters from "./filters"
|
|||
export * as helpers from "./helpers"
|
||||
export * as utils from "./utils"
|
||||
export * as sdk from "./sdk"
|
||||
export * from "./table"
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import { FieldType } from "@budibase/types"
|
||||
|
||||
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]
|
||||
}
|
|
@ -15,7 +15,8 @@
|
|||
"skipLibCheck": true,
|
||||
"paths": {
|
||||
"@budibase/types": ["../types/src"]
|
||||
}
|
||||
},
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["**/*.js", "**/*.ts"],
|
||||
"exclude": [
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
"compilerOptions": {
|
||||
"baseUrl": "..",
|
||||
"rootDir": "src",
|
||||
"composite": true,
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
"composite": true
|
||||
},
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "dist"
|
||||
"outDir": "dist",
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.spec.js"]
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"rootDir": "./src",
|
||||
"composite": true,
|
||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||
"composite": true
|
||||
},
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue