'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * * VisActionSlotSupport * The VisActionSlotSupport is to support evaluating the actions supported and creating action instances for slots * */ define(['jquery', 'underscore', './VisActionSupportBase'], function ($, _, Base) { 'use strict'; var VisActionSlotSupport = Base.extend({ /** * @public * Get the interface for slot action support * @param {string|SLOT_ACTIONS} action * @return a interface to access the support functions for the slot action */ getInterface: function getInterface(action) { var actionName = typeof action === 'string' ? action : _.invert(VisActionSlotSupport.SLOT_ACTIONS)[action]; return { isSupported: this._getFunction(VisActionSlotSupport.PREXFIX_SUPPORT, actionName), get: this._getFunction(VisActionSlotSupport.PREXFIX_GET, actionName) }; }, /** * NOTE: Ensure to complete the following 3 steps for adding actions for slots * 1. Update the VisActionSlotSupport.SLOT_ACTIONS with the new action and position * 2. Add a 'canSupport_???' function to determine whether the action is supported for a slot * 3. Add a 'get_' function to instantiate a new instance of the action */ __canSupport_DrillAction: function __canSupport_DrillAction(slotState) { return slotState.selectionObj && slotState.singleSlot && slotState.singleSlot.isSlotSortable() && !slotState.isMultiMeasure; } }); VisActionSlotSupport.PREXFIX_SUPPORT = '__canSupport_'; VisActionSlotSupport.PREXFIX_GET = '__get_'; // NOTE: The complete list of actions supported by a slot // The index determines the order of the action appeared on the toolbar // TODO: This file needs to be cleaned up but its too late in R7 to do this. // We need to revisit in 11.2 var SLOT_ACTIONS_ARRAY = []; VisActionSlotSupport.SLOT_ACTIONS = _.reduce(SLOT_ACTIONS_ARRAY, function (_obj, e, i) { _obj[e] = i;return _obj; }, {}); return VisActionSlotSupport; }); //# sourceMappingURL=VisActionSlotSupport.js.map