From 3689d94a978534812f38197d9d5829fa51e87d6d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 26 Jan 2023 21:48:03 +0100 Subject: [PATCH] change from fa-times to close and add omsApp.state --- UI/Component/AdvancedInput.js | 2 +- UI/Component/Form.js | 13 ++++++++++--- UI/Component/Input.js | 2 +- UI/GeneralUI.js | 9 +++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/UI/Component/AdvancedInput.js b/UI/Component/AdvancedInput.js index 1f27242..93518bd 100755 --- a/UI/Component/AdvancedInput.js +++ b/UI/Component/AdvancedInput.js @@ -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) { diff --git a/UI/Component/Form.js b/UI/Component/Form.js index e79198d..6f06e3a 100755 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -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) { diff --git a/UI/Component/Input.js b/UI/Component/Input.js index 8135efb..babf44b 100755 --- a/UI/Component/Input.js +++ b/UI/Component/Input.js @@ -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 () { diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index b91c8e3..24a8e62 100755 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -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 ?!