many small fixes

This commit is contained in:
Dennis Eichhorn 2023-02-10 18:20:57 +01:00
parent 1e21efa715
commit 321d6c5172
9 changed files with 51 additions and 49 deletions

View File

@ -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);
};
};

View File

@ -38,5 +38,7 @@ export class NotificationMessage
this.primaryButton = null;
this.secondaryButton = null;
this.duration = 3000;
};
};

View File

@ -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);
}

View File

@ -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
);
};

View File

@ -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);
}

View File

@ -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'

View File

@ -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';
}
});
}
};

View File

@ -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;

View File

@ -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;
}