Show QR code of a ticket directly from order details

This commit is contained in:
Raphael Michel
2019-02-21 15:23:29 +01:00
parent 407ecdf6c5
commit ca4c21a843
3 changed files with 44 additions and 0 deletions

View File

@@ -280,6 +280,10 @@
</form>
{% endfor %}
{% endif %}
<button type="submit" data-toggle="qrcode" data-qrcode="{{ line.secret }}"
class="btn btn-xs btn-default">
<span class="fa fa-qrcode"></span> {% trans "Ticket secret" %}
</button>
{% eventsignal event "pretix.control.signals.order_position_buttons" order=order position=line request=request %}
</div>
{% endif %}

View File

@@ -614,6 +614,36 @@ $(function () {
return false;
});
$("button[data-toggle=qrcode]").click(function (e) {
e.preventDefault();
var $current = $(".qr-code-overlay[data-qrcode=" + $(this).attr("data-qrcode") + "]");
if ($current.length) {
$(".qr-code-overlay").attr("data-qrcode", "").slideUp(200);
return false;
}
$(".qr-code-overlay").remove();
var $div = $("<div>").addClass("qr-code-overlay").attr("data-qrcode", $(this).attr("data-qrcode"));
$div.appendTo($("body"));
var offset = $(this).offset();
$div.css("top", offset.top + $(this).outerHeight() + 10).css("left", offset.left);
var $child = $("<div>");
$child.appendTo($div);
$child.qrcode(
{
text: $(this).attr("data-qrcode"),
correctLevel: 0, // M
width: 196,
height: 196
}
);
$div.append(gettext("Click to close"));
$div.slideDown(200);
$div.click(function (e) {
$(".qr-code-overlay").slideUp(200);
});
return false;
});
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
moment.locale($("body").attr("data-datetimelocale"));
});

View File

@@ -608,3 +608,13 @@ details summary {
h1 .label {
display: inline-block;
}
.qr-code-overlay {
display: none;
position: absolute;
padding: 30px;
background: white;
text-align: center;
border-radius: $border-radius-small;
box-shadow: 0 7px 14px 0 rgba(78, 50, 92, 0.1),0 3px 6px 0 rgba(0,0,0,.07);
}