Draft form feedback log

This commit is contained in:
Dennis Eichhorn 2018-02-14 18:42:42 +01:00
parent eba81f20c6
commit b95e3c86f8
4 changed files with 51 additions and 8 deletions

View File

@ -37,6 +37,15 @@
}
let output = document.importNode(tpl.content, true);
output.querySelector('.log-msg').classList.add('log-msg-status-' + msg.status);
output.querySelector('.log-msg-title').innerHTML = msg.title;
output.querySelector('.log-msg-content').innerHTML = msg.message;
tpl.parentNode.appendChild(output);
setTimeout(function ()
{
document.getElementsByClassName('log-msg')[0].remove();
}, 3000);
};
}(window.jsOMS = window.jsOMS || {}));

View File

@ -0,0 +1,19 @@
/**
* Notification data enum.
*
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @since 1.0.0
*/
(function (jsOMS) {
"use strict";
/** @namespace jsOMS.Message.Notification */
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification');
jsOMS.Message.Notification.NotificationLevel = Object.freeze({
OK: 'ok',
ERROR: 'error'
});
}(window.jsOMS = window.jsOMS || {}));

View File

@ -14,7 +14,7 @@
jsOMS.Message.Notification.NotificationMessage = function (status, title, message)
{
this.status = 0;
this.status = status;
this.title = title;
this.message = message;
};

View File

@ -222,13 +222,17 @@
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
);
if (typeof document.getElementById(form.getId()).dataset.msg !== 'undefined') {
let msg = JSON.parse(document.getElementById(form.getId()).dataset.msg);
self.app.notifyManager.send(
new jsOMS.Message.Notification.NotificationMessage(
jsOMS.Message.Notification.NotificationLevel.OK,
msg.title,
msg.message
), jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION
);
}
/* Handle responses (can be multiple response object) */
for (let k = 0; k < responseLength; ++k) {
@ -251,6 +255,17 @@
}
});
request.setResultCallback(0, function (xhr)
{
self.app.notifyManager.send(
new jsOMS.Message.Notification.NotificationMessage(
jsOMS.Message.Notification.NotificationLevel.ERROR,
'Failure',
'Some failure happend'
), jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION
);
});
request.send();
};