1.6 KiB
1.6 KiB
Drag and Drop Playlist Reordering Implementation
Task
Add drag-and-drop functionality to reorder videos in a playlist when editing
Steps Completed
- Add SortableJS library to the project (via CDN in the view)
- Update playlist show.blade.php to add drag-and-drop functionality
- Add CSS styles for drag-and-drop visual feedback
- Implement playlist sidebar when playing from playlist (no up-next recommendations)
Implementation Complete ✅
Backend (Already existed - no changes needed)
- Route:
PUT /playlists/{playlist}/reorder- acceptsvideo_idsarray - Controller:
PlaylistController::reorder()- callsplaylist->reorderVideos() - Model:
Playlist::reorderVideos()- updates position for each video
Frontend Changes Made (Playlist Show Page)
- Added SortableJS via CDN in
show.blade.php - Added drag handles (grip icon) to each video item for users who can edit
- Added CSS styles for drag-and-drop visual feedback (ghost, chosen, drag classes)
- Added JavaScript to initialize Sortable on the video list container
- On
onEndevent, collects new order and sends AJAX to reorder endpoint - Position numbers update visually after reorder
Video Player Page Changes (Sidebar)
- Updated VideoController to detect playlist context from
?playlist=parameter - Updated all video type views (generic, music, match, show) to show playlist videos in sidebar when viewing from playlist
- Shows playlist name and video count in sidebar header
- Shows position numbers on each video thumbnail
- Links preserve the playlist parameter for continuous playback
- Shows "Edit Playlist" button for playlist owners