mirror of
https://github.com/pretix/pretix.git
synced 2026-03-01 10:32:27 +00:00
Compare commits
1 Commits
datasync-l
...
answer-opt
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6db9b1711b |
@@ -118,6 +118,10 @@
|
|||||||
<button type="button" class="btn btn-default" data-formset-add>
|
<button type="button" class="btn btn-default" data-formset-add>
|
||||||
<i class="fa fa-plus"></i> {% trans "Add a new option" %}</button>
|
<i class="fa fa-plus"></i> {% trans "Add a new option" %}</button>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
{% trans "or add options from a csv file" %}
|
||||||
|
<input type="file" id="add-options-csv" accept=".csv" aria-label="{% trans "csv file with answer options" %}">
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
@@ -119,6 +119,25 @@ var form_handlers = function (el) {
|
|||||||
form_handlers($(event.target));
|
form_handlers($(event.target));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
el.find("#add-options-csv").on("change", function(event) {
|
||||||
|
var formset = $(this).closest('.formset');
|
||||||
|
var addOptionButton = formset.find("button[data-formset-add]");
|
||||||
|
for (const file of event.target.files) {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.addEventListener('load', (event) => {
|
||||||
|
event.target.result.split(/\r?\n/).forEach(function(line) {
|
||||||
|
if (!line) return;
|
||||||
|
var values = line.split(/[;,\t]/);
|
||||||
|
addOptionButton.trigger("click");
|
||||||
|
formset.find("[data-formset-body]>*:last-child").find("[type=text], textarea").each(function(i) {
|
||||||
|
if (values[i]) this.value = values[i];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
reader.readAsText(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Vouchers
|
// Vouchers
|
||||||
el.find("#voucher-bulk-codes-generate").click(function () {
|
el.find("#voucher-bulk-codes-generate").click(function () {
|
||||||
var num = $("#voucher-bulk-codes-num").val();
|
var num = $("#voucher-bulk-codes-num").val();
|
||||||
|
|||||||
Reference in New Issue
Block a user