diff --git a/routers/lists.py b/routers/lists.py index fb88839..d1a2234 100644 --- a/routers/lists.py +++ b/routers/lists.py @@ -406,3 +406,17 @@ async def reorder_list_item( filters["parent_item_id"] = None await repo.move_in_order(item_id, direction, filters=filters) return RedirectResponse(url=f"/lists/{list_id}", status_code=303) + + +@router.post("/{list_id}/items/reorder-all") +async def reorder_all_list_items( + list_id: str, + request: Request, + item_ids: str = Form(...), + db: AsyncSession = Depends(get_db), +): + repo = BaseRepository("list_items", db) + ids = [i.strip() for i in item_ids.split(",") if i.strip()] + if ids: + await repo.reorder(ids) + return RedirectResponse(url=f"/lists/{list_id}", status_code=303) diff --git a/templates/list_detail.html b/templates/list_detail.html index ab34539..1fbe707 100644 --- a/templates/list_detail.html +++ b/templates/list_detail.html @@ -53,7 +53,7 @@ {% if list_items %}
{% for li in list_items %} -
+
{% with reorder_url="/lists/" ~ item.id ~ "/items/reorder", item_id=li.id %} {% include 'partials/reorder_arrows.html' %} {% endwith %} @@ -133,6 +133,9 @@ {% endfor %} {% endfor %}
+ {% else %}
@@ -175,6 +178,52 @@