change from fa-times to close and add omsApp.state

This commit is contained in:
Dennis Eichhorn 2023-01-26 21:48:03 +01:00
parent 25db82cdf9
commit 3689d94a97
4 changed files with 19 additions and 7 deletions

View File

@ -126,7 +126,7 @@ export class AdvancedInput
observer.observe(this.tagElement, { childList: true, attributes: false, subtree: false });
eventManager.attach(this.id + '-tags-childList', function (data) {
const removes = data.target.querySelectorAll('.fa-times');
const removes = data.target.querySelectorAll('.close');
const removesLength = removes === null ? 0 : removes.length;
if (removesLength < 1) {

View File

@ -152,7 +152,9 @@ export class Form
if (!this.forms[id].isOnChange()) {
toBind[i].addEventListener('change', function (evnt) {
window.omsApp.state.hasChanges = true;
if (window.omsApp.state) {
window.omsApp.state.hasChanges = true;
}
});
}
}
@ -173,7 +175,9 @@ export class Form
onChangeContainer.addEventListener('change', function (event)
{
jsOMS.preventAll(event);
window.omsApp.state.hasChanges = true;
if (window.omsApp.state) {
window.omsApp.state.hasChanges = true;
}
const target = event.target.tagName.toLowerCase();
@ -1073,7 +1077,10 @@ export class Form
);
});
window.omsApp.state.hasChanges = false;
if (window.omsApp.state) {
window.omsApp.state.hasChanges = false;
}
request.send();
if (form.getFinally() !== null) {

View File

@ -56,7 +56,7 @@ export class Input
const type = input.type;
const removeContentButton = input.parentNode.querySelector('.fa-times');
const removeContentButton = input.parentNode.querySelector('.close');
if (removeContentButton !== null
&& type !== 'submit' && type !== 'button') {
removeContentButton.addEventListener('click', function () {

View File

@ -108,6 +108,7 @@ export class GeneralUI
if (this.getAttribute('target') === '_blank'
|| this.getAttribute(['data-target']) === '_blank'
|| event.button === 1
|| uri.startsWith('https://')
) {
window.open(UriFactory.build(uri), '_blank');
} else {
@ -115,7 +116,7 @@ export class GeneralUI
fetch(UriFactory.build(uri))
.then((response) => response.text())
.then((html) => {
if (window.omsApp.state.hasChanges) {
if (window.omsApp.state && window.omsApp.state.hasChanges) {
let message = new NotificationMessage(NotificationLevel.WARNING, 'Unsaved changes', 'Do you want to continue?', true, true);
message.primaryButton = {
text: 'Yes',
@ -145,7 +146,11 @@ export class GeneralUI
window.omsApp.notifyManager.send(message, NotificationType.APP_NOTIFICATION);
} else {
document.documentElement.innerHTML = html;
window.omsApp.state.hasChanges = false;
if (window.omsApp.state) {
window.omsApp.state.hasChanges = false;
}
this.parentNode.remove();
history.pushState({}, null, UriFactory.build(uri));
/* This is not working as it reloads the page ?!