ixc / wagtail-instance-selector

A widget for Wagtail's admin that allows you to create and select related items
MIT License
54 stars 17 forks source link

Wagtail 2.13 compatibility #14

Closed gasman closed 3 years ago

gasman commented 3 years ago

Fixes #11. The new telepath StreamField implementation in 2.13 requires some fairly heavy refactoring to the InstanceSelector widget, since InstanceSelector was quite heavily reliant on rendering a template for each instance, while StreamField needs to be able to construct them client-side from serialised data. I got it working by extracting an 'state' dict consisting of the pk, display_markup and edit_url, which can be used by both the server-side and client-side rendering logic.

(For reference, I submitted a fairly similar patch to wagtailmodelchooser that might help in following the changes: https://github.com/neon-jungle/wagtailmodelchooser/pull/27)

gasman commented 3 years ago

Just to add - wagtail-instance-selector's modal embeds are affected by https://github.com/wagtail/wagtail/pull/7169, so if you test against the current 2.13 release candidates you may encounter JS errors on opening them... this will be fixed for 2.13 final.

zerolab commented 3 years ago

@markfinger Wagtail 2.13 is now out - https://github.com/wagtail/wagtail/releases/tag/v2.13 - would be great to have this reviewed and released out in the wild, if you have time.

mixxorz commented 3 years ago

This looks amazing! Thanks @gasman!

markfinger commented 3 years ago

Thanks for all the work, @gasman. Sorry for the delay in response, I've been on leave.

I've run a quick test against one of our wagtail 2.11 systems, and everything looks alright.

markfinger commented 3 years ago

Thanks again to everyone for the reports and the fixes. 2.1.0 been published with @gasman's fixes.