diff --git a/dDashboardServer/static/js/ai-suggest.js b/dDashboardServer/static/js/ai-suggest.js index 6c71310fd..554b4ba17 100644 --- a/dDashboardServer/static/js/ai-suggest.js +++ b/dDashboardServer/static/js/ai-suggest.js @@ -206,7 +206,7 @@ var prefill = { account: String(data.account_id), action: s.action, days: s.days, strike: s.strike, reason: s.action === 'note' ? clip(s.staff_explanation, 300) : s.player_reason, at: Date.now() }; try { sessionStorage.setItem(PREFILL_KEY, JSON.stringify(prefill)); } catch (e) { return toast('Could not pass the suggestion on (browser storage is off)', 'warning'); } - window.location.href = '/accounts/' + encodeURIComponent(data.account_id); + goTo('/accounts/' + encodeURIComponent(data.account_id)); } // On an account page: fill in the form a suggestion was passed to. Nothing is submitted. diff --git a/dDashboardServer/static/js/common.js b/dDashboardServer/static/js/common.js index 6efe1c9a9..48738ac9a 100644 --- a/dDashboardServer/static/js/common.js +++ b/dDashboardServer/static/js/common.js @@ -92,6 +92,21 @@ }); }; + /** + * Show this page again with what the server has now, after a change made from it: in place when nav.js is there + * (Nav.refresh), otherwise a reload. goTo(url) opens another page the same way (Nav.go, or a normal load). + */ + window.reloadInPlace = function () { + if (window.Nav && Nav.refresh) return Nav.refresh({ force: true }); + window.location.reload(); + return Promise.resolve(); + }; + window.goTo = function (url, options) { + if (window.Nav && Nav.go) return Nav.go(url, options); + if (options && options.replace) window.location.replace(url); else window.location.href = url; + return Promise.resolve(); + }; + window.toast = function (message, type) { var container = document.getElementById('toast-container'); if (!container) { diff --git a/dDashboardServer/templates/bug_report-view.jinja2 b/dDashboardServer/templates/bug_report-view.jinja2 index 656d1697d..52f9e1aee 100644 --- a/dDashboardServer/templates/bug_report-view.jinja2 +++ b/dDashboardServer/templates/bug_report-view.jinja2 @@ -61,12 +61,12 @@ if (window.Live) Live.refreshPage('bug_reports', document.getElementById('report function resolveReport() { api.action(reportUrl + '/resolve', { resolution: document.getElementById('resolution').value.trim() }) - .then(function () { location.reload(); }).catch(function () {}); + .then(function () { reloadInPlace(); }).catch(function () {}); } function deleteReport() { if (!confirm('Delete this bug report?')) return; - api.action(reportUrl + '/delete').then(function () { window.location.href = '/bug_reports'; }).catch(function () {}); + api.action(reportUrl + '/delete').then(function () { goTo('/bug_reports', { replace: true }); }).catch(function () {}); } {% endblock %} diff --git a/dDashboardServer/templates/play_key-view.jinja2 b/dDashboardServer/templates/play_key-view.jinja2 index c3c866677..298fa0c5d 100644 --- a/dDashboardServer/templates/play_key-view.jinja2 +++ b/dDashboardServer/templates/play_key-view.jinja2 @@ -75,7 +75,7 @@ function saveKey() { function deleteKey() { if (!confirm('Delete this play key? Accounts that used it keep working but lose the link to it.')) return; - api.action(keyUrl + '/delete').then(function () { window.location.href = '/play_keys'; }).catch(function () {}); + api.action(keyUrl + '/delete').then(function () { goTo('/play_keys', { replace: true }); }).catch(function () {}); } {% endblock %} diff --git a/dDashboardServer/templates/system_log.jinja2 b/dDashboardServer/templates/system_log.jinja2 index 0042a4b2b..f350cdda5 100644 --- a/dDashboardServer/templates/system_log.jinja2 +++ b/dDashboardServer/templates/system_log.jinja2 @@ -28,7 +28,7 @@