Type sort store

This commit is contained in:
Adria Navarro 2024-12-30 13:40:52 +01:00
parent 078053a417
commit 56fe3ce6fe
3 changed files with 14 additions and 5 deletions

View File

@ -173,7 +173,7 @@ export const initialise = (context: StoreContext) => {
await datasource.actions.saveDefinition({ await datasource.actions.saveDefinition({
...$view, ...$view,
sort: { sort: {
field: $sort.column, field: $sort.column!,
order: $sort.order || SortOrder.ASCENDING, order: $sort.order || SortOrder.ASCENDING,
}, },
}) })

View File

@ -95,7 +95,6 @@ export type Store = BaseStore &
Clipboard.Store & Clipboard.Store &
Scroll.Store & { Scroll.Store & {
// TODO while typing the rest of stores // TODO while typing the rest of stores
sort: Writable<any>
subscribe: any subscribe: any
dispatch: (event: string, data: any) => any dispatch: (event: string, data: any) => any
width: Writable<number> width: Writable<number>
@ -108,7 +107,8 @@ export type Store = BaseStore &
Conditions.Store & Conditions.Store &
Cache.Store & Cache.Store &
Viewport.Store & Viewport.Store &
Notifications.Store Notifications.Store &
Sort.Store
export const attachStores = (context: Store): Store => { export const attachStores = (context: Store): Store => {
// Atomic store creation // Atomic store creation

View File

@ -1,9 +1,18 @@
import { derived, get } from "svelte/store" import { derived, get, Writable } from "svelte/store"
import { memo } from "../../../utils" import { memo } from "../../../utils"
import { SortOrder } from "@budibase/types" import { SortOrder } from "@budibase/types"
import { Store as StoreContext } from "." import { Store as StoreContext } from "."
export const createStores = (context: StoreContext) => { interface SortStore {
sort: Writable<{
column: string | null | undefined
order: SortOrder
}>
}
export type Store = SortStore
export const createStores = (context: StoreContext): SortStore => {
const { props } = context const { props } = context
const $props = get(props) const $props = get(props)