Unify
This commit is contained in:
parent
10615bbce4
commit
acc9da3876
|
@ -3,11 +3,11 @@ import { DefaultColumnWidth, GutterWidth } from "../lib/constants"
|
||||||
import { CalculationType, FieldSchema, FieldType } from "@budibase/types"
|
import { CalculationType, FieldSchema, FieldType } from "@budibase/types"
|
||||||
import { Store as StoreContext } from "."
|
import { Store as StoreContext } from "."
|
||||||
|
|
||||||
export interface Store {
|
interface ColumnStore {
|
||||||
columns: Writable<Column[]>
|
columns: Writable<Column[]>
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DerivedStore {
|
interface DerivedColumnStore {
|
||||||
tableColumns: Readable<Column[]>
|
tableColumns: Readable<Column[]>
|
||||||
displayColumn: Readable<Column>
|
displayColumn: Readable<Column>
|
||||||
columnLookupMap: Readable<Record<string, Column>>
|
columnLookupMap: Readable<Record<string, Column>>
|
||||||
|
@ -16,6 +16,8 @@ export interface DerivedStore {
|
||||||
hasNonAutoColumn: Readable<boolean>
|
hasNonAutoColumn: Readable<boolean>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Store = ColumnStore & DerivedColumnStore
|
||||||
|
|
||||||
type Column = FieldSchema & {
|
type Column = FieldSchema & {
|
||||||
label: string
|
label: string
|
||||||
readonly: boolean
|
readonly: boolean
|
||||||
|
@ -34,7 +36,7 @@ type Column = FieldSchema & {
|
||||||
calculationType: CalculationType
|
calculationType: CalculationType
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createStores = (): Store => {
|
export const createStores = (): ColumnStore => {
|
||||||
const columns = writable([])
|
const columns = writable([])
|
||||||
|
|
||||||
// Enrich columns with metadata about their display position
|
// Enrich columns with metadata about their display position
|
||||||
|
@ -63,7 +65,7 @@ export const createStores = (): Store => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deriveStores = (context: StoreContext): DerivedStore => {
|
export const deriveStores = (context: StoreContext): DerivedColumnStore => {
|
||||||
const { columns } = context
|
const { columns } = context
|
||||||
|
|
||||||
// Derive a lookup map for all columns by name
|
// Derive a lookup map for all columns by name
|
||||||
|
|
|
@ -50,14 +50,13 @@ const DependencyOrderedStores = [
|
||||||
Cache,
|
Cache,
|
||||||
]
|
]
|
||||||
|
|
||||||
export type Store = Columns.Store &
|
export type Store = Columns.Store & {
|
||||||
Columns.DerivedStore & {
|
// TODO while typing the rest of stores
|
||||||
// TODO while typing the rest of stores
|
datasource: any
|
||||||
datasource: any
|
definition: Writable<any>
|
||||||
definition: Writable<any>
|
displayColumn: Writable<any>
|
||||||
displayColumn: Writable<any>
|
enrichedSchema: any
|
||||||
enrichedSchema: any
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export const attachStores = (context): Store => {
|
export const attachStores = (context): Store => {
|
||||||
// Atomic store creation
|
// Atomic store creation
|
||||||
|
|
Loading…
Reference in New Issue