1.0 KiB
1.0 KiB
Design: Persistent ordering + touch-friendly DnD
Database
- Add
sort_order integer not null default 0tobookmarks. - Add indexes to support ordered listing:
(user_id, folder_id, sort_order)
API
- Extend
BookmarkDTO/schema withsortOrder. - Add
POST /bookmarks/reordersimilar to existing/folders/reorder:- Input:
{ folderId: uuid|null, orderedIds: uuid[] } - Validates
orderedIdsis a permutation of all bookmarks for that user+folder (excluding deleted). - Transactionally updates
sort_orderfor each id.
- Input:
Web UI
- Replace native HTML5 drag/drop with a touch-capable approach.
- Implementation choice:
sortablejs(small, proven, touch-friendly). - Bind Sortable to:
- Folder header list (per parent group) for folder ordering.
- Each open folder’s bookmark list for bookmark ordering.
- Implementation choice:
- Root group is rendered as a first-class group and can also be reordered.
Compatibility
- If the DB schema lacks ordering columns (fresh/old DB), endpoints should return a clear 409 prompting
db:migrate.