Added a mechanism to disable and enable the navigation when waiting for a response from a plugin
Change-Id: I11cba9a7fc2a32e3d3d32fb9cf9f0590900fe73b
Issue-ID: SDC-1277
Signed-off-by: Idan Amit <ia096e@intl.att.com>
}
}
+ public isWaitingForEvent(eventName: string) : boolean {
+ return Array.from(this.eventsToWait.values()).some((eventsList: Array<string>) =>
+ eventsList.indexOf(eventName) !== -1
+ );
+ }
+
protected onMessage(event: any) {
if (this.subscribers.has(event.data.originId)) {
this.eventsCallbacks.forEach((callback: Function) => {
width: 100%;
height: 100%;
border: none;
+ top: 3px;
+ left: 2px;
+ position: relative;
+ z-index: 1030
}
}
-import {Component, Inject, Input, Output, OnInit, EventEmitter, ViewChild, ElementRef} from "@angular/core";
+import {Component, Inject, Input, Output, OnInit, EventEmitter} from "@angular/core";
import {URLSearchParams} from '@angular/http';
import {Plugin} from "app/models";
import {EventBusService} from "../../../services/event-bus.service";
this.eventBusService.notify("WINDOW_OUT").subscribe(() => {
this.isClosed = true;
-
this.eventBusService.unregister(this.plugin.pluginId);
this.$state.go(toState.name, toParams);
this.handlePluginRegistration(event.data, event);
}
}
+
+ public disableNavigation(isDisable: boolean) {
+ if (isDisable) {
+ let disableDiv = document.createElement('div');
+ disableDiv.style.cssText = "position: fixed;\n" +
+ "z-index: 1029;\n" +
+ "background: rgba(0,0,0,0.5);\n" +
+ "width: 100%;\n" +
+ "height: 100%;\n" +
+ "top: 0;\n" +
+ "left: 0;";
+ disableDiv.setAttribute("class", "disable-navigation-div");
+ document.body.appendChild(disableDiv);
+ }
+ else {
+ document.getElementsByClassName("disable-navigation-div")[0].remove();
+ }
+ }
+
+ public notify(eventType:string, eventData?:any, disableOnWaiting:boolean=true) {
+ let doDisable = false;
+
+ if (disableOnWaiting) {
+ doDisable = this.isWaitingForEvent(eventType);
+
+ if (doDisable) {
+ this.disableNavigation(true);
+ }
+ }
+
+ const origSubscribe = super.notify(eventType, eventData).subscribe;
+
+ return {
+ subscribe: function (callbackFn) {
+ origSubscribe(() => {
+ if (doDisable) {
+ this.disableNavigation(false);
+ }
+
+ callbackFn();
+ });
+ }.bind(this)
+ };
+ }
}
return plugin.pluginDisplayOptions["context"] &&
plugin.pluginDisplayOptions["context"].displayRoles.includes(userRole) &&
plugin.pluginDisplayOptions["context"].displayContext.indexOf(contextType) !== -1
- }
+ };
}
return versionObj.versionId === this.$scope.component.uniqueId;
});
}
- this.$scope.isLoading = true;
let eventData = {
uuid: this.$scope.component.uuid,
};
this.eventBusService.notify("VERSION_CHANGED", eventData).subscribe(() => {
+ this.$scope.isLoading = true;
+
this.$state.go(this.$state.current.name, {
id: selectedId,
type: this.$scope.componentType.toLowerCase(),
switch (url) {
case 'lifecycleState/CHECKOUT':
- this.eventBusService.notify("CHECK_OUT", eventData).subscribe(() => {
+ this.eventBusService.notify("CHECK_OUT", eventData, false).subscribe(() => {
// only checkOut get the full component from server
// this.$scope.component = component;
// Work around to change the csar version
});
break;
case 'lifecycleState/UNDOCHECKOUT':
- this.eventBusService.notify("UNDO_CHECK_OUT", eventData).subscribe(() => {
+ this.eventBusService.notify("UNDO_CHECK_OUT", eventData, false).subscribe(() => {
defaultActionAfterChangeLifecycleState();
this.Notification.success({
message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"),
padding: 0px 0px 0px 0px;
background-color: @main_color_p;
- z-index: 1;
+ //z-index: 1;
.sdc-workspace-top-bar {
height: @action_nav_height;