From 86d25691d277aba0fab933b07474f50a60cf9e3b Mon Sep 17 00:00:00 2001 From: Michael Genson <71845777+michael-genson@users.noreply.github.com> Date: Thu, 15 Sep 2022 18:53:58 -0500 Subject: [PATCH] fix: defaults recipe actions to sort by name, ascending (#1650) --- frontend/composables/partials/use-actions-factory.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/composables/partials/use-actions-factory.ts b/frontend/composables/partials/use-actions-factory.ts index e0a48693c954..80b73d28af3b 100644 --- a/frontend/composables/partials/use-actions-factory.ts +++ b/frontend/composables/partials/use-actions-factory.ts @@ -7,7 +7,7 @@ type BoundT = { }; interface StoreActions { - getAll(): Ref; + getAll(page?: number, perPage?: number, params?: any): Ref; refresh(): Promise; createOne(createData: T): Promise; updateOne(updateData: T): Promise; @@ -25,10 +25,13 @@ export function useStoreActions( allRef: Ref | null, loading: Ref ): StoreActions { - function getAll() { + function getAll(page = 1, perPage = -1, params = {} as any) { + params.orderBy ??= "name"; + params.orderDirection ??= "asc"; + loading.value = true; const allItems = useAsync(async () => { - const { data } = await api.getAll(); + const { data } = await api.getAll(page, perPage, params); if (data && allRef) { allRef.value = data.items;