From 7f66903d7d366e3a0a30075b8b96b000fd9c1d22 Mon Sep 17 00:00:00 2001 From: Robin Dittmar Date: Fri, 11 Sep 2026 19:14:25 +0200 Subject: [PATCH] feat: re-order lists --- src/api/lists.ts | 8 ++ src/components/ListCard.vue | 64 ++++++++++++- src/composables/useListDragReorder.ts | 129 ++++++++++++++++++++++++++ src/database/db.ts | 2 + src/stores/__tests__/lists.spec.ts | 98 +++++++++++++++++++ src/stores/lists.ts | 78 +++++++++++++++- src/types/list.ts | 5 + src/views/ListsView.vue | 60 +++++++++++- 8 files changed, 435 insertions(+), 9 deletions(-) create mode 100644 src/composables/useListDragReorder.ts diff --git a/src/api/lists.ts b/src/api/lists.ts index 5999e2a..a39e6d0 100644 --- a/src/api/lists.ts +++ b/src/api/lists.ts @@ -9,6 +9,7 @@ import type { SetListItemTitlePayload, AddUserToListPayload, RemoveUserFromListPayload, + OrderListsPayload, } from '@/types/list' export async function getListsApi(): Promise { @@ -77,6 +78,13 @@ export async function removeUserFromListApi(payload: RemoveUserFromListPayload): } } +export async function orderListsApi(payload: OrderListsPayload): Promise { + const response = await apiClient.post('/lists/order', payload) + if (!response.ok) { + throw new Error(await extractErrorMessage(response, 'Failed to reorder lists')) + } +} + export async function deleteListApi(listId: string): Promise { const response = await apiClient.delete(`/lists/${listId}`) if (!response.ok) { diff --git a/src/components/ListCard.vue b/src/components/ListCard.vue index 1c72cfb..a5d0dff 100644 --- a/src/components/ListCard.vue +++ b/src/components/ListCard.vue @@ -5,10 +5,11 @@ import type { LocalList } from '@/database/db' import { useListsStore } from '@/stores/lists' import { useDismissableMenu } from '@/composables/useDismissableMenu' -const props = defineProps<{ list: LocalList }>() +const props = defineProps<{ list: LocalList; dragging?: boolean }>() const emit = defineEmits<{ share: [list: LocalList] delete: [list: LocalList] + 'handle-pointerdown': [event: PointerEvent] }>() const listsStore = useListsStore() @@ -49,7 +50,24 @@ function handleDelete(event: Event) {