-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPIKE: Drag-and-drop reordering of items
in a list
#4
Comments
The way we store the Luckily, Jira already has this problem and they fix it in a rather interesting way - you can find it here. They rank each item through strings and use a minimising string length algo to generate the minimum length possible string when changing ranks, changing only two rows at a time. Basically, the "rank" (what we would call |
Agreed. The number of updates for each drag-and-drop event can potentially be the whole list. If each person has average If we notice a significant performance bottleneck in this, we can target it for optimisation. 🔍 Thank you for sharing the link to the StackOverflow https://stackoverflow.com/questions/9536262/best-representation-of-an-ordered-list-in-a-database/49956113#49956113 ... as noted, I don't expect that our DB will suffer too much from updating the This is a very fast update query even if there are hundreds of Going to avoid using For now we are targeting having |
For:
task describe in #4 (comment) running Because Tailwind is not included by default on Phoenix yet, the styles will need to be updated for the genereated liveview templates: |
My latest commit makes shure the drag and drop events are saved (items' indexes udpated) and all clients are notify to the new list order: b3b4db2 I need to update the Readme and the tests but you can already test the drag and drop with |
I spent a bit mote time trying to implement a UI to show which element is moved on all clients: drag-and-drop.webmWhen an element is grabbed it is highlighted and moved on all the connected clients. |
Siiiiiiiick! 🤩 @SimonLab 🙇 |
I'm keen to try to create lists for items and to test drag and drop of items between lists. Now that I have a better idea how Phoenix liveview and Alpine.js can work together to make the drag-and-drop visible on all clients I don't think it should be too complicated to implement. And the last step would be to apply the drag and drop to lists (ie reorder how the display of the lists). |
I'm following the instruction again on the Adding Alpine.js to LiveView, see https://hexdocs.pm/phoenix_live_view/js-interop.html |
This is working well on #5 ✅ |
Deployed to: https://alpine-demo.fly.dev/items alpine-drag-and-drop.movWorking well. ✅ |
@SimonLab please note: one of the original requirements in the OP ⬆️ I've attempted to test it on my iPhone: https://alpine-demo.fly.dev/items Were you able to do it on your Android phone? 🤞 |
Unfortunately I think the drag and drop html api is not very well supported on mobile. |
@SimonLab let's not invest toooo much time in this. ⏳ |
As outlined in dwyl/app#283 (comment) the next feature on our roadmap is prioritisation of
items
.We will achieve this visually by dragging and dropping the
item
to order them in terms of the priority.From quick searching, it looks like we can pull off basic drag-and-drop using
Alpine.js
: 🤞https://codeblog.trovster.com/2020/05/alpinejs-drag-and-drop/ 📝
https://www.youtube.com/watch?v=zJ4NQaiYxKs 📺
https://codepen.io/trovster/pen/oNjGGMq 👨💻
Screen.Recording.2022-09-30.at.10.36.28.mov
Our objective is to
SPIKE
this ONE feature in a standalone way, see: dwyl/technology-stack#96Essentially we just want to test that it's _possible to:
a. Have a bunch of
items
on a page with the following fields:text
id
index
b. Drag an item to a different position should refresh the ordering i.e.
index
of the adjacentitems
c. If the
item
from the bottom is moved to the top it will now haveindex=1
d. All the other
items
will have their index updated. So we need to get theitem.id
for each item on the page and update it's newindex
.e. Sync this update to another connected client e.g. using
LiveView
.Todo
Phoenix
App in this repo. call it "app" so that it's easy to copy-paste working code to theMVP
later.Phoenix
App, add the usual setup: Tailwind + Alpine see: mvp/BUILDIT.md#1-create-a-new-phoenix-appitems
schema but withoutpeople
or any other unnecessary data/fields. just:id
text
index
LiveView
page where we can build this experiement!items
in alist
#4 (comment))One More Thing ...
Technical Implementation is 100% Flexible at this point!
If you find a more efficient way of implementing this please share!
Right now we are 100% in the research & development phase.
Good luck! 🍀
The text was updated successfully, but these errors were encountered: