diff --git a/src/pretix/static/pretixcontrol/js/ui/main.js b/src/pretix/static/pretixcontrol/js/ui/main.js index 3c82ccfdb..a6d44e907 100644 --- a/src/pretix/static/pretixcontrol/js/ui/main.js +++ b/src/pretix/static/pretixcontrol/js/ui/main.js @@ -1,5 +1,51 @@ /*global $,gettext*/ +function question_page_toggle_view() { + var show = $("#id_type").val() == "C" || $("#id_type").val() == "M"; + $("#answer-options").toggle(show); + + show = $("#id_type").val() == "B" && $("#id_required").prop("checked"); + $(".alert-required-boolean").toggle(show); + + let input = $('#id_default_value'); + let common_attrs = ' name="default_value" placeholder="' + input.attr('placeholder') + '" title="' + input.attr('title') + '" id="id_default_value"'; + let value = input.val(); + switch ($("#id_type").val()) { + case 'N': + input.replaceWith(''); + $('.form-group:has(#id_default_value)').show(); + break; + case 'S': + input.replaceWith(''); + $('.form-group:has(#id_default_value)').show(); + break; + case 'T': + input.replaceWith(''); + $('.form-group:has(#id_default_value)').show(); + break; + case 'B': + let checked = (value === 'True' ? 'checked' : ''); + input.replaceWith(''); + $('.form-group:has(#id_default_value)').show(); + break; + case 'F': + $('.form-group:has(#id_default_value)').hide(); + break; + case 'D': + input.replaceWith(''); + $('.form-group:has(#id_default_value)').show(); + break; + case 'H': + input.replaceWith(''); + $('.form-group:has(#id_default_value)').show(); + break; + case 'W': + input.replaceWith(''); + $('.form-group:has(#id_default_value)').show(); + break; + } +} + var waitingDialog = { show: function (message) { "use strict";