You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came across this writing a custom chooser widget. All I needed to do for the adapter was update the widget class in the chooser factory which should be an easy thing by extending the ChooserFactory class. This would keep it in sync with the Wagtail current code and require minimum maintennance and coding.
I couldn't find any way to access the underlying class which made me think it would be really beneficial to expose classes as part of the telepath.register() process.
For example:
window.telepath.register('wagtail.snippets.widgets.SnippetChooser', SnippetChooserFactory,);
could expose the class via window.telepath.wagtail.snippets.widgets.SnippetChooser
then the custom ChooserFactory can just be declared as
Doesn't require source code or hacking the minified code to expose the class.
I've ended up copying the minified code, working out which is the relevant class and exposing it in there. Ugly and overly complicated solution that requires continuous updating to be version compliant now. Perhaps I've just missed a cleaner, better way to do this.
The text was updated successfully, but these errors were encountered:
enzedonline
changed the title
Suggestion: Expose registered classes to allow easy extending without source repacking
Suggestion: allow easier extending of registered classes
Aug 11, 2023
I wonder if this could be simplified using a mixin approach and an 'extends' optional parameter in the telepath.register method, so my code above would just be something along the lines of:
I came across this writing a custom chooser widget. All I needed to do for the adapter was update the widget class in the chooser factory which should be an easy thing by extending the
ChooserFactory
class. This would keep it in sync with the Wagtail current code and require minimum maintennance and coding.I couldn't find any way to access the underlying class which made me think it would be really beneficial to expose classes as part of the
telepath.register()
process.For example:
window.telepath.register('wagtail.snippets.widgets.SnippetChooser', SnippetChooserFactory,);
could expose the class via
window.telepath.wagtail.snippets.widgets.SnippetChooser
then the custom
ChooserFactory
can just be declared asDoesn't require source code or hacking the minified code to expose the class.
I've ended up copying the minified code, working out which is the relevant class and exposing it in there. Ugly and overly complicated solution that requires continuous updating to be version compliant now. Perhaps I've just missed a cleaner, better way to do this.
The text was updated successfully, but these errors were encountered: