0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Explicitly list widget JS in FooChooserAdapter media

This is necessary (according to the logic for adding Django form media objects together) whenever the JS adapter definition depends on anything defined in the widget JS - e.g. if foo-chooser.js defines `window.FooChooser`, and foo-chooser-telepath.js references that in the definition of FooChooserAdapter, then the only way to guarantee the correct ordering is with an explicit `['foo-chooser.js', 'foo-chooser-telepath.js']` media definition - adding two media objects does not guarantee this ordering.
This commit is contained in:
Matt Westcott 2023-01-11 16:50:34 +00:00
parent 7a1ae9f16b
commit f8c8bf06ba
3 changed files with 6 additions and 0 deletions

View File

@ -175,6 +175,8 @@ class DocumentChooserAdapter(BaseChooserAdapter):
def media(self):
return forms.Media(
js=[
versioned_static("wagtaildocs/js/document-chooser-modal.js"),
versioned_static("wagtaildocs/js/document-chooser.js"),
versioned_static("wagtaildocs/js/document-chooser-telepath.js"),
]
)

View File

@ -59,6 +59,8 @@ class ImageChooserAdapter(BaseChooserAdapter):
def media(self):
return forms.Media(
js=[
versioned_static("wagtailimages/js/image-chooser-modal.js"),
versioned_static("wagtailimages/js/image-chooser.js"),
versioned_static("wagtailimages/js/image-chooser-telepath.js"),
]
)

View File

@ -65,6 +65,8 @@ class SnippetChooserAdapter(BaseChooserAdapter):
def media(self):
return forms.Media(
js=[
versioned_static("wagtailadmin/js/chooser-modal.js"),
versioned_static("wagtailsnippets/js/snippet-chooser.js"),
versioned_static("wagtailsnippets/js/snippet-chooser-telepath.js"),
]
)