#119 Trello Clone. Advanced Kanban Drag and Drop Sortable Lists with Hotwire
I'm so proud of this one, it should be premium content!
I've watched all the other youtube videos on this topic and I'm sure this approach is better and more versatile.
Also this video gives great insight into the thought process and debugging required to complete the feature.
Code deliverables:
- Sort Lists
- Sort tasks within List
- Move tasks between Lists
- Persist changes
This functinality was achived thanks to:
- gem RankedModel that stores the order of items in a list
- RequestJS that sends http requests from your javascript to your Rails controller
- SortableJS that provides the seamless sorting functionality
Episode source code: https://github.com/corsego/119-trello-drag-drop-save/commits/main
Based on this blogpost: https://blog.corsego.com/drag-and-drop-stimulus-request-js
0:00 Preview of what we will build, other solutions
1:15 Build the boilerplate app. List has many tasks.
7:25 Install SortableJS to sort List elements in the frontend
11:20 Install gem Ranked Model to track sort order of elements
20:00 Install RequestJS to make requests to Rails controller from StimulusJS
25:45 Updating Sort order works!
26:53 Sort Tasks within a List
32:50 Sort Tasks between Lists
40:05 CSS to stack lists horizontally like Trello
41:40 Final demo. Advanced sorting works!
0
Destacado en listas
![#59 Hotwire Turbo Streams CRUD](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTc4MiwicHVyIjoiYmxvYl9pZCJ9fQ==--7b4b94ff669cbcd3485cfcc3f72e9100df7eae48/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
![#60 Hotwire Turbo Streams Autocomplete Search](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTc1MywicHVyIjoiYmxvYl9pZCJ9fQ==--c95f098cc49b4d72ecb027c13735c1bedf44cb78/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
![#63 Hotwire Modals (the right way)](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTg2MywicHVyIjoiYmxvYl9pZCJ9fQ==--29f62b39b302aa16a6e6c28453e036aaa724add0/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)