12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2015, 2017
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- /**
- * This class creates EventChannelRouter object by Channel type.
- *
- * SAME_PAGE channel is supported meaning that widgets on same page will be notified.
- */
- define(['underscore', '../lib/@waca/core-client/js/core-client/ui/core/Class', '../app/EventChannelRouter'], function (_, Class, EventChannelRouter) {
- // private members
- var CHANNEL_TYPE = {
- SAME_PAGE: 1, //A channel is established with a single page
- Page2Page: 2, //For future, Channel is established between explicit two pages
- Widget2Widget: 3 //For future, Channel is established between explicit two widgets
- };
- // list event names that will go through channel
- var EVENT_NAMES = {
- SAME_PAGE: ['dw:filters'],
- Page2Page: [], //For future
- Widget2Widget: [] //For future
- };
- var EventChannelRouterHelper = null;
- EventChannelRouterHelper = Class.extend({
- //Channel type
- TYPE: CHANNEL_TYPE,
- widgetAndPageMap: null, //Id (string) map - pairs of widgetId and pageId.
- pageAndChannelRouterMap: null, //pageId and EventChannelRouter object map
- eventRouter: null,
- init: function init(options) {
- EventChannelRouterHelper.inherited('init', this, arguments);
- this.eventRouter = options.eventRouter;
- this.pageAndChannelRouterMap = {};
- },
- destroy: function destroy() {
- for (var containerPageId in this.pageAndChannelRouterMap) {
- if (this.pageAndChannelRouterMap.hasOwnProperty(containerPageId)) {
- delete this.pageAndChannelRouterMap[containerPageId];
- }
- }
- delete this.topLayoutModel;
- delete this.pageAndChannelRouterMap;
- delete this.eventRouter;
- },
- /**
- * Create SamePage type EventChannelRouter for given containerPageId and store in the map
- */
- createSamePageEventChannelRouter: function createSamePageEventChannelRouter(containerPageId) {
- var channelOptoins = {
- channelId: containerPageId,
- eventNames: EVENT_NAMES.SAME_PAGE,
- globalEventRouter: this.eventRouter,
- alias: _.unique('tabPageECR_')
- };
- var pageEventRouter = new EventChannelRouter(channelOptoins);
- this.pageAndChannelRouterMap[containerPageId] = pageEventRouter;
- return pageEventRouter;
- },
- /**
- * @returns eventChannelRouter for the given pageId. Create and save one if does not exist
- */
- getChannelRouter: function getChannelRouter(containerPageId) {
- if (this.pageAndChannelRouterMap[containerPageId]) {
- return this.pageAndChannelRouterMap[containerPageId];
- }
- return this.createSamePageEventChannelRouter(containerPageId);
- }
- });
- return EventChannelRouterHelper;
- });
- //# sourceMappingURL=EventChannelRouterHelper.js.map
|