DataPointActionBase.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /*
  4. *+------------------------------------------------------------------------+
  5. *| Licensed Materials - Property of IBM
  6. *| IBM Cognos Products: Content Explorer
  7. *| (C) Copyright IBM Corp. 2019
  8. *|
  9. *| US Government Users Restricted Rights - Use, duplication or disclosure
  10. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  11. *+------------------------------------------------------------------------+
  12. */
  13. define(['../../../lib/@waca/dashboard-common/dist/utils/ContentUtil', 'underscore'], function (ContentUtil, _) {
  14. /**
  15. * The base class of data point selections actions. The selections are built from brushing or pending filters,
  16. * usually as a form of multi-select (using the ctrl/command key or long press).
  17. */
  18. var DataPointActionBase = function () {
  19. function DataPointActionBase(options) {
  20. _classCallCheck(this, DataPointActionBase);
  21. options = options || {};
  22. this.dashboard = options.dashboardAPI;
  23. this.logger = this.dashboard.getGlassCoreSvc('.Logger');
  24. this.content = options.content;
  25. this.globalFilters = this.dashboard.getFeature('GlobalFilters');
  26. this.eventGroups = this.dashboard.getFeature('EventGroups');
  27. this.transaction = this.dashboard.getFeature('Transaction');
  28. }
  29. DataPointActionBase.prototype._getLocalFilters = function _getLocalFilters() {
  30. if (!this.localFilters) {
  31. this.visualization = this.visualization || this.content.getFeature('Visualization');
  32. this.localFilters = this.visualization.getLocalFilters();
  33. }
  34. return this.localFilters;
  35. };
  36. DataPointActionBase.prototype._getSelector = function _getSelector() {
  37. var type = this.dashboard.getAppConfig('pageContainerType');
  38. var page = ContentUtil.getPageContent(this.content, type);
  39. return {
  40. origin: 'visualization',
  41. sourceId: this._getVisualization().getDataSource().getId(),
  42. scope: page && page.getId(),
  43. eventGroupId: this.eventGroups.getGroupId(this.content.getId()),
  44. //use the 'strict match option' and event source to only select brushing entries
  45. //that originate from this visualization.
  46. eventSourceId: this.content.getId(),
  47. _strictMatch: true
  48. };
  49. };
  50. DataPointActionBase.prototype._getVisualization = function _getVisualization() {
  51. this.visualization = this.visualization || this.content.getFeature('Visualization');
  52. return this.visualization;
  53. };
  54. DataPointActionBase.prototype._groupSelections = function _groupSelections(selectionList) {
  55. var groupedSelections = {};
  56. if (!selectionList || !selectionList.length) {
  57. return;
  58. }
  59. var columnIdList = null;
  60. var tupleList = null;
  61. var categoryList = _.pluck(selectionList, 'categories');
  62. categoryList.forEach(function (tuple) {
  63. tupleList = [];
  64. columnIdList = [];
  65. tuple && tuple.forEach(function (value) {
  66. columnIdList.push(value.columnId);
  67. // TODO Add .u and .d internally until all internal implementation classes (pageContext, filters etc.) use .value and .label.
  68. value.u = value.value;
  69. value.d = value.label;
  70. if (value.parentId) {
  71. value.p = {
  72. u: value.parentId
  73. };
  74. }
  75. tupleList.push(value);
  76. });
  77. var groupKey = _.uniq(columnIdList).join();
  78. if (!groupedSelections[groupKey]) {
  79. groupedSelections[groupKey] = [];
  80. }
  81. groupedSelections[groupKey].push(tupleList);
  82. });
  83. return groupedSelections;
  84. };
  85. return DataPointActionBase;
  86. }();
  87. return DataPointActionBase;
  88. });
  89. //# sourceMappingURL=DataPointActionBase.js.map