From 1e21efa715fbbfbd05eb920c196b0464f29f28ff Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 27 Jan 2023 22:12:09 +0100 Subject: [PATCH] phpstan, phpcs, phpunit fixes --- Message/Notification/NotificationMessage.js | 2 +- UI/Component/Form.js | 2 +- UI/GeneralUI.js | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Message/Notification/NotificationMessage.js b/Message/Notification/NotificationMessage.js index 805fdaa..9ef1291 100755 --- a/Message/Notification/NotificationMessage.js +++ b/Message/Notification/NotificationMessage.js @@ -36,7 +36,7 @@ export class NotificationMessage /** @type {boolean} isSticky */ this.isSticky = isSticky; - this.primaryButton = null; + this.primaryButton = null; this.secondaryButton = null; }; }; diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 6f06e3a..8db9bf3 100755 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -56,7 +56,7 @@ export class Form return this.forms[id]; }; - hasChanges() + hasChanges () { const length = this.forms.length; diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index 24a8e62..90663ca 100755 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -5,7 +5,6 @@ import { NotificationLevel } from '../Message/Notification/NotificationLevel.j import { NotificationMessage } from '../Message/Notification/NotificationMessage.js'; import { NotificationType } from '../Message/Notification/NotificationType.js'; - /** * UI manager for handling basic ui elements. * @@ -117,13 +116,21 @@ export class GeneralUI .then((response) => response.text()) .then((html) => { if (window.omsApp.state && window.omsApp.state.hasChanges) { - let message = new NotificationMessage(NotificationLevel.WARNING, 'Unsaved changes', 'Do you want to continue?', true, true); + const message = new NotificationMessage( + NotificationLevel.WARNING, + 'Unsaved changes', + 'Do you want to continue?', + true, + true + ); + message.primaryButton = { text: 'Yes', style: 'ok', callback: function () { document.documentElement.innerHTML = html; - window.omsApp.state.hasChanges = false; + window.omsApp.state.hasChanges = false; + this.parentNode.remove(); history.pushState({}, null, UriFactory.build(uri)); /* This is not working as it reloads the page ?! @@ -133,14 +140,15 @@ export class GeneralUI */ // @todo: fix memory leak which most likely exists because of continous binding without removing binds window.omsApp.reInit(); - }, + } }; + message.secondaryButton = { text: 'No', style: 'error', callback: function () { this.parentNode.remove(); - }, + } }; window.omsApp.notifyManager.send(message, NotificationType.APP_NOTIFICATION);