mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Refactor widget redeeming voucher form (#4890)
This commit is contained in:
committed by
GitHub
parent
d0d17a1d0a
commit
3eff74bf4c
@@ -765,41 +765,11 @@ var shared_methods = {
|
|||||||
redeem: function (event) {
|
redeem: function (event) {
|
||||||
if (this.$root.useIframe) {
|
if (this.$root.useIframe) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else {
|
this.voucher_open(this.voucher);
|
||||||
if (this.$root.additionalURLParams) {
|
|
||||||
var params = new URLSearchParams(this.$root.additionalURLParams);
|
|
||||||
for (var [key, value] of params.entries()) {
|
|
||||||
if (!event.target.form.elements[key]) {
|
|
||||||
var input = document.createElement("input");
|
|
||||||
input.type = "hidden";
|
|
||||||
input.name = key;
|
|
||||||
input.value = value;
|
|
||||||
event.target.form.appendChild(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var redirect_url = this.$root.voucherFormTarget + '&voucher=' + encodeURIComponent(this.voucher) + '&subevent=' + this.$root.subevent;
|
|
||||||
if (this.$root.widget_data) {
|
|
||||||
redirect_url += '&widget_data=' + encodeURIComponent(this.$root.widget_data_json);
|
|
||||||
}
|
|
||||||
if (this.$root.additionalURLParams) {
|
|
||||||
redirect_url += '&' + this.$root.additionalURLParams;
|
|
||||||
}
|
|
||||||
redirect_url += this.$root.consent_parameter;
|
|
||||||
this.$root.overlay.frame_src = redirect_url;
|
|
||||||
},
|
},
|
||||||
voucher_open: function (voucher) {
|
voucher_open: function (voucher) {
|
||||||
var redirect_url;
|
var redirect_url = this.$root.voucherFormTarget + '&voucher=' + encodeURIComponent(voucher);
|
||||||
redirect_url = this.$root.voucherFormTarget + '&voucher=' + encodeURIComponent(voucher);
|
|
||||||
if (this.$root.widget_data) {
|
|
||||||
redirect_url += '&widget_data=' + encodeURIComponent(this.$root.widget_data_json);
|
|
||||||
}
|
|
||||||
if (this.$root.additionalURLParams) {
|
|
||||||
redirect_url += '&' + this.$root.additionalURLParams;
|
|
||||||
}
|
|
||||||
redirect_url += this.$root.consent_parameter;
|
|
||||||
if (this.$root.useIframe) {
|
if (this.$root.useIframe) {
|
||||||
this.$root.overlay.frame_src = redirect_url;
|
this.$root.overlay.frame_src = redirect_url;
|
||||||
} else {
|
} else {
|
||||||
@@ -1075,10 +1045,7 @@ Vue.component('pretix-widget-event-form', {
|
|||||||
+ '<div class="pretix-widget-voucher-input-wrap">'
|
+ '<div class="pretix-widget-voucher-input-wrap">'
|
||||||
+ '<input class="pretix-widget-voucher-input" ref="voucherinput" type="text" v-model="$parent.voucher" name="voucher" placeholder="'+strings.voucher_code+'">'
|
+ '<input class="pretix-widget-voucher-input" ref="voucherinput" type="text" v-model="$parent.voucher" name="voucher" placeholder="'+strings.voucher_code+'">'
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
+ '<input type="hidden" name="subevent" :value="$root.subevent" />'
|
+ '<input type="hidden" v-for="p in hiddenParams" :name="p[0]" :value="p[1]" />'
|
||||||
+ '<input type="hidden" name="widget_data" :value="$root.widget_data_json" />'
|
|
||||||
+ '<input v-if="$root.consent_parameter_value" type="hidden" name="consent" :value="$root.consent_parameter_value" />'
|
|
||||||
+ '<input type="hidden" name="locale" value="' + lang + '" />'
|
|
||||||
+ '<div class="pretix-widget-voucher-button-wrap">'
|
+ '<div class="pretix-widget-voucher-button-wrap">'
|
||||||
+ '<button @click="$parent.redeem">' + strings.redeem + '</button>'
|
+ '<button @click="$parent.redeem">' + strings.redeem + '</button>'
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
@@ -1136,7 +1103,13 @@ Vue.component('pretix-widget-event-form', {
|
|||||||
} else {
|
} else {
|
||||||
return strings.buy;
|
return strings.buy;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
hiddenParams: function () {
|
||||||
|
var params = new URL(this.$root.voucherFormTarget).searchParams;
|
||||||
|
params.delete("iframe");
|
||||||
|
params.delete("take_cart_id");
|
||||||
|
return [...params.entries()];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
focus_voucher_field: function() {
|
focus_voucher_field: function() {
|
||||||
@@ -1973,6 +1946,9 @@ var shared_root_computed = {
|
|||||||
if (this.subevent) {
|
if (this.subevent) {
|
||||||
form_target += "&subevent=" + this.subevent;
|
form_target += "&subevent=" + this.subevent;
|
||||||
}
|
}
|
||||||
|
if (this.$root.widget_data) {
|
||||||
|
form_target += '&widget_data=' + encodeURIComponent(this.$root.widget_data_json);
|
||||||
|
}
|
||||||
form_target += this.$root.consent_parameter;
|
form_target += this.$root.consent_parameter;
|
||||||
if (this.$root.additionalURLParams) {
|
if (this.$root.additionalURLParams) {
|
||||||
form_target += '&' + this.$root.additionalURLParams;
|
form_target += '&' + this.$root.additionalURLParams;
|
||||||
|
|||||||
Reference in New Issue
Block a user