diff --git a/src/pretix/control/forms/item.py b/src/pretix/control/forms/item.py index 5a2b158c0a..00b894395a 100644 --- a/src/pretix/control/forms/item.py +++ b/src/pretix/control/forms/item.py @@ -1142,6 +1142,10 @@ class ItemAddOnForm(I18nModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['addon_category'].queryset = self.event.categories.all() + self.fields['addon_category'].help_text = format_html('{}', reverse('control:event.items.categories.add', kwargs={ + 'event': self.event.slug, + 'organizer': self.event.organizer.slug, + }), _("Create new category")) self.fields['addon_category'].widget = Select2( attrs={ 'data-model-select2': 'generic', diff --git a/src/pretix/static/pretixcontrol/js/ui/main.js b/src/pretix/static/pretixcontrol/js/ui/main.js index d028897b2f..a4777077a4 100644 --- a/src/pretix/static/pretixcontrol/js/ui/main.js +++ b/src/pretix/static/pretixcontrol/js/ui/main.js @@ -1122,6 +1122,38 @@ $(function () { }).areYouSure({ message: gettext('You have unsaved changes!') }) }) +function show_django_dialog(url, callback) { + function messageEvent(e) { + console.log('messageEvent', e.origin, e.source, e.data) + if (e.origin === location.origin && e.data.type === 'pretix:dialog-loaded') { + $dlg.find("iframe").attr("height", Math.min(window.innerHeight - 120, e.data.contentHeight|0)).css("visibility", "visible") + $dlg.find("center").remove() + } + if (e.origin === location.origin && e.data.type === 'pretix:notify-parent') { + $dlg[0].close() + if (!callback(e.data.data)) { + if (e.data.data.messages?.length) { + alert(e.data.data.messages.map(m => m.message).join('\n\n')) + } + } + } + } + var $dlg = $('
') + .css('max-width', '60em') + $dlg.find("iframe").attr("src", url).css("visibility", "hidden").css("border", "0") + window.addEventListener('message', messageEvent) + $dlg.appendTo("body") + $dlg.on('close', function() { + window.removeEventListener('message', messageEvent) + $dlg.remove() + }) + $dlg[0].showModal() +} +$(function() { + $("[data-django-dialog]").on("click", function(e) { + show_django_dialog(this.getAttribute("data-django-dialog"), function() {}) + }) +}) function notify_parent_frame() { window.addEventListener('message', function(e) { if (e.source === window) return