wagtail-nest / wagtail-modeladmin

Add any model in your project to the Wagtail admin. Formerly wagtail.contrib.modeladmin.
Other
21 stars 8 forks source link

Feature request: Rearrange order of objects in modeladmin index view #9

Open adriaant opened 8 years ago

adriaant commented 8 years ago

In wagtail admin, it is possible to rearrange the order of pages in the admin editor. This is a feature that would work equally well for custom models managed via modeladmin, provided the models inherit the Orderable mixin. This is useful for pages that provide a list of all/filtered objects of a given model, but for which you want to provide the user with an option to define the order of the objects on the page.

For example: A custom model for FAQ categories and a page that grabs the categories dynamically during rendering and displays them according to the order stored in the db. In other words, all the user has to do is create categories (and the contained questions) in the modeladmin interface.

Is this something already being considered or worth discussing?

ababic commented 7 years ago

One approach to this would be to create an OrderableMixin class, to be used with the ModelAdmin class where needed (much like the ThumbnailMixin). The basic elements of which would be:

  1. Getting the ID/order values for each object into the listing, so the data is available to create reorder requests
  2. Some view functionality to take care of reorder requests
  3. Some javascript with drag-and-drop support to bind it all together

From a UI/UX perspective, it'd make sense to match the page reordering approach as closely as possible. I haven't looked yet, but I'd expect there'd be some JS/styles that can be reused, or at least serve as a decent starting point to copy from.

I'd be happy to work on a pull-request.

adriaant commented 7 years ago

What is the status of this ticket? I noticed PR is closed, but has actually not been merged.

ababic commented 7 years ago

Hey @adriaant. The branch still exists here if you wanted to copy/paste for a project in the meantime: https://github.com/rkhleics/wagtail/tree/modeladmin/orderableadmin-2

I closed wagtail/wagtail#3103 because It didn't look like it was going to be reviewed any time soon, and there are a bunch of other issues that need addressing that would just introduce a bunch of merge conflicts for that wagtail/wagtail#3103. I'd rather just recreate the functionality later (with a bit less scope-creep) after having rebased everything on master.

adriaant commented 7 years ago

@ababic Understood, thanks for the quick and clear reply!

vstoykov commented 6 years ago

This will be very nice addition to Wagtail.

inostia commented 5 years ago

Is there any reason why this wasn't merged yet? This is a necessary feature for my org, we need to render the items on the FE in the order they appear on the admin interface.

tomdyson commented 5 years ago

@inostia why what wasn't merged? This is an issue, not a PR. There was an associated PR, but that was closed for reasons outlined above.

inostia commented 5 years ago

Good call @tomdyson, yes this is a GH issue. I was referring to the PR referenced in this thread, and the reason given for not merging that the original PR wasn't reviewed (as well as the apparent conflicts from the work), which led me to believe that this feature is not a high priority for the Wagtail team. I'd be happy to take a look at this (and @ababic's work) this weekend to see if I can contribute. If it's a super hairy issue I may end re-working requirements a bit, and attaching the Orderable to a page instead.

elton2048 commented 5 years ago

For guys who requires this feature I created a package wagtail-orderable for that. Simply extends with the Orderable model and apply OrderableMixin for wagtail_hooks.py should give you the feature. Leave any issue if any.

Most code are contributed by @ababic from this commit with minor modification for mainly versioning issue. Once again thanks for his contribution.

ababic commented 5 years ago

@elton2048 thank you for taking the time to put wagtail-orderable together. I really feel a separate package is the best way to go here. Far easier to gather feedback and evolve things that way.

inostia commented 5 years ago

Thank you @elton2048! This is awesome, will give it a try soon.