From 5dfd1e6337ba3eb8133084a167f2aee81101fa61 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Thu, 4 Apr 2019 14:13:08 +0200 Subject: [PATCH] Prefill attendee name/email of first ticket with contact email and invoice recipient --- src/pretix/static/pretixpresale/js/ui/main.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/pretix/static/pretixpresale/js/ui/main.js b/src/pretix/static/pretixpresale/js/ui/main.js index c79b25a245..7ff44da4a5 100644 --- a/src/pretix/static/pretixpresale/js/ui/main.js +++ b/src/pretix/static/pretixpresale/js/ui/main.js @@ -153,6 +153,28 @@ $(function () { copy_answers(idx); return false; }); + var copy_to_first_ticket = true; + $("input[id*=attendee_name_parts_], input[id*=attendee_email]").each(function () { + if ($(this).val()) { + copy_to_first_ticket = false; + } + }) + $("input[id^=id_name_parts_], #id_email").change(function () { + console.log(copy_to_first_ticket); + console.log($(".questions-form").first().select("input[id*=attendee_email]")); + console.log($("#id_email").val()); + if (copy_to_first_ticket) { + $(".questions-form").first().find("input[id*=attendee_email]").val($("#id_email").val()); + $(".questions-form").first().find("input[id*=attendee_name_parts]").each(function () { + var parts = $(this).attr("id").split("_"); + var num = parts[parts.length - 1]; + $(this).val($("#id_name_parts_" + num).val()); + }); + } + }); + $("input[id*=attendee_name_parts_], input[id*=attendee_email]").change(function () { + copy_to_first_ticket = false; + }); // Subevent choice if ($(".subevent-toggle").length) {