mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
* Added copying multiple tickets answers enhancement (#149) * Copying of multiple tickets answers enhancement - review for #292 (#149) * changed to button and removed unbinging * Removed unused button id attribute - changes for PR #149 * Housekeeping
This commit is contained in:
committed by
Raphael Michel
parent
2f0c7c0ebc
commit
79c65496b9
@@ -41,6 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% for form in forms %}
|
{% for form in forms %}
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
@@ -51,11 +52,16 @@
|
|||||||
– {{ form.pos.variation }}
|
– {{ form.pos.variation }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
|
{% if forloop.counter > 1 %}
|
||||||
|
<span class="text-right pull-right">
|
||||||
|
<input type="button" data-id="{{ forloop.counter0 }}" name="copy" class="js-copy-answers btn btn-block" value='{% trans "Copy answers from above" %}'>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div id="cp{{ form.pos.id }}"
|
<div id="cp{{ form.pos.id }}"
|
||||||
class="panel-collapse collapsed in">
|
class="panel-collapse collapsed in">
|
||||||
<div class="panel-body">
|
<div class="panel-body" data-idx="{{ forloop.counter0 }}">
|
||||||
{% bootstrap_form form layout="horizontal" %}
|
{% bootstrap_form form layout="horizontal" %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -35,8 +35,50 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
||||||
|
|
||||||
|
// Copy answers
|
||||||
|
$(".js-copy-answers").click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var idx = $(this).data('id');
|
||||||
|
bind_groups(idx);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function bind_groups(idx) {
|
||||||
|
var elements = $('*[data-idx="'+idx+'"] input, *[data-idx="'+idx+'"] select, *[data-idx="'+idx+'"] textarea');
|
||||||
|
var firstAnswers = $('*[data-idx="0"] input, *[data-idx="0"] select, *[data-idx="0"] textarea');
|
||||||
|
elements.each(function(index){
|
||||||
|
var input = $(this),
|
||||||
|
tagName = input.prop('tagName').toLowerCase(),
|
||||||
|
attributeType = input.attr('type');
|
||||||
|
|
||||||
|
switch (tagName) {
|
||||||
|
case "textarea":
|
||||||
|
input.val(firstAnswers.eq(index).val());
|
||||||
|
break;
|
||||||
|
case "select":
|
||||||
|
input.val(firstAnswers.eq(index).find(":selected").val()).change();
|
||||||
|
break;
|
||||||
|
case "input":
|
||||||
|
switch (attributeType) {
|
||||||
|
case "text":
|
||||||
|
case "number":
|
||||||
|
input.val(firstAnswers.eq(index).val());
|
||||||
|
break;
|
||||||
|
case "checkbox":
|
||||||
|
case "radio":
|
||||||
|
input.prop("checked", firstAnswers.eq(index).prop("checked"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
input.val(firstAnswers.eq(index).val());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
input.val(firstAnswers.eq(index).val());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var waitingDialog = {
|
var waitingDialog = {
|
||||||
show: function (message) {
|
show: function (message) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|||||||
Reference in New Issue
Block a user