Type fields
This commit is contained in:
parent
f84ddd2b57
commit
fa930de15e
|
@ -7,11 +7,13 @@
|
||||||
import { Component, Context, SDK } from "../../../../index"
|
import { Component, Context, SDK } from "../../../../index"
|
||||||
import { TableSchema, UIDatasource } from "@budibase/types"
|
import { TableSchema, UIDatasource } from "@budibase/types"
|
||||||
|
|
||||||
|
type Field = { name: string; active: boolean }
|
||||||
|
|
||||||
export let actionType: string
|
export let actionType: string
|
||||||
export let dataSource: UIDatasource
|
export let dataSource: UIDatasource
|
||||||
export let size: string
|
export let size: string
|
||||||
export let disabled: boolean
|
export let disabled: boolean
|
||||||
export let fields
|
export let fields: (Field | string)[]
|
||||||
export let buttons: {
|
export let buttons: {
|
||||||
"##eventHandlerType": string
|
"##eventHandlerType": string
|
||||||
parameters: Record<string, string>
|
parameters: Record<string, string>
|
||||||
|
@ -66,11 +68,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertOldFieldFormat = (fields: any[]) => {
|
const convertOldFieldFormat = (fields: (Field | string)[]): Field[] => {
|
||||||
if (!fields) {
|
if (!fields) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return fields.map((field: any) => {
|
return fields.map(field => {
|
||||||
if (typeof field === "string") {
|
if (typeof field === "string") {
|
||||||
// existed but was a string
|
// existed but was a string
|
||||||
return {
|
return {
|
||||||
|
@ -87,14 +89,11 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDefaultFields = (
|
const getDefaultFields = (fields: Field[], schema: TableSchema) => {
|
||||||
fields: { name: string; active: boolean }[],
|
|
||||||
schema: TableSchema
|
|
||||||
) => {
|
|
||||||
if (!schema) {
|
if (!schema) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
let defaultFields: { name: string; active: boolean }[] = []
|
let defaultFields: Field[] = []
|
||||||
|
|
||||||
if (!fields || fields.length === 0) {
|
if (!fields || fields.length === 0) {
|
||||||
Object.values(schema)
|
Object.values(schema)
|
||||||
|
|
Loading…
Reference in New Issue