VisActionSlotSupport.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018, 2020
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. *
  7. * VisActionSlotSupport
  8. * The VisActionSlotSupport is to support evaluating the actions supported and creating action instances for slots
  9. *
  10. */
  11. define(['jquery', 'underscore', './VisActionSupportBase'], function ($, _, Base) {
  12. 'use strict';
  13. var VisActionSlotSupport = Base.extend({
  14. /**
  15. * @public
  16. * Get the interface for slot action support
  17. * @param {string|SLOT_ACTIONS} action
  18. * @return a interface to access the support functions for the slot action
  19. */
  20. getInterface: function getInterface(action) {
  21. var actionName = typeof action === 'string' ? action : _.invert(VisActionSlotSupport.SLOT_ACTIONS)[action];
  22. return {
  23. isSupported: this._getFunction(VisActionSlotSupport.PREXFIX_SUPPORT, actionName),
  24. get: this._getFunction(VisActionSlotSupport.PREXFIX_GET, actionName)
  25. };
  26. },
  27. /**
  28. * NOTE: Ensure to complete the following 3 steps for adding actions for slots
  29. * 1. Update the VisActionSlotSupport.SLOT_ACTIONS with the new action and position
  30. * 2. Add a 'canSupport_???' function to determine whether the action is supported for a slot
  31. * 3. Add a 'get_' function to instantiate a new instance of the action
  32. */
  33. __canSupport_DrillAction: function __canSupport_DrillAction(slotState) {
  34. return slotState.selectionObj && slotState.singleSlot && slotState.singleSlot.isSlotSortable() && !slotState.isMultiMeasure;
  35. }
  36. });
  37. VisActionSlotSupport.PREXFIX_SUPPORT = '__canSupport_';
  38. VisActionSlotSupport.PREXFIX_GET = '__get_';
  39. // NOTE: The complete list of actions supported by a slot
  40. // The index determines the order of the action appeared on the toolbar
  41. // TODO: This file needs to be cleaned up but its too late in R7 to do this.
  42. // We need to revisit in 11.2
  43. var SLOT_ACTIONS_ARRAY = [];
  44. VisActionSlotSupport.SLOT_ACTIONS = _.reduce(SLOT_ACTIONS_ARRAY, function (_obj, e, i) {
  45. _obj[e] = i;return _obj;
  46. }, {});
  47. return VisActionSlotSupport;
  48. });
  49. //# sourceMappingURL=VisActionSlotSupport.js.map