Widget: Only show new tab button on connection error

This commit is contained in:
Raphael Michel
2021-08-30 15:49:22 +02:00
parent 6d08e7a8b0
commit c7b5baa185

View File

@@ -1290,7 +1290,7 @@ Vue.component('pretix-widget', {
+ '<resize-observer @notify="handleResize" />' + '<resize-observer @notify="handleResize" />'
+ shared_loading_fragment + shared_loading_fragment
+ '<div class="pretix-widget-error-message" v-if="$root.error && $root.view !== \'event\'">{{ $root.error }}</div>' + '<div class="pretix-widget-error-message" v-if="$root.error && $root.view !== \'event\'">{{ $root.error }}</div>'
+ '<div class="pretix-widget-error-action" v-if="$root.error"><a :href="$root.newTabTarget" class="pretix-widget-button" target="_blank">' + '<div class="pretix-widget-error-action" v-if="$root.error && $root.connection_error"><a :href="$root.newTabTarget" class="pretix-widget-button" target="_blank">'
+ strings['open_new_tab'] + strings['open_new_tab']
+ '</a></div>' + '</a></div>'
+ '<pretix-widget-event-form ref="formcomp" v-if="$root.view === \'event\'"></pretix-widget-event-form>' + '<pretix-widget-event-form ref="formcomp" v-if="$root.view === \'event\'"></pretix-widget-event-form>'
@@ -1417,6 +1417,7 @@ var shared_root_methods = {
return; return;
} }
} }
root.connection_error = false;
if (data.weeks !== undefined) { if (data.weeks !== undefined) {
root.weeks = data.weeks; root.weeks = data.weeks;
root.date = data.date; root.date = data.date;
@@ -1475,8 +1476,10 @@ var shared_root_methods = {
root.currency = ''; root.currency = '';
if (error.status === 429) { if (error.status === 429) {
root.error = strings['loading_error_429']; root.error = strings['loading_error_429'];
root.connection_error = true;
} else { } else {
root.error = strings['loading_error']; root.error = strings['loading_error'];
root.connection_error = true;
} }
if (root.loading > 0) { if (root.loading > 0) {
root.loading--; root.loading--;
@@ -1505,11 +1508,12 @@ var shared_root_methods = {
} }
}, },
choose_event: function (event) { choose_event: function (event) {
root.target_url = event.event_url; this.$root.target_url = event.event_url;
this.$root.error = null; this.$root.error = null;
root.subevent = event.subevent; this.$root.connection_error = false;
root.loading++; this.$root.subevent = event.subevent;
root.reload(); this.$root.loading++;
this.$root.reload();
} }
}; };
@@ -1689,6 +1693,7 @@ var create_widget = function (element) {
skip_ssl: skip_ssl, skip_ssl: skip_ssl,
disable_iframe: disable_iframe, disable_iframe: disable_iframe,
style: style, style: style,
connection_error: false,
error: null, error: null,
weeks: null, weeks: null,
days: null, days: null,