mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds ability to display "success" messages inside a persistant modal dialog
This commit is contained in:
parent
9f5618a51f
commit
7170e16ae7
@ -37,7 +37,6 @@ function showAlertOrCache(message, cache, options={}) {
|
||||
if (cache) {
|
||||
addCachedAlert(message, options);
|
||||
} else {
|
||||
|
||||
showMessage(message, options);
|
||||
}
|
||||
}
|
||||
@ -82,6 +81,8 @@ function showMessage(message, options={}) {
|
||||
|
||||
var timeout = options.timeout || 5000;
|
||||
|
||||
var target = options.target || $('#alerts');
|
||||
|
||||
var details = '';
|
||||
|
||||
if (options.details) {
|
||||
@ -111,7 +112,7 @@ function showMessage(message, options={}) {
|
||||
</div>
|
||||
`;
|
||||
|
||||
$('#alerts').append(html);
|
||||
target.append(html);
|
||||
|
||||
// Remove the alert automatically after a specified period of time
|
||||
$(`#alert-${id}`).delay(timeout).slideUp(200, function() {
|
||||
|
@ -942,9 +942,22 @@ function handleFormSuccess(response, options) {
|
||||
cache = false;
|
||||
}
|
||||
|
||||
var msg_target = null;
|
||||
|
||||
if (options.modal && options.reloadFormAfterSuccess) {
|
||||
// If the modal is persistant, the target for any messages should be the modal!
|
||||
msg_target = $(options.modal).find('#pre-form-content');
|
||||
}
|
||||
|
||||
// Display any messages
|
||||
if (response && (response.success || options.successMessage)) {
|
||||
showAlertOrCache(response.success || options.successMessage, cache, {style: 'success'});
|
||||
showAlertOrCache(
|
||||
response.success || options.successMessage,
|
||||
cache,
|
||||
{
|
||||
style: 'success',
|
||||
target: msg_target,
|
||||
});
|
||||
}
|
||||
|
||||
if (response && response.info) {
|
||||
|
Loading…
Reference in New Issue
Block a user