diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index 273f2ec527..a686b5c512 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -28,9 +28,8 @@ padding: 20px; padding-bottom: 35px; background-color: rgba(50, 50, 50, 0.75); - width: 100%; - max-width: 330px; + max-width: 550px; margin: auto; } diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index b4f7114448..5d393a085a 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -202,6 +202,9 @@ function inventreeDocReady() { location.href = url; }); + + // Display any cached alert messages + showCachedAlerts(); } function isFileTransfer(transfer) { diff --git a/InvenTree/InvenTree/static/script/inventree/notification.js b/InvenTree/InvenTree/static/script/inventree/notification.js index f62226985e..dc346e6f92 100644 --- a/InvenTree/InvenTree/static/script/inventree/notification.js +++ b/InvenTree/InvenTree/static/script/inventree/notification.js @@ -1,12 +1,43 @@ +/* + * Add a cached alert message to sesion storage + */ +function addCachedAlert(message, style) { -function showAlertOrCache(alertType, message, cache, timeout=5000) { - if (cache) { - sessionStorage.setItem(`inventree-${alertType}`, message); + var alerts = sessionStorage.getItem('inventree-alerts'); + + if (alerts) { + alerts = JSON.parse(alerts); + } else { + alerts = []; } - else { - showMessage('#' + alertType, message, timeout); - sessionStorage.removeItem(`inventree-${alertType}`); + alerts.push({ + message: message, + style: style + }); + + sessionStorage.setItem('inventree-alerts', JSON.stringify(alerts)); +} + + +/* + * Remove all cached alert messages + */ +function clearCachedAlerts() { + sessionStorage.removeItem('inventree-alerts'); +} + + +/* + * Display an alert, or cache to display on reload + */ +function showAlertOrCache(message, style, cache=false) { + + if (cache) { + addCachedAlert(message, style); + } else { + + showMessage(message, {style: style}); } } @@ -16,25 +47,13 @@ function showAlertOrCache(alertType, message, cache, timeout=5000) { */ function showCachedAlerts() { - var styles = [ - 'primary', - 'secondary', - 'success', - 'info', - 'warning', - 'danger', - ]; + var alerts = JSON.parse(sessionStorage.getItem('inventree-alerts')) || []; - styles.forEach(function(style) { - - var msg = sessionStorage.getItem(`inventree-alert-${style}`); - - if (msg) { - showMessage(msg, { - style: style, - }); - } + alerts.forEach(function(alert) { + showMessage(alert.message, {style: alert.style}); }); + + clearCachedAlerts(); } diff --git a/InvenTree/templates/account/base.html b/InvenTree/templates/account/base.html index 4dded57eba..fa2a34f79d 100644 --- a/InvenTree/templates/account/base.html +++ b/InvenTree/templates/account/base.html @@ -10,6 +10,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -46,9 +66,10 @@