From 0dd94695b8004b4de231753ff63ead2279a5587e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 8 Apr 2023 04:36:26 +0200 Subject: [PATCH] fix billing process --- Message/Response/Response.js | 2 +- UI/Component/Form.js | 9 +++++---- UI/GeneralUI.js | 13 +++++++++++-- Uri/HttpUri.js | 5 +++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Message/Response/Response.js b/Message/Response/Response.js index 1ceb5e4..9cd28f1 100755 --- a/Message/Response/Response.js +++ b/Message/Response/Response.js @@ -34,7 +34,7 @@ export class Response */ get (id = null) { - return id === null ? this.responses : this.responses[id]; + return id === null ? this.responses : (typeof this.responses[id] === 'undefined' ? null : this.responses[id]); }; /** diff --git a/UI/Component/Form.js b/UI/Component/Form.js index c66bd47..c7f0ac8 100755 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -1076,7 +1076,7 @@ export class Form .catch((error) => { console.warn(error); }); - } else if (typeof response.get('type') !== 'undefined') { + } else if (response.get('type') !== null) { self.app.responseManager.run(response.get('type'), response.get(), null); } else if (typeof o.status !== 'undefined' && o.status !== NotificationLevel.HIDDEN) { self.app.notifyManager.send( @@ -1098,10 +1098,11 @@ export class Form request.setResultCallback(0, function (xhr) { try { - const o = JSON.parse(xhr.response)[0]; - const response = new Response(o); + const o = JSON.parse(xhr.response)[0]; + const response = new Response(o); - if (typeof response.get('type') !== 'undefined') { + if (response.get('type') !== null) { + console.log(response.get('type')); } else if (typeof o.status !== 'undefined' && o.status !== NotificationLevel.HIDDEN) { self.app.notifyManager.send( new NotificationMessage(o.status, o.title, o.message), NotificationType.APP_NOTIFICATION diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index 0849f2f..dfd9a29 100755 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -105,15 +105,21 @@ export class GeneralUI uri = uri === null ? this.getAttribute('href') : uri; if (this.getAttribute('target') === '_blank' - || this.getAttribute(['data-target']) === '_blank' + || this.getAttribute('data-target') === '_blank' || event.button === 1 || uri.startsWith('https://') ) { window.open(UriFactory.build(uri), '_blank'); + } else if (this.getAttribute('data-redirect') !== null) { + uri = window.omsApp.request.getRootPath() + uri; + window.location.assign(uri); } else { // window.location = UriFactory.build(uri); + // @todo : consider to implement the line above again. why was it removed? + uri = window.omsApp.request.getRootPath() + uri; + fetch(UriFactory.build(uri)) - .then((response) => response.text()) + .then (response => response.text()) .then((html) => { if (window.omsApp.state && window.omsApp.state.hasChanges) { const message = new NotificationMessage( @@ -167,6 +173,9 @@ export class GeneralUI */ // @todo: fix memory leak which most likely exists because of continous binding without removing binds window.omsApp.reInit(); + + const event = new Event('DOMContentLoaded'); + window.dispatchEvent(event); } }) .catch((error) => { diff --git a/Uri/HttpUri.js b/Uri/HttpUri.js index be28c66..229b8c8 100755 --- a/Uri/HttpUri.js +++ b/Uri/HttpUri.js @@ -215,6 +215,11 @@ export class HttpUri this.set(this.uri); }; + getRootPath () + { + return this.root; + } + /** * Get Uri base *