Create a Post
Node.js CMS & Web Application Platform
Title
Details
4
Sort from the owner side of a relationship
On a relationship X->Y, it's currently possible to change the sort order, only if the relationship is defined on the Y side with many:false and Y is made sortable:true. Then every Y document in the db has a SortOrder value which can be used in the views. This also allows for nice usage of sortContext, but even without the context it's fine because one can filter List Y to only show the ones that link to X and then change the sort-order with drag-and-drop within that context easily. But , it would have been much easier in many cases, if we could simply define the relationship on the X side, set many:true and then be able to change the order in the ui in the X side. In this case, each X document in the db is saved with an array of ids which point to Y documents. This is very preferable, because it makes building the views easier, as one can use the mongoose populate(... ) feature and easily load the children instead of having to async find queries to load them from the other side using X.id The only thing that's missing is a way in the adminUi to change the order of the selected items. The selection of the {many:true} items is done now using a multi-select dropdown. The only thing one can do is delete the contents of the dropdown and select them again in the order one desires. This can be really painful in cases where there are a lots of selections and a lot of things to select from. My suggestion is to either make the items draggable in the multi-select control, or to have something like a popup which brings a draggable list similar to the one shown in the case of sortable and sortContext. The end effect of the reordering operation would be to simply save the array in a different order, no extra index is needed, as the array itself inherently holds the items in a certain order Original: https://github.com/keystonejs/keystone/issues/2979
0
Load More