This is using value-list which already has drag-and-drop but makes editing impossible, if you want to edit you have to delete row and recreate it, because all events on the row are for drag/drop.
So my options:
1- modify directly value-list, remove drag and drop, and make edit on row click
2- duplicate value-list (unordered-value-list?) removes drag and drop and make edit on row click
If you tell me,; just remove drag and dropd everywhere it doesn’t work I will go with 1. So far I have done 1, going to 2 is a matter of few minutes.
To make editing the simplest possible I made the following choices:
Click a row will remove it from selection, and put it in “add input”:
If you already had something in “add input” when clicking on a row, this content will be added to selection before being replaced by the content for the clicked row:
In this example I had “test” in the “add input” and clicked on “something,
http://www.google.fr” row
4 Likes
@sam Could you review it please https://github.com/discourse/discourse/pull/6194 ?
I went for a new component so I could test/refactor it more easily. We could remove {{value-list}} in the future very easily.
I added support for list_type
in a site setting, this way compact_list is usable everywhere but doesn’t duplicate all the list logic.
7 Likes
I just merged it. And made a few changes from the initial plan.
- I completely replaced
{{value-list}}
by this
- It’s an hybrid component using a select-kit combo-box and some custom HTML
- Drag an drop support is dropped, because you can now directly edit each line
8 Likes
There are two major TODO items left on this:
- I need to push one select-kit improvement, currently select-kit will not expand if you click on it and there are no selectable items left. Even if we allow to create items, in this case I would want it to expand with the create row already displayed and ready to take input.
- You can edit an existing input, but the save/cancel buttons will only show when you focusout of the input. I didn’t have a trivial way to fix it for now, will think more about it.
6 Likes
I have the fix for first item of this TODO: https://github.com/discourse/discourse/pull/6237
Will write a test for this and then push it tomorrow.
6 Likes