Changed retry behavior
This commit is contained in:
@@ -611,7 +611,7 @@ return [
|
||||
'action_source' => 'Action Source',
|
||||
'search_tip' => 'Searches return a partial match by default. For more specific results, you can use <code>not:value</code> to exclude, <code>is:value</code> for an exact match, <code>is:null</code> for empty values, and <code>is:not_null</code> for non-empty. (In these examples, <code>value</code> is the text you are searching for.)',
|
||||
'search_load_error_short' => 'Could not load records.',
|
||||
'search_load_error_help' => 'An API error has occurred. Check your server logs and confirm migrations are up to date.',
|
||||
'search_load_error_help' => 'An API error has occurred. Check your server logs for errors and confirm migrations are up to date.',
|
||||
'or' => 'or',
|
||||
'url' => 'URL',
|
||||
'phone' => 'Phone',
|
||||
|
||||
@@ -497,8 +497,7 @@
|
||||
return default_value;
|
||||
}
|
||||
|
||||
var renderBootstrapTableLoadErrorState = function ($table, attempt) {
|
||||
attempt = attempt || 0;
|
||||
var renderBootstrapTableLoadErrorState = function ($table) {
|
||||
var $wrapper = $table.closest('.bootstrap-table');
|
||||
|
||||
if (!$wrapper.length) {
|
||||
@@ -517,20 +516,47 @@
|
||||
var $targets = $wrapper.find('.fixed-table-body .no-records-found td, .fixed-table-body .fixed-table-loading');
|
||||
|
||||
if (!$targets.length) {
|
||||
// On initial load errors, bootstrap-table may insert the no-records row
|
||||
// after onLoadError has fired. Retry briefly so first render also shows
|
||||
// the error state instead of the default "no matching records" text.
|
||||
// Initial table bootstrap can lag behind onLoadError by quite a bit depending
|
||||
// on browser/layout timing. Keep retrying briefly so first-page errors are caught.
|
||||
if (attempt < 80) {
|
||||
setTimeout(function () {
|
||||
renderBootstrapTableLoadErrorState($table, attempt + 1);
|
||||
}, 50);
|
||||
// On initial load errors, bootstrap-table can insert the no-records row
|
||||
// after the load-error callback fires. Observe DOM changes briefly and
|
||||
// render the error state once the row appears, then disconnect.
|
||||
var existingObserver = $table.data('bs-table-load-error-observer');
|
||||
if (existingObserver) {
|
||||
return;
|
||||
}
|
||||
|
||||
var wrapperNode = $wrapper.get(0);
|
||||
if (!wrapperNode || typeof MutationObserver === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
var observer = new MutationObserver(function () {
|
||||
if ($table.data('bs-table-load-error') !== true) {
|
||||
observer.disconnect();
|
||||
$table.removeData('bs-table-load-error-observer');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var $newTargets = $wrapper.find('.fixed-table-body .no-records-found td, .fixed-table-body .fixed-table-loading');
|
||||
if ($newTargets.length) {
|
||||
observer.disconnect();
|
||||
$table.removeData('bs-table-load-error-observer');
|
||||
renderBootstrapTableLoadErrorState($table);
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(wrapperNode, { childList: true, subtree: true });
|
||||
$table.data('bs-table-load-error-observer', observer);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var activeObserver = $table.data('bs-table-load-error-observer');
|
||||
if (activeObserver) {
|
||||
activeObserver.disconnect();
|
||||
$table.removeData('bs-table-load-error-observer');
|
||||
}
|
||||
|
||||
$targets.html(errorHtml);
|
||||
};
|
||||
|
||||
@@ -666,6 +692,11 @@
|
||||
// Clear transport/server error state so genuine empty results show normal messaging.
|
||||
$(this).data('bs-table-load-error', false);
|
||||
$(this).removeData('bs-table-load-error-status');
|
||||
var observer = $(this).data('bs-table-load-error-observer');
|
||||
if (observer) {
|
||||
observer.disconnect();
|
||||
$(this).removeData('bs-table-load-error-observer');
|
||||
}
|
||||
$('[data-tooltip="true"]').tooltip(); // Needed to attach tooltips after ajax call
|
||||
},
|
||||
onLoadError: function () {
|
||||
|
||||
Reference in New Issue
Block a user