question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create improved sortable many relationship widget in Admin UI

See original GitHub issue

@morenoh149 based on our conversation on IRC I have created this issue (I’m d4rklit3 on freenode)

The Issue

The current UI does not allow for any kind of context based sorting of these relationships. The only place to sort an enumerable amount of models is this:

current_sort

This issue with this is that its a global sort. If you ever need to to have these items in a different order somewhere else there is no way to actually do this.

Currently this is what we have for a one-to-many relationship in Keystone:

tickers: {type:Types.Relationship, ref:"Ticker", many:true}

tagbox

I would like to propose something a bit more functional for providing contextual sorting for many:true relationships:

Some Background

In my experience with working on some custom CMS platforms (mostly built in YII over php) we would use MySQL and we would need to create join tables for this kind of thing. The join tables would allow for intermediary records to hold a context based sort order for an object relationship between 2 tables. I think the way Mongo handles “relationships” (in that it doesn’t) makes this problem almost non-existent outside of just using the proper UI.

All relationships in Mongo are just an array of ObjectIDs stored inside of an array. The index of that array can reliably used as the sort order.

Working Examples

I would like to propose that we move to a more functional interface for the many:true relationships within the schemas.

These are some successful UIs that I like or have used.

Wordpress ACF Relationship Field

image

This is from a more recent project I was working on where we had many different posts that would need to be in many different orders depending on what page they appeared on. This widget was really helpful.

JQuery UI Draggable

https://jqueryui.com/sortable/#default

I have used this many times. It’s pretty self explanitory.

React Flavored

http://webcloud.se/truly-reactive-sortable-component/

This may be helpful if you are using react.

One More For Good Measure

http://rubaxa.github.io/Sortable/

Proposed Solution

This is something I mocked up for what I was thinking.

ordered-relationships

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:3
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
guillaumewcommented, Nov 23, 2016

I also think this should be improved. My main trouble is that only a few elements of the collection are availbale when you have more than 100 items in your rederenced collection. In my case, it makes the admin quite useless.

0reactions
pr1ntrcommented, Jan 23, 2018

is this related? #3282

Read more comments on GitHub >

github_iconTop Results From Across the Web

Admin UI: show relationship values as links · Issue #564 · keystonejs ...
However, if the many: attribute is set to true then you cannot browse t... ... Create improved sortable many relationship widget in Admin...
Read more >
Is there a django admin widget that allows the admin to sort ...
I'll suggest you use django-treebeard. This allows you to view tree nodes hierarchically in the administration interface, with interface ...
Read more >
Backend sorting and reordering - Winter CMS
The Reorder behavior is a controller behavior that provides features for sorting and reordering database records.
Read more >
django-admin-sortable2
django-admin-sortable2¶. is a generic drag-and-drop ordering package to sort objects in the list- and detail inline-views of the Django admin interface.
Read more >
Configure sorting capabilities within mobile filters
Create a many-to-many relationship to connect the category and the item sorting. Select the Item Sorting tab within the Filter Category form.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found