Improve typings
This commit is contained in:
parent
e70dc86202
commit
675e195708
|
@ -1,6 +1,6 @@
|
||||||
import { derived, get, Writable, writable } from "svelte/store"
|
import { derived, get, Writable, writable } from "svelte/store"
|
||||||
import { DefaultColumnWidth, GutterWidth } from "../lib/constants"
|
import { DefaultColumnWidth, GutterWidth } from "../lib/constants"
|
||||||
import { FieldSchema } from "@budibase/types"
|
import { CalculationType, FieldSchema } from "@budibase/types"
|
||||||
import { StoreContext } from "."
|
import { StoreContext } from "."
|
||||||
|
|
||||||
export interface Store {
|
export interface Store {
|
||||||
|
@ -8,15 +8,18 @@ export interface Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Column = FieldSchema & {
|
type Column = FieldSchema & {
|
||||||
|
label: string
|
||||||
|
readonly: boolean
|
||||||
|
conditions: any
|
||||||
related?: {
|
related?: {
|
||||||
field: string
|
field: string
|
||||||
subField: string
|
subField: string
|
||||||
}
|
}
|
||||||
primaryDisplay: boolean
|
primaryDisplay?: boolean
|
||||||
|
|
||||||
schema?: {
|
schema?: {
|
||||||
autocolumn: boolean
|
autocolumn: boolean
|
||||||
}
|
}
|
||||||
|
calculationType: CalculationType
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createStores = (): Store => {
|
export const createStores = (): Store => {
|
||||||
|
@ -169,7 +172,8 @@ export const initialise = (context: StoreContext) => {
|
||||||
.map(field => {
|
.map(field => {
|
||||||
const fieldSchema = $enrichedSchema[field]
|
const fieldSchema = $enrichedSchema[field]
|
||||||
const oldColumn = $columns?.find(col => col.name === field)
|
const oldColumn = $columns?.find(col => col.name === field)
|
||||||
const column = {
|
const column: Column = {
|
||||||
|
type: fieldSchema.type,
|
||||||
name: field,
|
name: field,
|
||||||
label: fieldSchema.displayName || field,
|
label: fieldSchema.displayName || field,
|
||||||
schema: fieldSchema,
|
schema: fieldSchema,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { Writable } from "svelte/store"
|
||||||
|
|
||||||
import * as Bounds from "./bounds"
|
import * as Bounds from "./bounds"
|
||||||
import * as Columns from "./columns"
|
import * as Columns from "./columns"
|
||||||
import * as Menu from "./menu"
|
import * as Menu from "./menu"
|
||||||
|
@ -75,7 +77,7 @@ export const attachStores = context => {
|
||||||
export interface StoreContext {
|
export interface StoreContext {
|
||||||
columns: Columns.Store["columns"]
|
columns: Columns.Store["columns"]
|
||||||
datasource: any
|
datasource: any
|
||||||
definition: any
|
definition: Writable<any>
|
||||||
displayColumn: any
|
displayColumn: Writable<any>
|
||||||
enrichedSchema: any
|
enrichedSchema: any
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue