Developed disable navigation mechanism 05/46605/2
authorIdan Amit <ia096e@intl.att.com>
Tue, 8 May 2018 13:06:34 +0000 (16:06 +0300)
committerMichael Lando <ml636r@att.com>
Tue, 8 May 2018 13:40:11 +0000 (13:40 +0000)
Added a list for events to not fire an WINDOW_OUT event after sdc notifies about them
Small fix to Plugins loader

Change-Id: Ia31ebf4095b94a5ca602c4f502df4fcc32368b0b
Issue-ID: SDC-1277
Signed-off-by: Idan Amit <ia096e@intl.att.com>
catalog-ui/src/app/models/base-pubsub.ts
catalog-ui/src/app/ng2/components/ui/plugin/plugin-frame.component.ts
catalog-ui/src/app/ng2/services/event-bus.service.ts
catalog-ui/src/app/view-models/workspace/tabs/plugins/plugins-context-view.html

index c4b109f..41e8039 100644 (file)
@@ -6,12 +6,14 @@ export class BasePubSub {
     eventsCallbacks: Array<Function>;
     clientId: string;
     eventsToWait: Map<string, Array<string>>;
+    lastEventNotified: string;
 
     constructor(pluginId: string) {
         this.subscribers = new Map<string, ISubscriber>();
         this.eventsCallbacks = [];
         this.eventsToWait = new Map<string, Array<string>>();
         this.clientId = pluginId;
+        this.lastEventNotified = "";
         this.onMessage = this.onMessage.bind(this);
 
         window.addEventListener("message", this.onMessage);
@@ -54,9 +56,10 @@ export class BasePubSub {
 
         this.subscribers.forEach( (subscriber: ISubscriber, subscriberId: string) => {
             subscriber.window.postMessage(eventObj, subscriber.locationUrl);
-
         });
 
+        this.lastEventNotified = eventType;
+
         return {
             subscribe: function(callbackFn) {
 
index 83d302b..cd92cca 100644 (file)
@@ -58,15 +58,20 @@ export class PluginFrameComponent implements OnInit {
         // before moving to a new state
         this.$scope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
             if ((fromState.name !== toState.name) || (fromState.name === toState.name) && (toParams.path !== fromParams.path)) {
-                if (!this.isClosed) {
-                    event.preventDefault();
+                if(this.eventBusService.NoWindowOutEvents.indexOf(this.eventBusService.lastEventNotified) == -1) {
+                    if (!this.isClosed) {
+                        event.preventDefault();
 
-                    this.eventBusService.notify("WINDOW_OUT").subscribe(() => {
-                        this.isClosed = true;
-                        this.eventBusService.unregister(this.plugin.pluginId);
+                        this.eventBusService.notify("WINDOW_OUT").subscribe(() => {
+                            this.isClosed = true;
+                            this.eventBusService.unregister(this.plugin.pluginId);
 
-                        this.$state.go(toState.name, toParams);
-                    });
+                            this.$state.go(toState.name, toParams);
+                        });
+                    }
+                }
+                else {
+                    this.eventBusService.unregister(this.plugin.pluginId);
                 }
             }
         });
index cff18e1..10990e2 100644 (file)
@@ -4,8 +4,11 @@ import {BasePubSub, IPubSubEvent} from "../../models/base-pubsub";
 @Injectable()
 export class EventBusService extends BasePubSub {
 
+    NoWindowOutEvents: Array<string>;
+
     constructor() {
         super("sdc-hub");
+        this.NoWindowOutEvents = ["CHECK_IN", "SUBMIT_FOR_TESTING", "UNDO_CHECK_OUT"];
     }
 
     protected handlePluginRegistration(eventData: IPubSubEvent, event: any) {
index d70717a..3746bc0 100644 (file)
@@ -1,4 +1,4 @@
-<loader display="isLoading"></loader>
+<loader display="isLoading && plugin.isOnline" ></loader>
 <div class="workspace-plugins">
     <plugin-frame (on-loading-done)="onLoadingDone(plugin)" [plugin]="plugin" [query-params]="queryParams"></plugin-frame>
 </div>