server
server copied to clipboard
Add "Sort Order" field to Application model and order by it
This is my attempt at resolving: https://github.com/gotify/server/issues/358
This adds a new field to Application called "Sort Order". When fetching the list of Applications by user, it will order by this Sort Order. By default, Applications will have a Sort Order of 0.
This is my first time contributing to a Go codebase, I am not familiar with the database tooling so I am unsure if this will automatically migrate the Application table to include the "Sort Order" column.
Happy to take feedback on this feature implementation.
Thanks! It looks generally good. I have no problem going with this design, might be a couple nitpicks for a deep look before merge but otherwise looking good. However there might be a more user friendly UX.
Do you know about sortable drag and drop list? The one where you have "Apple" on one line, "Banana" on the second, and you can swap orders between them? I think it would be more intuitive than inputting a number.
you can implement this by labeling the "sort order" of Apps from 0-N, and then when the user drag and drop you upload a new sequence, or swap the index of two apps. I would prefer the full update approach since we are displaying Apps on one page anyways so there won't be too much.
Let me know if you are up to it!
Another option would be to use decimals when reordering, this way only one app has to be updated in the database. E.g. You have this order (the number is the sort order index)
1. Apple
2. Banana
3. Orange
When now reordering Orange between Apple and Banana it would get the sort order 1.5.
But the full update proposal from eternal-flame-AD is fine too.
I am not sure when I will get around to making any improvements to this pull request, but happy for others to contribute if they would like to round out this feature.
I test the feature, I validate.
:+1:
The feature could be added to master and drag n drop could be added after
I'm OK to try add the dnd
@jberlyn Do you still plan on finishing this PR or are you open to me finishing it when I got some spare time to spend since it seems there is community need for this?
@jberlyn Do you still plan on finishing this PR or are you open to me finishing it when I got some spare time to spend since it seems there is community need for this?
More than happy for you to take a look at it.
I will push a pull request today to add drag and drop on sortOrder
The pull request is created https://github.com/gotify/server/pull/856 I merged the changes made by @jberlyn to resolve conflicts This PR could be close