diff --git a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts index 71c22e6866..6a788d3ec6 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts @@ -173,7 +173,7 @@ export const initialise = (context: StoreContext) => { await datasource.actions.saveDefinition({ ...$view, sort: { - field: $sort.column, + field: $sort.column!, order: $sort.order || SortOrder.ASCENDING, }, }) diff --git a/packages/frontend-core/src/components/grid/stores/index.ts b/packages/frontend-core/src/components/grid/stores/index.ts index d55002186f..8a4d40976d 100644 --- a/packages/frontend-core/src/components/grid/stores/index.ts +++ b/packages/frontend-core/src/components/grid/stores/index.ts @@ -95,7 +95,6 @@ export type Store = BaseStore & Clipboard.Store & Scroll.Store & { // TODO while typing the rest of stores - sort: Writable subscribe: any dispatch: (event: string, data: any) => any width: Writable @@ -108,7 +107,8 @@ export type Store = BaseStore & Conditions.Store & Cache.Store & Viewport.Store & - Notifications.Store + Notifications.Store & + Sort.Store export const attachStores = (context: Store): Store => { // Atomic store creation diff --git a/packages/frontend-core/src/components/grid/stores/sort.ts b/packages/frontend-core/src/components/grid/stores/sort.ts index 474de59e7b..ab58d7dabe 100644 --- a/packages/frontend-core/src/components/grid/stores/sort.ts +++ b/packages/frontend-core/src/components/grid/stores/sort.ts @@ -1,9 +1,18 @@ -import { derived, get } from "svelte/store" +import { derived, get, Writable } from "svelte/store" import { memo } from "../../../utils" import { SortOrder } from "@budibase/types" 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 = get(props)