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 { FIELDS } from "constants/backend"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { parseFile } from "./utils"
|
import { parseFile } from "./utils"
|
||||||
|
import { canBeDisplayColumn } from "@budibase/shared-core"
|
||||||
|
|
||||||
export let rows = []
|
export let rows = []
|
||||||
export let schema = {}
|
export let schema = {}
|
||||||
|
@ -97,9 +98,13 @@
|
||||||
let selectedColumnTypes = {}
|
let selectedColumnTypes = {}
|
||||||
|
|
||||||
$: displayColumnOptions = Object.keys(schema || {}).filter(column => {
|
$: 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
|
// binding in consumer is causing double renders here
|
||||||
const newValidateHash = JSON.stringify(rows) + JSON.stringify(schema)
|
const newValidateHash = JSON.stringify(rows) + JSON.stringify(schema)
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -3,3 +3,4 @@ export * as dataFilters from "./filters"
|
||||||
export * as helpers from "./helpers"
|
export * as helpers from "./helpers"
|
||||||
export * as utils from "./utils"
|
export * as utils from "./utils"
|
||||||
export * as sdk from "./sdk"
|
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,
|
"skipLibCheck": true,
|
||||||
"paths": {
|
"paths": {
|
||||||
"@budibase/types": ["../types/src"]
|
"@budibase/types": ["../types/src"]
|
||||||
}
|
},
|
||||||
|
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||||
},
|
},
|
||||||
"include": ["**/*.js", "**/*.ts"],
|
"include": ["**/*.js", "**/*.ts"],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": "..",
|
"baseUrl": "..",
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"composite": true,
|
"composite": true
|
||||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"outDir": "dist"
|
"outDir": "dist",
|
||||||
|
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.spec.js"]
|
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.spec.js"]
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"composite": true,
|
"composite": true
|
||||||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
|
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "dist"]
|
"exclude": ["node_modules", "dist"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue