mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 10:49:00 +02:00
Fixed error popup behavior, when turbo could not find a matching turbo-fram in the response.
This commit is contained in:
parent
be5663c468
commit
9188331c1e
2 changed files with 11 additions and 7 deletions
|
@ -28,7 +28,9 @@ class ErrorHandlerHelper {
|
||||||
console.log('Error Handler registered');
|
console.log('Error Handler registered');
|
||||||
|
|
||||||
const content = document.getElementById('content');
|
const content = document.getElementById('content');
|
||||||
content.addEventListener('turbo:before-fetch-response', (event) => this.handleError(event));
|
//content.addEventListener('turbo:before-fetch-response', (event) => this.handleError(event));
|
||||||
|
content.addEventListener('turbo:fetch-request-error', (event) => this.handleError(event));
|
||||||
|
content.addEventListener('turbo:frame-missing', (event) => this.handleError(event));
|
||||||
|
|
||||||
$(document).ajaxError(this.handleJqueryErrror.bind(this));
|
$(document).ajaxError(this.handleJqueryErrror.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -87,8 +89,10 @@ class ErrorHandlerHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleError(event) {
|
handleError(event) {
|
||||||
const fetchResponse = event.detail.fetchResponse;
|
//Prevent default error handling
|
||||||
const response = fetchResponse.response;
|
event.preventDefault();
|
||||||
|
|
||||||
|
const response = event.detail.response;
|
||||||
|
|
||||||
//Ignore aborted requests.
|
//Ignore aborted requests.
|
||||||
if (response.statusText === 'abort' || response.status == 0) {
|
if (response.statusText === 'abort' || response.status == 0) {
|
||||||
|
@ -100,11 +104,11 @@ class ErrorHandlerHelper {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fetchResponse.failed) {
|
if(!response.ok) {
|
||||||
response.text().then(responseHTML => {
|
response.text().then(responseHTML => {
|
||||||
this._showAlert(response.statusText, response.status, fetchResponse.location.toString(), responseHTML);
|
this._showAlert(response.statusText, response.status, response.url, responseHTML);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this._showAlert(response.statusText, response.status, fetchResponse.location.toString(), '<pre>' + err + '</pre>');
|
this._showAlert(response.statusText, response.status, response.url, '<pre>' + err + '</pre>');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@
|
||||||
<hr>
|
<hr>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{% trans %}export_all.label{% endtrans %}</legend>
|
<legend>{% trans %}export_all.label{% endtrans %}</legend>
|
||||||
{% include 'admin/_export_form.html.twig' with {'path' : path('attachment_type_export_all')} %}
|
{% include 'admin/_export_form.html.twig' with {'path' : path(route_base ~ '_export_all')} %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue