server icon indicating copy to clipboard operation
server copied to clipboard

Add "Sort Order" field to Application model and order by it

Open jberlyn opened this issue 5 months ago • 3 comments

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.

jberlyn avatar Jun 09 '25 07:06 jberlyn

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!

eternal-flame-AD avatar Jun 09 '25 10:06 eternal-flame-AD

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.

jmattheis avatar Jun 09 '25 10:06 jmattheis

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.

jberlyn avatar Jun 15 '25 06:06 jberlyn

I test the feature, I validate. image image

:+1:

The feature could be added to master and drag n drop could be added after

I'm OK to try add the dnd

xavier-GitHub76 avatar Jun 30 '25 20:06 xavier-GitHub76

@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?

eternal-flame-AD avatar Sep 16 '25 01:09 eternal-flame-AD

@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.

jberlyn avatar Sep 16 '25 01:09 jberlyn

I will push a pull request today to add drag and drop on sortOrder

xavier-GitHub76 avatar Oct 08 '25 04:10 xavier-GitHub76

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

xavier-GitHub76 avatar Oct 08 '25 05:10 xavier-GitHub76