OpenUserJS / OpenUserJS.org

The home of FOSS user scripts.
https://openuserjs.org/
GNU General Public License v3.0
857 stars 305 forks source link

Sorting by another column inverts the current order #803

Open jesus2099 opened 9 years ago

jesus2099 commented 9 years ago

Let’s say you have clicked Installed to sort by descending download times. Now you click the next column (Ratings I guess), it will now sort ascending instead of descending. It should keep the last selected order, IMO. :)

sizzlemctwizzle commented 9 years ago

Using the default order for the newly selected column makes sense to me. Can you give me examples of other applications that exhibit the behavior you want? On Nov 5, 2015 10:22 AM, "PATATE12" notifications@github.com wrote:

Let’s say you have clicked Installed to sort by descending download times. Now you click the next column (Ratings I guess), it will now sort ascending instead of descending. It should keep the last selected order, IMO. :)

— Reply to this email directly or view it on GitHub https://github.com/OpenUserJs/OpenUserJS.org/issues/803.

jesus2099 commented 9 years ago

Using the default order for the newly selected column makes sense to me.

It makes sense to me too but the oujs sorting is not using defaults. Let me be more clear on what is right and what seems wrong to me.  :)

https://openuserjs.org shows scripts sorted by unknown column, unknown direction. From here :

  1. Clicking Name is ascending (good default)
    1. Clicking Name is descending (good opposite)
      1. Clicking Name is ascending (good opposite) → goto 1.
      2. Clicking Installs is ascending (NO GOOD :red_circle:)
      3. Clicking Rating is ascending (NO GOOD :red_circle:)
      4. Clicking Last Updated is ascending (NO GOOD :red_circle:)
    2. Clicking Installs is descending (good by luck) → goto 2.
    3. Clicking Rating is descending (good by luck) → goto 3.
    4. Clicking Last Updated is descending (good by luck) → goto 4.
  2. Clicking Installs is descending (good default)
    1. Clicking Name is ascending (good by luck) → goto 1.
    2. Clicking Installs is ascending (good opposite)
    3. Clicking Rating is ascending (NO GOOD :red_circle:)
    4. Clicking Last Updated is ascending (NO GOOD :red_circle:)
  3. Clicking Rating is descending (good default)
    1. Clicking Name is ascending (good by luck) → goto 1.
    2. Clicking Installs is ascending (NO GOOD :red_circle:)
    3. Clicking Rating is ascending (good opposite)
    4. Clicking Last Updated is ascending (NO GOOD :red_circle:)
  4. Clicking Last Updated is descending (good default)
    1. Clicking Name is ascending (good by luck) → goto 1.
    2. Clicking Installs is ascending (NO GOOD :red_circle:)
    3. Clicking Rating is ascending (NO GOOD :red_circle:)
    4. Clicking Last Updated is ascending (good opposite)

I could write all the cases but It’s becoming more and more confusing, I think now you can see my point…

Each opposite click is OK, but the problem is that the default is not used on other columns, it’s always using the same as the opposite click.

Martii commented 9 years ago

https://openuserjs.org shows scripts sorted by unknown column, unknown direction.

That would be https://openuserjs.org/?orderBy=rating&orderDir=desc I believe

1) Clicking Name is ascending (good default)

True

i) Clicking Name is descending (good opposite)

True

a) Clicking Name is ascending (good opposite) → goto 1.

True... went to 1. ...since you didn't say go back to 1.i.b. I did it anyhow and it generates:

b) Clicking Installs is ascending (NO GOOD :red_circle:)

FALSE... the URI is https://openuserjs.org/?orderBy=installs&orderDir=desc and Quack Toolsammlung is the top installed (Userscript) on the site and at the top of the list here as expected.

Try to reduce what you are experiencing down. Having that many test cases is too much.

That routine is handled currently here with the (initial) defaults... when not using any orderDir and orderBy QSPs and currently here with the toggling... if you can find something that is more agreeable to what you are looking for please post the logic behind it... however from here your use cases fail in the first test with a false report of NO GOOD.

Martii commented 9 years ago

So to elaborate on the current logic on a very reduced test case...

  1. Start at https://openuserjs.org/ ... all initial defaults are in place since there aren't any QSPs
  2. Clicking "Name" pushes you into using the QSPs... where the toggle (sort) function will invert what you are currently sorting by... this is intended behavior.

Now if you start at a QSPd URI of:

  1. https://openuserjs.org/?orderBy=rating&orderDir=desc ... the initial defaults are not applied because you are using the QSPs... you'll notice all the orderDirections are the same.
  2. So the toggle function will invert your sort order... again intended behavior.

If you can find some code logic that changes it to what you are expecting I'll try it out... but as far as I can tell this is intended behavior.

Martii commented 9 years ago

Another example of this is:

  1. Start out by using https://openuserjs.org/?orderBy=updated and that uses the initial default orderDirection for all table headers... as expected since the toggle (sort) routine isn't requested at this point.
jesus2099 commented 9 years ago

Ok my explanation was even less understandable than first post, sorry. :) Let's say I go to my page where I want to see latest updated. I click Last Updated. Now I want to see most downloaded, so click Installs. Here is the problem, now I see the Least installed. Same problem if I had wanted the best noted. It keeps going back and forth between best and worst and it is unusual user experience, no?

Martii commented 9 years ago

I'm tinkering with it now... I'll see if I can get it your style... but I may have to do this in a User preference to accommodate sizzle and the intended defaults... still running through some permutations... basically what you are looking for is the table headers not to use the orderDir with the exception of if you are on the orderBy... give me some time to ponder on it.

Martii commented 9 years ago

GH is also not cooperating very well in dev environment so difficult to test at this time.

jesus2099 commented 9 years ago

Yes yes please take your time to think it... Compare with what you usually expect or have elsewhere. I may be mistaking so it is good when more people think it...

Martii commented 9 years ago

@sizzlemctwizzle The commit branch above might be feasible... please give it a whirl under the stated conditions for now on dev and local pro and see if this is something that you want to implement as a site default or as a site option (or find any boogs in logic). To me the coding itself makes more sense this way although I think orderDir() needs to be combined into this somehow... perhaps with a JSON config file.

Steps to test:

  1. Start at http://localhost:8080/ (works on libraries too but not in other model lists yet)
  2. Click "Last Updated" which brings you to http://localhost:8080/?orderBy=updated ... which is currently a default of descending because newer dates are larger.
  3. Click "Last Updated" again which brings you to http://localhost:8080/?orderBy=updated&orderDir=asc ... which shows the smaller dates, or older dates.
  4. Here's the change... Click "Installs" which brings you to http://localhost:8080/?orderBy=installs ... which is currently a default of descending to show largest install counts first.