2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 04:26:44 +00:00

Modal form improvements

This commit is contained in:
Oliver 2021-07-09 01:20:40 +10:00
parent ecf47aa69d
commit 337223b8eb
2 changed files with 22 additions and 4 deletions

View File

@ -732,11 +732,31 @@ function handleFormSuccess(response, options) {
// Close the modal // Close the modal
if (!options.preventClose) { if (!options.preventClose) {
// TODO: Actually just *delete* the modal, // Note: The modal will be deleted automatically after closing
// rather than hiding it!!
$(options.modal).modal('hide'); $(options.modal).modal('hide');
} }
// Display any required messages
// Should we show alerts immediately or cache them?
var cache = (options.follow && response.url) || options.redirect || options.reload;
// Display any messages
if (response.success) {
showAlertOrCache("alert-success", response.success, cache);
}
if (response.info) {
showAlertOrCache("alert-info", response.info, cache);
}
if (response.warning) {
showAlertOrCache("alert-warning", response.warning, cache);
}
if (response.danger) {
showAlertOrCache("alert-danger", response.danger, cache);
}
if (options.onSuccess) { if (options.onSuccess) {
// Callback function // Callback function
options.onSuccess(response, options); options.onSuccess(response, options);

View File

@ -83,8 +83,6 @@ function createNewModal(options={}) {
// Capture "enter" key input // Capture "enter" key input
$(modal_name).on('keydown', 'input', function(event) { $(modal_name).on('keydown', 'input', function(event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
event.preventDefault(); event.preventDefault();
// Simulate a click on the 'Submit' button // Simulate a click on the 'Submit' button