ExpandCollapsePropertyProvider.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Cognos Products: Dashboard
  6. * (C) Copyright IBM Corp. 2019
  7. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. */
  9. define(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../../lib/@waca/dashboard-common/dist/api/PropertiesProviderAPI', '../../../widgets/livewidget/nls/StringResources'], function (APIFactory, PropertiesProviderAPI, StringResources) {
  10. var PROP_ID_EXPANDCOLLAPSE = 'expandCollapse';
  11. var ExpandCollapsePropertyProvider = function () {
  12. function ExpandCollapsePropertyProvider(options) {
  13. _classCallCheck(this, ExpandCollapsePropertyProvider);
  14. this.content = options.content;
  15. // register self as a 'Properties' provider
  16. this.content && this.content.getFeature('Properties').registerProvider(this.getAPI());
  17. this.dashboard = options.dashboardAPI;
  18. }
  19. ExpandCollapsePropertyProvider.prototype.getAPI = function getAPI() {
  20. if (!this._api) {
  21. this._api = APIFactory.createAPI(this, [PropertiesProviderAPI]);
  22. }
  23. return this._api;
  24. };
  25. ExpandCollapsePropertyProvider.prototype.destroy = function destroy() {
  26. this.dashboard = null;
  27. this.content = null;
  28. };
  29. ExpandCollapsePropertyProvider.prototype.getPropertyLayoutList = function getPropertyLayoutList() {
  30. return [];
  31. };
  32. ExpandCollapsePropertyProvider.prototype.getPropertyList = function getPropertyList() {
  33. var _this = this;
  34. var propertyList = [];
  35. if (this._isSupported()) {
  36. propertyList.push({
  37. id: PROP_ID_EXPANDCOLLAPSE,
  38. editor: {
  39. 'sectionId': 'visualization.chart',
  40. uiControl: {
  41. type: 'ToggleButton',
  42. defaultValue: true,
  43. label: StringResources.get(PROP_ID_EXPANDCOLLAPSE),
  44. onChange: function onChange(propertyName, propertyValue) {
  45. _this.content.setPropertyValue(propertyName, propertyValue);
  46. }
  47. }
  48. },
  49. onPropertyChange: {
  50. refresh: {
  51. data: true
  52. }
  53. },
  54. defaultValue: true
  55. });
  56. }
  57. return propertyList;
  58. };
  59. ExpandCollapsePropertyProvider.prototype._isSupported = function _isSupported() {
  60. var expandCollapseFeatureFlag = !this.dashboard.getGlassCoreSvc('.FeatureChecker').checkValue('dashboard', 'expandCollapse', 'disabled');
  61. if (expandCollapseFeatureFlag) {
  62. var visApi = this.content.getFeature('Visualization');
  63. return visApi && this._isSupportedVisType(visApi) && this._isOlap(visApi);
  64. } else {
  65. return false;
  66. }
  67. };
  68. ExpandCollapsePropertyProvider.prototype._isSupportedVisType = function _isSupportedVisType(visApi) {
  69. return visApi.getType() === 'Crosstab';
  70. };
  71. ExpandCollapsePropertyProvider.prototype._isOlap = function _isOlap(visApi) {
  72. var mappedSlot = visApi.getSlots().getMappedSlotList();
  73. var dataItem = mappedSlot && mappedSlot[0] && mappedSlot[0].getDataItemList()[0];
  74. return dataItem && dataItem.getMetadataColumn().isOlapColumn() || false;
  75. };
  76. return ExpandCollapsePropertyProvider;
  77. }();
  78. return ExpandCollapsePropertyProvider;
  79. });
  80. //# sourceMappingURL=ExpandCollapsePropertyProvider.js.map