kopia lustrzana https://github.com/wagtail/wagtail
Deprecate createSnippetChooser
rodzic
f3e40571f1
commit
be5b8c41c7
|
@ -1,4 +1,4 @@
|
|||
class SnippetChooser {
|
||||
class SnippetChooserFactory {
|
||||
constructor(html, idPattern) {
|
||||
this.html = html;
|
||||
this.idPattern = idPattern;
|
||||
|
@ -8,14 +8,14 @@ class SnippetChooser {
|
|||
const html = this.html.replace(/__NAME__/g, name).replace(/__ID__/g, id);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
placeholder.outerHTML = html;
|
||||
/* the chooser object returned by createImageChooser also serves as the JS widget representation */
|
||||
/* the SnippetChooser object also serves as the JS widget representation */
|
||||
// eslint-disable-next-line no-undef
|
||||
const chooser = createSnippetChooser(id);
|
||||
const chooser = new SnippetChooser(id);
|
||||
chooser.setState(initialState);
|
||||
return chooser;
|
||||
}
|
||||
}
|
||||
window.telepath.register(
|
||||
'wagtail.snippets.widgets.SnippetChooser',
|
||||
SnippetChooser,
|
||||
SnippetChooserFactory,
|
||||
);
|
||||
|
|
|
@ -20,8 +20,10 @@ class SnippetChooser extends Chooser {
|
|||
return this.chooserBaseUrl + urlQuery;
|
||||
}
|
||||
}
|
||||
window.SnippetChooser = SnippetChooser;
|
||||
|
||||
function createSnippetChooser(id) {
|
||||
/* RemovedInWagtail50Warning */
|
||||
return new SnippetChooser(id);
|
||||
}
|
||||
window.createSnippetChooser = createSnippetChooser;
|
||||
|
|
|
@ -144,3 +144,7 @@ The `move_breadcrumb` template tag is no longer used and has been removed.
|
|||
### `wagtail.contrib.modeladmin.menus.SubMenu` is deprecated
|
||||
|
||||
The `wagtail.contrib.modeladmin.menus.SubMenu` class should no longer be used for constructing submenus of the admin sidebar menu. Instead, import `wagtail.admin.menu.Menu` and pass the list of menu items as the `items` keyword argument.
|
||||
|
||||
### `createSnippetChooser` replaced with `SnippetChooser` class
|
||||
|
||||
The JavaScript function `createSnippetChooser(id)` has been deprecated; user code should call `new SnippetChooser(id)` instead.
|
||||
|
|
|
@ -1294,7 +1294,7 @@ class TestSnippetChooserPanel(TestCase, WagtailTestUtils):
|
|||
|
||||
def test_render_js(self):
|
||||
self.assertIn(
|
||||
'createSnippetChooser("id_advert");',
|
||||
'new SnippetChooser("id_advert");',
|
||||
self.snippet_chooser_panel.render_as_field(),
|
||||
)
|
||||
|
||||
|
@ -2502,7 +2502,7 @@ class TestSnippetChooserPanelWithCustomPrimaryKey(TestCase, WagtailTestUtils):
|
|||
|
||||
def test_render_js(self):
|
||||
self.assertIn(
|
||||
'createSnippetChooser("id_advertwithcustomprimarykey");',
|
||||
'new SnippetChooser("id_advertwithcustomprimarykey");',
|
||||
self.snippet_chooser_panel.render_as_field(),
|
||||
)
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class AdminSnippetChooser(BaseChooser):
|
|||
raise
|
||||
|
||||
def render_js_init(self, id_, name, value_data):
|
||||
return "createSnippetChooser({id});".format(id=json.dumps(id_))
|
||||
return "new SnippetChooser({id});".format(id=json.dumps(id_))
|
||||
|
||||
@cached_property
|
||||
def media(self):
|
||||
|
|
Ładowanie…
Reference in New Issue