another approach

pull/11639/head
Abdelrahman 2024-03-06 04:01:32 +02:00
rodzic 62c597b786
commit 5c40147547
4 zmienionych plików z 14 dodań i 6 usunięć

Wyświetl plik

@ -34,7 +34,7 @@ export class PageChooser extends Chooser {
matchSubclass: this.opts.matchSubclass,
canChooseRoot: this.opts.canChooseRoot,
userPerms: this.opts.userPerms,
parentId: this.opts.parentId,
instanceId: this.opts.instanceId
};
if (this.state && this.state.parentId) {
opts.parentId = this.state.parentId;

Wyświetl plik

@ -251,6 +251,9 @@ class PageChooserModal extends ChooserModal {
if (opts.userPerms) {
urlParams.user_perms = opts.userPerms;
}
if (opts.instanceId) {
urlParams.instance_id = opts.instanceId;
}
return urlParams;
}
}

Wyświetl plik

@ -292,10 +292,12 @@ class BrowseView(View):
selected_locale = get_object_or_404(
Locale, language_code=request.GET["locale"]
)
active_locale_id = selected_locale.pk
elif request.GET.get("instance_id"):
page_instance = Page.objects.get(id=request.GET["instance_id"])
selected_locale = page_instance.locale
else:
active_locale_id = Locale.get_active().pk
selected_locale = get_object_or_404(Locale, id=active_locale_id)
selected_locale = Locale.get_active()
active_locale_id = selected_locale.pk
# we are at the Root level, so get the locales from the current pages
choose_url = reverse("wagtailadmin_choose_page")

Wyświetl plik

@ -300,8 +300,11 @@ class AdminPageChooser(BaseChooser):
opts = super().get_js_init_options(id_, name, value_data)
value_data = value_data or {}
parent_id = value_data.get("parent_id")
if parent_id is not None or self.page_instance is not None:
opts["parentId"] = parent_id or self.page_instance.id
if parent_id is not None:
opts["parentId"] = parent_id
if self.page_instance is not None:
opts["instanceId"] = self.page_instance.id
return opts
@property