From 32aa4b4f3e7a471ac965de43f3bdda118a7f11d7 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 16 May 2019 11:41:30 +0200 Subject: [PATCH] Fix #1286 -- Autofill quota names with products --- .../static/pretixcontrol/js/ui/quota.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/pretix/static/pretixcontrol/js/ui/quota.js b/src/pretix/static/pretixcontrol/js/ui/quota.js index b0860091a6..9d8a060e25 100644 --- a/src/pretix/static/pretixcontrol/js/ui/quota.js +++ b/src/pretix/static/pretixcontrol/js/ui/quota.js @@ -18,3 +18,24 @@ $(function () { ] }); }); + +$(function () { + if (!$("input[name=itemvars]").length) { + return; + } + var autofill = ($("#id_name").val() === ""); + + $("#id_name").on("change keyup keydown keypress", function () { + autofill = false; + }) + + $("input[name=itemvars]").change(function () { + if (autofill) { + var names = []; + $("input[name=itemvars]:checked").each(function () { + names.push($.trim($(this).closest("label").text())) + }); + $("#id_name").val(names.join(', ')); + } + }); +});