From 9141f7026cd6d134afe773f49b2f829058d7cd4c Mon Sep 17 00:00:00 2001 From: StanZGenchev Date: Mon, 27 Jan 2025 00:13:57 +0200 Subject: [PATCH] Fixed form editor not setting dirty state on delete, dialogs and context menus now return focus, removed navigation from schema editor --- .../dirigible/editor-form-builder/editor.html | 6 ++++++ .../dirigible/editor-form-builder/js/editor.js | 2 ++ .../dirigible/editor-schema/modeler.html | 4 ++-- .../platform-core/ui/platform/contextmenu-hub.js | 3 +++ .../platform-core/ui/platform/dialog-hub.js | 16 +++++++++++++++- .../platform-core/ui/platform/dialogs.js | 2 +- 6 files changed, 29 insertions(+), 4 deletions(-) diff --git a/components/platform-ide/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/editor.html b/components/platform-ide/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/editor.html index 7701171dcc..c9e0dcd4af 100644 --- a/components/platform-ide/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/editor.html +++ b/components/platform-ide/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/editor.html @@ -176,6 +176,9 @@

+ + No feeds. + {{feed.name}} {{feed.url}} @@ -204,6 +207,9 @@

+ + No scripts. + {{script.name}} {{script.url}} diff --git a/components/platform-ide/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/js/editor.js b/components/platform-ide/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/js/editor.js index 03858218c7..5bb604a59b 100644 --- a/components/platform-ide/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/js/editor.js +++ b/components/platform-ide/editor-form-builder/src/main/resources/META-INF/dirigible/editor-form-builder/js/editor.js @@ -1352,6 +1352,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou $scope.deleteFeed = (index) => { $scope.formData.feeds.splice(index, 1); + $scope.fileChanged(); }; $scope.addScript = () => { @@ -1446,6 +1447,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou $scope.deleteScript = (index) => { $scope.formData.scripts.splice(index, 1); + $scope.fileChanged(); }; $scope.isFormValid = () => { diff --git a/components/platform-ide/editor-schema/src/main/resources/META-INF/dirigible/editor-schema/modeler.html b/components/platform-ide/editor-schema/src/main/resources/META-INF/dirigible/editor-schema/modeler.html index 796291997a..f88a2dbe61 100644 --- a/components/platform-ide/editor-schema/src/main/resources/META-INF/dirigible/editor-schema/modeler.html +++ b/components/platform-ide/editor-schema/src/main/resources/META-INF/dirigible/editor-schema/modeler.html @@ -47,8 +47,8 @@ - - + diff --git a/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/contextmenu-hub.js b/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/contextmenu-hub.js index 973c5fc421..5af5bd3d06 100644 --- a/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/contextmenu-hub.js +++ b/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/contextmenu-hub.js @@ -10,6 +10,8 @@ * SPDX-License-Identifier: EPL-2.0 */ class ContextMenuHub extends MessageHubApi { + #reclaimFocus = window.frameElement ? () => window.focus() : () => { }; + /** * Definition of a menu item object. * @typedef {Object} MenuItem @@ -74,6 +76,7 @@ class ContextMenuHub extends MessageHubApi { topic: callbackTopic, handler: (data) => { this.removeMessageListener(callbackListener); + this.#reclaimFocus(); resolve(data); } }); diff --git a/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/dialog-hub.js b/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/dialog-hub.js index c2f1f0683a..8537519b5a 100644 --- a/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/dialog-hub.js +++ b/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/dialog-hub.js @@ -18,6 +18,8 @@ const AlertTypes = { }; class DialogHub extends MessageHubApi { + #reclaimFocus = window.frameElement ? () => window.focus() : () => { }; + constructor(viewId) { super(); this.viewId = viewId || location.pathname; @@ -54,6 +56,7 @@ class DialogHub extends MessageHubApi { topic: callbackTopic, handler: (data) => { this.removeMessageListener(callbackListener); + this.#reclaimFocus(); resolve(data); } }); @@ -105,6 +108,7 @@ class DialogHub extends MessageHubApi { topic: callbackTopic, handler: (data) => { this.removeMessageListener(callbackListener); + this.#reclaimFocus(); resolve(data); } }); @@ -213,6 +217,7 @@ class DialogHub extends MessageHubApi { topic: callbackTopic, handler: (data) => { this.removeMessageListener(callbackListener); + this.#reclaimFocus(); resolve(data); } }); @@ -247,6 +252,7 @@ class DialogHub extends MessageHubApi { * @param {boolean} [closeButton=true] - Should the dialog have a close button in the title bar. */ // @ts-ignore showWindow({ hasHeader = true, header, title, subheader, id, path, params, width = '95%', height = '90%', maxWidth = '1280px', maxHeight = '768px', minWidth, minHeight, callbackTopic, closeButton = true } = {}) { + const closeTopic = `platform.${id || 'dialog'}.window.${new Date().valueOf()}`; this.postMessage({ topic: 'platform.dialog.window', data: { @@ -267,7 +273,15 @@ class DialogHub extends MessageHubApi { maxHeight: maxHeight, minWidth: minWidth, minHeight: minHeight, - callbackTopic: callbackTopic, + closeTopic: closeTopic, + } + }); + const closeListener = this.addMessageListener({ + topic: closeTopic, + handler: () => { + this.removeMessageListener(closeListener); + if (callbackTopic) this.triggerEvent(callbackTopic); + window.focus(); } }); } diff --git a/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/dialogs.js b/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/dialogs.js index 4ba5553cdf..d244251903 100644 --- a/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/dialogs.js +++ b/components/platform/platform-core/src/main/resources/META-INF/dirigible/platform-core/ui/platform/dialogs.js @@ -147,7 +147,7 @@ angular.module('platformDialogs', ['blimpKit', 'platformView']).directive('dialo } else scope.$apply(() => scope.dialogWindows.push(data)); }); scope.closeDialogWindow = () => { - if (scope.dialogWindows[0].callbackTopic) dialogHub.triggerEvent(scope.dialogWindows[0].callbackTopic); + dialogHub.triggerEvent(scope.dialogWindows[0].closeTopic); scope.dialogWindows.shift(); };