Skip to content
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

Preserve sorting order of collections #1762

Open
afuechsel opened this issue Nov 24, 2021 · 6 comments
Open

Preserve sorting order of collections #1762

afuechsel opened this issue Nov 24, 2021 · 6 comments

Comments

@afuechsel
Copy link

Is your feature request related to a problem? Please describe.
I'm always frustrated when opening my long collection that the sorting order is NOT preserved.

Describe the solution you'd like
When opening a collection the queries could be sorted in different ways. The last set sorting order should be meomorized somehow so when I open the collection again next time it's automatically sorted in this very order.

Describe alternatives you've considered
No alternatives.

Additional context

@bombillazo
Copy link

I second this feature!

@ahmb
Copy link

ahmb commented Apr 27, 2023

number each request in the flow i.e. 1. request a 2. request b etc , and then the app can sort by name

@imolorhe i think it would be a very simple change , we could add a sort operation to the collectionTreeToNzTreeNode method. I can create a branch and do it if you are okay with the implementation. Atleast it will have some natural order vs last updated time which I think it is right now.

In the code below, the children variable is assigned the sorted array of child collections by calling the sort function on the collections array and providing a comparison function that compares the title property of each collection using the localeCompare function. The map function is then called on the sorted children array to recursively convert each child collection to a NzTreeNodeOptions object.

C:\Users\roboto\Source\Repos\altair\packages\altair-app\src\app\modules\altair\components\add-collection-query-dialog\add-collection-query-dialog.component.ts:

collectionTreeToNzTreeNode(
  collectionTree: IQueryCollectionTree
): NzTreeNodeOptions {
  const children = collectionTree.collections?.sort((a, b) => a.title.localeCompare(b.title))
    .map((ct) => this.collectionTreeToNzTreeNode(ct));
  return {
    title: collectionTree.title,
    key: `${collectionTree.id}`,
    children,
  };
}

@imolorhe
Copy link
Collaborator

@ahmb it will be a little more complicated than that. There is already the sorting option. The concern is about preserving the sorting order after changing it. One way to solve this is to store the sorting information on the collection objects themselves. The concern I have with that is that users of the exported collection may have different sorting preferences from what was selected. This may not be a big issue since the collection can be resorted again.

Alternatively, the sorting order can be stored in the application state and applied globally to all the collections by default.

@imolorhe imolorhe mentioned this issue Apr 28, 2023
3 tasks
@ahmb
Copy link

ahmb commented Apr 28, 2023

thanks for the response @imolorhe but i interpreted this a bit differently. Hear me out here, the main request is to "Preserve it" , you could say "Presist" is one form of it , but what triggered this issue was:

Is your feature request related to a problem? Please describe.
I'm always frustrated when opening my long collection that the sorting order is NOT preserved.

I was able to recreate this , but for me it happens whenever I save or modify a request in that collection. In my screenshot 1,2,3 were in order, but when i saved updates to the second request, it then showed up at the bottom :
image

Im assuming this is because of a default sort on last updated datetime. So from a UX perspective i think a standard is to first sort on name alphabetically in an ascending fashion. I think this can be a quick fix and will alleviate this issue for now.

Secondly, yes you are right about adding additional sorting persistence , incase the order is modified by the user to something custom i.e. not alphabetical. Then in that case as part of the collection metadata , along with each requests name etc we can add one more property for index. That can be the updated as the user drags + drops requests in the collection to change the order. And the user importing the collection should have the same sort coming in, with the difference that theres standard sorting options like Name ascending/descending to override the index in the UI. But this would be a bigger update.

@imolorhe
Copy link
Collaborator

@ahmb I tried to reproduce that but can't seem to do so (unless my recent changes also fixes that):

  • I created a new collection
  • Added a query starting with A
  • Added a query starting with B
  • Changed the sorting order to Z-A
  • Added a query starting with C
  • The C query got placed at the top of the list as expected

Is this different from what you're experiencing?

@ahmb
Copy link

ahmb commented Apr 28, 2023

oh i see sorry my bad! i totally missed the sort option! please disregard the short term fix, @imolorhe thank you for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants