diff --git a/Message/Notification/App/AppNotification.js b/Message/Notification/App/AppNotification.js index 66b9d7a..5b6b323 100644 --- a/Message/Notification/App/AppNotification.js +++ b/Message/Notification/App/AppNotification.js @@ -30,5 +30,13 @@ 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 || {})); \ No newline at end of file diff --git a/Message/Notification/NotificationMessage.js b/Message/Notification/NotificationMessage.js index e69de29..a93ca5b 100644 --- a/Message/Notification/NotificationMessage.js +++ b/Message/Notification/NotificationMessage.js @@ -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 || {})); \ No newline at end of file diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 91fe1e5..b6f6a4f 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -196,6 +196,14 @@ return; } + if (form.getMethod() !== jsOMS.Message.Request.RequestMethod.GET + && Math.floor(Date.now()) - form.getLastSubmit() < 500 + ) { + return; + } + + form.updateLastSubmit(); + /* Handle default submit */ const request = new jsOMS.Message.Request.Request(), self = this; @@ -214,6 +222,14 @@ let tempResponse = 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) */ for (let k = 0; k < responseLength; ++k) { tempResponse = response.getByIndex(k); @@ -225,6 +241,8 @@ } } } catch (e) { + console.log(e); + jsOMS.Log.Logger.instance.error('Invalid form response. \n' + 'URL: ' + form.getAction() + '\n' + 'Request: ' + JSON.stringify(form.getData()) + '\n' diff --git a/Views/FormView.js b/Views/FormView.js index 24ef749..c082533 100644 --- a/Views/FormView.js +++ b/Views/FormView.js @@ -29,7 +29,9 @@ this.initializeMembers(); this.bind(); - this.success = null; + + this.success = null; + this.lastSubmit = 0; }; /** @@ -70,6 +72,16 @@ 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 * @@ -196,9 +208,9 @@ try { for (let i = 0; i < length; ++i) { - if ((elements[i].required && elements[i].value === '') - || (typeof elements[i].pattern !== 'undefined' - && elements[i].pattern !== '' + if ((elements[i].required && elements[i].value === '') + || (typeof elements[i].pattern !== 'undefined' + && elements[i].pattern !== '' && !(new RegExp(elements[i].pattern)).test(elements[i].value)) ) { return false;