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

allow to re-order items within a shelf #521

Open
maxlath opened this issue Apr 17, 2021 · 6 comments
Open

allow to re-order items within a shelf #521

maxlath opened this issue Apr 17, 2021 · 6 comments

Comments

@maxlath
Copy link
Member

maxlath commented Apr 17, 2021

Re-ordering items has been a recurring feature request.

This could be implemented by adding an ordinal to items' shelves array, from the current array of id:

[
  '0a35e15bdff5c8c0507207898f00003c',
  'a51ca773050dc882b8105b0d18000ecc'
]

to an array of objects:

[
  { id: '0a35e15bdff5c8c0507207898f00003c', ordinal: 5 },
  { id: 'a51ca773050dc882b8105b0d18000ecc' }
]

This should allow to get the items of a given shelf already ordered directly from CouchDB

@jum-s
Copy link
Contributor

jum-s commented Apr 17, 2021

isnt an array already an ordered list, one can query with an index, reorder at will etc. ?

@maxlath
Copy link
Member Author

maxlath commented Apr 17, 2021

@jum-s the array above is on a single item that is in several shelves, the ordinal then gives the place of that item within those different shelves.

For instance, the 2 following items could be ordered within 3 different shelves like so:

{
  _id: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
  entity: 'isbn:9782729897093',
  shelves: [
    { id: '0a35e15bdff5c8c0507207898f00003c', ordinal: 1 },
    { id: 'a51ca773050dc882b8105b0d18000ecc', ordinal: 1 },
    { id: 'cce00081d0b5018b288cd050377ac15a', ordinal: 2 }
  ]
}
{
  _id: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
  entity: 'isbn:9781941999738',
  shelves: [
    { id: '0a35e15bdff5c8c0507207898f00003c', ordinal: 2 },
    { id: 'a51ca773050dc882b8105b0d18000ecc', ordinal: 2 },
    { id: 'cce00081d0b5018b288cd050377ac15a', ordinal: 1 }
  ]
}

@jum-s
Copy link
Contributor

jum-s commented Apr 17, 2021

im a bit rusty, my bad

@jum-s
Copy link
Contributor

jum-s commented Apr 17, 2021

the other question to me is : isnt it the client responsibility to sort items. Is it that necessary to store this information server-side ? Users may not that much appreciate to sort "for good" and just according to the current need/mood.
I guess it depends also how users may sort items (completely custom order, or only according to some criterias (alphabetical title, alphabetical first author, last added, by transations etc)).

@maxlath
Copy link
Member Author

maxlath commented Apr 19, 2021

I see 2 distinct features:

  • the possibility to dynamically re-order the items in an inventory or shelf in various ways : by title or author sorted alphabetically, by publication date, by date of addition to the inventory (the only mode currently available). This kind of sort could be done by anyone browsing an inventory and are mostly a problem for the client (even if that requires that the server be able to produce those items list paginated in those different orders, unless we fully load the inventory items in the client, but that's likely to not scale for large inventories)
  • the possibility for an inventory or shelf owner to modify the default order, to present their inventory in a certain order to visitors, just like a book shop or a library would physically organize their display shelf ([fr] présentoir à livre). That's this feature that I was describing, which, to be visible by others than the inventory owner, would need to be saved in the database.

@alexture
Copy link

Also ties in to #315

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

3 participants