12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 'use strict';
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: CA
- *| (C) Copyright IBM Corp. 2017 - 2018
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['jquery'], function ($) {
- var TriggerEventActionHandler = function TriggerEventActionHandler(options) {
- // Only passed in when we're dealing with a button. Options is undefined for a menu item
- this.dashboardApi = options && options.dashboardApi;
- };
- /**
- * Button action handler
- */
- TriggerEventActionHandler.prototype.execute = function (event, buttonDefinition) {
- TriggerEventActionHandler._triggerEvent(this.dashboardApi, buttonDefinition);
- };
- /**
- * Menu action handler
- */
- TriggerEventActionHandler.prototype.onSelectItem = function (context) {
- var menuId = context.target.itemId;
- // Need to find the menu contribution specification
- var menuSpec = $.grep(context.target.plugin.itemSpec.items, function (item) {
- return item.id === menuId;
- });
- if (!menuSpec || menuSpec.length === 0) {
- console.debug('Could not find menu with id ' + menuId);
- }
- var dashboardApi = context.glassContext.appController.getCurrentContentView().getDashboardApi();
- TriggerEventActionHandler._triggerEvent(dashboardApi, menuSpec[0]);
- };
- TriggerEventActionHandler._triggerEvent = function (dashboardApi, contribDef) {
- var eventName = contribDef ? contribDef.eventName : null;
- if (!eventName) {
- console.debug('No eventName property in the button definition.');
- return;
- }
- dashboardApi.triggerDashboardEvent(eventName);
- };
- return TriggerEventActionHandler;
- });
- //# sourceMappingURL=TriggerEventActionHandler.js.map
|