diff --git a/Message/Notification/App/AppNotification.js b/Message/Notification/App/AppNotification.js index a1a6ad8..d4a1b65 100755 --- a/Message/Notification/App/AppNotification.js +++ b/Message/Notification/App/AppNotification.js @@ -54,6 +54,12 @@ export class AppNotification return; } + switch (msg.status) { + case 0: + msg.status = NotificationLevel.OK; + break; + }; + const output = document.importNode(tpl.content, true); output.querySelector('.log-msg').classList.add('log-msg-status-' + msg.status); output.querySelector('.log-msg-content').innerHTML = msg.message; @@ -112,6 +118,6 @@ export class AppNotification if (lastElementAdded !== null && lastElementAdded.parentNode !== null) { lastElementAdded.parentNode.removeChild(lastElementAdded); } - }, 3000); + }, msg.duration); }; }; diff --git a/Message/Notification/NotificationMessage.js b/Message/Notification/NotificationMessage.js index 9ef1291..5511a42 100755 --- a/Message/Notification/NotificationMessage.js +++ b/Message/Notification/NotificationMessage.js @@ -38,5 +38,7 @@ export class NotificationMessage this.primaryButton = null; this.secondaryButton = null; + + this.duration = 3000; }; }; diff --git a/Model/Action/Message/Request.js b/Model/Action/Message/Request.js index aa1c1e2..1c0f041 100755 --- a/Model/Action/Message/Request.js +++ b/Model/Action/Message/Request.js @@ -20,7 +20,7 @@ export function requestAction (action, callback) callback(JSON.parse(xhr.responseText)); }); - if (typeof action.data !== 'undefined') { + if (typeof action.data !== 'undefined' && action.data !== null) { request.setData(action.data); } diff --git a/Model/Message/Notify.js b/Model/Message/Notify.js index 5f0c949..e1e9562 100755 --- a/Model/Message/Notify.js +++ b/Model/Message/Notify.js @@ -1,3 +1,6 @@ +import { NotificationMessage } from '../../Message/Notification/NotificationMessage.js'; +import { NotificationType } from '../../Message/Notification/NotificationType.js'; + /** * Notification message. * @@ -7,31 +10,10 @@ */ export function notifyMessage (data) { - setTimeout(function () - { - const notify = document.createElement('div'); - const h = document.createElement('h1'); - const inner = document.createElement('div'); - const title = document.createTextNode(data.title); - const content = document.createTextNode(data.msg); + const msg = new NotificationMessage(data.level, data.title, data.msg); + msg.duration = 5000; - notify.id = 'notify'; - notify.class = data.level; - h.appendChild(title); - inner.appendChild(content); - notify.appendChild(h); - notify.appendChild(inner); - document.body.appendChild(notify); - - if (data.stay <= 0) { - data.stay = 5000; - } - - if (data.stay > 0) { - setTimeout(function () - { - notify.parentElement.removeChild(notify); - }, data.stay); - } - }, parseInt(data.delay)); + window.omsApp.notifyManager.send( + msg, NotificationType.APP_NOTIFICATION + ); }; diff --git a/UI/Component/AdvancedInput.js b/UI/Component/AdvancedInput.js index 93518bd..d45e3d2 100755 --- a/UI/Component/AdvancedInput.js +++ b/UI/Component/AdvancedInput.js @@ -87,23 +87,23 @@ export class AdvancedInput * @todo Karaka/jsOMS#62 * If the data for the input element is only locally defined the filter or sort should be done by the best match. */ - if (e.keyCode === 27 || e.keyCode === 46 || e.keyCode === 8) { + if (e.code === 'Escape' || e.code === 'Delete' || e.code === 'Backspace') { // handle esc, del to go back to input field self.inputField.focus(); self.clearDataListSelection(self); - } else if (e.keyCode === 38) { + } else if (e.code === 'ArrowUp') { // handle up-click if (document.activeElement.previousElementSibling !== null) { self.clearDataListSelection(self); self.selectOption(document.activeElement.previousElementSibling); } - } else if (e.keyCode === 40) { + } else if (e.code === 'ArrowDown') { // handle down-click if (document.activeElement.nextElementSibling !== null) { self.clearDataListSelection(self); self.selectOption(document.activeElement.nextElementSibling); } - } else if (e.keyCode === 13 || e.keyCode === 9) { + } else if (e.code === 'Enter' || e.code === 'Tab') { self.clearDataListSelection(self); self.addToResultList(self, document.activeElement); } diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 8db9bf3..4449b85 100755 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -255,10 +255,15 @@ export class Form ? document.querySelector(uiContainerName) : formElement.querySelector(uiContainerName); - /** @var {HTMLElement} newElement New element to add */ - const newElement = uiContainer.querySelector(formElement.getAttribute('data-update-tpl')).content.cloneNode(true); - - uiContainer.appendChild(newElement.firstElementChild); + if (formElement.getAttribute('data-update-tpl')) { + /** @var {HTMLElement} newElement New element to add */ + const newElement = uiContainer.querySelector(formElement.getAttribute('data-update-tpl')).content.cloneNode(true); + uiContainer.appendChild(newElement.firstElementChild); + } else { + /** @var {HTMLElement} newElement New element to add */ + const newElement = uiContainer.querySelector(formElement.getAttribute('data-add-tpl')).content.cloneNode(true); + uiContainer.appendChild(newElement.firstElementChild); + } } else { // handle external add @@ -1055,7 +1060,7 @@ export class Form ); } } catch (e) { - window.omsApp.logger.log(e); + Logger.instance.log(e); Logger.instance.error('Invalid form response. \n' + 'URL: ' + form.getAction() + '\n' diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index 90663ca..5eaa3e7 100755 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -196,12 +196,14 @@ export class GeneralUI const length = e.length; for (let i = 0; i < length; ++i) { - if (e[i].contentWindow.document.body !== null) { - e[i].height = e[i].contentWindow.document.body.scrollHeight + 25; - } + e[i].src = UriFactory.build(e[i].src); e[i].addEventListener('load', function () { - this.height = this.contentWindow.document.body.scrollHeight + 25; + const spinner = this.parentElement.getElementsByClassName('ispinner'); + + if (spinner.length > 0) { + spinner[0].style.display = 'none'; + } }); } }; diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js index 2ea7d9c..8425143 100755 --- a/Uri/UriFactory.js +++ b/Uri/UriFactory.js @@ -215,14 +215,14 @@ export class UriFactory } let parsed = uri.replace(new RegExp('\{[\/#\?%@\.\$\!][a-zA-Z0-9_\\-#\.]*\}', 'g'), function (match) { - match = match.substr(1, match.length - 2); + match = match.substring(1, match.length - 1); if (toMatch !== null && Object.prototype.hasOwnProperty.call(toMatch, match)) { return toMatch[match]; } else if (typeof UriFactory.uri[match] !== 'undefined') { return UriFactory.uri[match]; } else if (match.indexOf('!') === 0) { - const e = document.querySelector(match.substr(1)); + const e = document.querySelector(match.substring(1)); if (!e) { return ''; @@ -241,11 +241,12 @@ export class UriFactory return value; } else if (match.indexOf('?') === 0) { - return HttpUri.getUriQueryParameter(current.query, match.substr(1)); + return HttpUri.getUriQueryParameter(current.query, match.substring(1)); } else if (match === '#') { return current.fragment; } else if (match.indexOf('#') === 0) { - const e = document.getElementById(match.substr(1)); + const e = document.getElementById(match.substring(1)); + if (e) { if (e.tagName.toLowerCase() !== 'form') { return e.value; diff --git a/Views/FormView.js b/Views/FormView.js index 9ee0927..fd41246 100755 --- a/Views/FormView.js +++ b/Views/FormView.js @@ -630,14 +630,18 @@ export class FormView try { for (let i = 0; i < length; ++i) { + if (!elements[i].required && elements[i].value === '') { + continue; + } + if ((elements[i].required && elements[i].value === '') || (typeof elements[i].pattern !== 'undefined' && elements[i].pattern !== '' && !(new RegExp(elements[i].pattern)).test(elements[i].value)) - || (typeof elements[i].maxlength !== 'undefined' && elements[i].maxlength !== '' && elements[i].value.length > elements[i].maxlength) - || (typeof elements[i].minlength !== 'undefined' && elements[i].minlength !== '' && elements[i].value.length < elements[i].minlength) - || (typeof elements[i].max !== 'undefined' && elements[i].max !== '' && elements[i].value > elements[i].max) - || (typeof elements[i].min !== 'undefined' && elements[i].min !== '' && elements[i].value < elements[i].min) + || (typeof elements[i].maxlength !== 'undefined' && elements[i].maxlength !== '' && elements[i].value.length > elements[i].maxlength) + || (typeof elements[i].minlength !== 'undefined' && elements[i].minlength !== '' && elements[i].value.length < elements[i].minlength) + || (typeof elements[i].max !== 'undefined' && elements[i].max !== '' && elements[i].value > elements[i].max) + || (typeof elements[i].min !== 'undefined' && elements[i].min !== '' && elements[i].value < elements[i].min) ) { return false; }