Skip to content

Commit

Permalink
Fixed form editor not setting dirty state on delete, dialogs and cont…
Browse files Browse the repository at this point in the history
…ext menus now return focus, removed navigation from schema editor
  • Loading branch information
StanZGenchev committed Jan 26, 2025
1 parent cefbf64 commit 9141f70
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ <h4 bk-panel-title>
</tr>
</thead>
<tbody bk-table-body>
<tr ng-if="formData.feeds.length === 0" bk-table-row>
<td bk-table-cell no-data="true">No feeds.</td>
</tr>
<tr bk-table-row hoverable="false" ng-repeat="feed in formData.feeds track by $index">
<td bk-table-cell>{{feed.name}}</td>
<td bk-table-cell>{{feed.url}}</td>
Expand Down Expand Up @@ -204,6 +207,9 @@ <h4 bk-panel-title>
</tr>
</thead>
<tbody bk-table-body>
<tr ng-if="formData.scripts.length === 0" bk-table-row>
<td bk-table-cell no-data="true">No scripts.</td>
</tr>
<tr bk-table-row hoverable="false" ng-repeat="script in formData.scripts track by $index">
<td bk-table-cell>{{script.name}}</td>
<td bk-table-cell>{{script.url}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou

$scope.deleteFeed = (index) => {
$scope.formData.feeds.splice(index, 1);
$scope.fileChanged();
};

$scope.addScript = () => {
Expand Down Expand Up @@ -1446,6 +1447,7 @@ editorView.controller('DesignerController', ($scope, $window, $document, $timeou

$scope.deleteScript = (index) => {
$scope.formData.scripts.splice(index, 1);
$scope.fileChanged();
};

$scope.isFormValid = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<bk-button state="transparent" glyph="sap-icon--paste" aria-label="Paste" title="Paste" ng-click="paste()"></bk-button>
<bk-toolbar-spacer></bk-toolbar-spacer>
<bk-button state="transparent" glyph="sap-icon--list" aria-label="Properties" title="Properties" ng-click="properties()"></bk-button>
<bk-toolbar-separator></bk-toolbar-separator>
<bk-button state="transparent" glyph="sap-icon--tree" aria-label="Navigation" title="Navigation" ng-click="navigation()"></bk-button>
<!-- <bk-toolbar-separator></bk-toolbar-separator>
<bk-button state="transparent" glyph="sap-icon--tree" aria-label="Navigation" title="Navigation" ng-click="navigation()"></bk-button> -->
<bk-toolbar-separator></bk-toolbar-separator>
<bk-button state="transparent" glyph="sap-icon--delete" aria-label="Delete" title="Delete" ng-click="delete()"></bk-button>
<bk-toolbar-separator></bk-toolbar-separator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,6 +76,7 @@ class ContextMenuHub extends MessageHubApi {
topic: callbackTopic,
handler: (data) => {
this.removeMessageListener(callbackListener);
this.#reclaimFocus();
resolve(data);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const AlertTypes = {
};

class DialogHub extends MessageHubApi {
#reclaimFocus = window.frameElement ? () => window.focus() : () => { };

constructor(viewId) {
super();
this.viewId = viewId || location.pathname;
Expand Down Expand Up @@ -54,6 +56,7 @@ class DialogHub extends MessageHubApi {
topic: callbackTopic,
handler: (data) => {
this.removeMessageListener(callbackListener);
this.#reclaimFocus();
resolve(data);
}
});
Expand Down Expand Up @@ -105,6 +108,7 @@ class DialogHub extends MessageHubApi {
topic: callbackTopic,
handler: (data) => {
this.removeMessageListener(callbackListener);
this.#reclaimFocus();
resolve(data);
}
});
Expand Down Expand Up @@ -213,6 +217,7 @@ class DialogHub extends MessageHubApi {
topic: callbackTopic,
handler: (data) => {
this.removeMessageListener(callbackListener);
this.#reclaimFocus();
resolve(data);
}
});
Expand Down Expand Up @@ -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: {
Expand All @@ -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();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand Down

0 comments on commit 9141f70

Please sign in to comment.