mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-15 16:58:42 +00:00
Prepare for messages and prevent double submit
This commit is contained in:
parent
d00924bcd6
commit
eba81f20c6
|
|
@ -30,5 +30,13 @@
|
||||||
|
|
||||||
jsOMS.Message.Notification.App.AppNotification.prototype.send = function(msg)
|
jsOMS.Message.Notification.App.AppNotification.prototype.send = function(msg)
|
||||||
{
|
{
|
||||||
|
const tpl = document.getElementById('app-message');
|
||||||
|
|
||||||
|
if (tpl === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = document.importNode(tpl.content, true);
|
||||||
|
tpl.parentNode.appendChild(output);
|
||||||
};
|
};
|
||||||
}(window.jsOMS = window.jsOMS || {}));
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
/**
|
||||||
|
* App notification.
|
||||||
|
*
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
(function (jsOMS) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/** @namespace jsOMS.Message.Notification.App */
|
||||||
|
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification');
|
||||||
|
|
||||||
|
jsOMS.Message.Notification.NotificationMessage = function (status, title, message)
|
||||||
|
{
|
||||||
|
this.status = 0;
|
||||||
|
this.title = title;
|
||||||
|
this.message = message;
|
||||||
|
};
|
||||||
|
}(window.jsOMS = window.jsOMS || {}));
|
||||||
|
|
@ -196,6 +196,14 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (form.getMethod() !== jsOMS.Message.Request.RequestMethod.GET
|
||||||
|
&& Math.floor(Date.now()) - form.getLastSubmit() < 500
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
form.updateLastSubmit();
|
||||||
|
|
||||||
/* Handle default submit */
|
/* Handle default submit */
|
||||||
const request = new jsOMS.Message.Request.Request(),
|
const request = new jsOMS.Message.Request.Request(),
|
||||||
self = this;
|
self = this;
|
||||||
|
|
@ -214,6 +222,14 @@
|
||||||
let tempResponse = null,
|
let tempResponse = null,
|
||||||
success = null;
|
success = null;
|
||||||
|
|
||||||
|
self.app.notifyManager.send(
|
||||||
|
new jsOMS.Message.Notification.NotificationMessage(
|
||||||
|
jsOMS.Message.Notification.NotificationLevel,
|
||||||
|
'Success',
|
||||||
|
'Successfully created object'
|
||||||
|
), jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION
|
||||||
|
);
|
||||||
|
|
||||||
/* Handle responses (can be multiple response object) */
|
/* Handle responses (can be multiple response object) */
|
||||||
for (let k = 0; k < responseLength; ++k) {
|
for (let k = 0; k < responseLength; ++k) {
|
||||||
tempResponse = response.getByIndex(k);
|
tempResponse = response.getByIndex(k);
|
||||||
|
|
@ -225,6 +241,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
|
||||||
jsOMS.Log.Logger.instance.error('Invalid form response. \n'
|
jsOMS.Log.Logger.instance.error('Invalid form response. \n'
|
||||||
+ 'URL: ' + form.getAction() + '\n'
|
+ 'URL: ' + form.getAction() + '\n'
|
||||||
+ 'Request: ' + JSON.stringify(form.getData()) + '\n'
|
+ 'Request: ' + JSON.stringify(form.getData()) + '\n'
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,9 @@
|
||||||
|
|
||||||
this.initializeMembers();
|
this.initializeMembers();
|
||||||
this.bind();
|
this.bind();
|
||||||
this.success = null;
|
|
||||||
|
this.success = null;
|
||||||
|
this.lastSubmit = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -70,6 +72,16 @@
|
||||||
return this.action;
|
return this.action;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
jsOMS.Views.FormView.prototype.getLastSubmit = function ()
|
||||||
|
{
|
||||||
|
return this.lastSubmit;
|
||||||
|
};
|
||||||
|
|
||||||
|
jsOMS.Views.FormView.prototype.updateLastSubmit = function ()
|
||||||
|
{
|
||||||
|
this.lastSubmit = Math.floor(Date.now());
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get submit elements
|
* Get submit elements
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user