SuppressionPropertyProvider.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_SUPPRESSION = 'suppression';
  11. var SuppressionPropertyProvider = function () {
  12. function SuppressionPropertyProvider(options) {
  13. _classCallCheck(this, SuppressionPropertyProvider);
  14. this.content = options.content;
  15. // register self as a 'Properties' provider
  16. this.content && this.content.getFeature('Properties').registerProvider(this.getAPI());
  17. }
  18. SuppressionPropertyProvider.prototype.getAPI = function getAPI() {
  19. if (!this._api) {
  20. this._api = APIFactory.createAPI(this, [PropertiesProviderAPI]);
  21. }
  22. return this._api;
  23. };
  24. SuppressionPropertyProvider.prototype.destroy = function destroy() {
  25. this.content = null;
  26. };
  27. SuppressionPropertyProvider.prototype.getPropertyLayoutList = function getPropertyLayoutList() {
  28. return [];
  29. };
  30. SuppressionPropertyProvider.prototype.getPropertyList = function getPropertyList() {
  31. var _this = this;
  32. var propertyList = [];
  33. if (this._isSupported()) {
  34. propertyList.push({
  35. id: PROP_ID_SUPPRESSION,
  36. editor: {
  37. 'sectionId': 'visualization.chart',
  38. uiControl: {
  39. type: 'ToggleButton',
  40. defaultValue: 'rowsAndColumns',
  41. label: StringResources.get(PROP_ID_SUPPRESSION),
  42. onChange: function onChange(propertyName, propertyValue) {
  43. var overrideValue = propertyValue === false ? 'none' : 'rowsAndColumns';
  44. _this.content.setPropertyValue(propertyName, overrideValue);
  45. }
  46. }
  47. },
  48. onPropertyChange: {
  49. refresh: {
  50. data: true
  51. }
  52. },
  53. defaultValue: 'rowsAndColumns'
  54. });
  55. }
  56. return propertyList;
  57. };
  58. SuppressionPropertyProvider.prototype._isSupported = function _isSupported() {
  59. var visApi = this.content.getFeature('Visualization');
  60. return visApi && this._isSupportedVisType(visApi);
  61. };
  62. SuppressionPropertyProvider.prototype._isSupportedVisType = function _isSupportedVisType(visApi) {
  63. return visApi.getType() === 'Crosstab' || visApi.getType() === 'List';
  64. };
  65. SuppressionPropertyProvider.prototype._isOlap = function _isOlap(visApi) {
  66. var mappedSlot = visApi.getSlots().getMappedSlotList();
  67. var dataItem = mappedSlot[0] && mappedSlot[0].getDataItemList()[0];
  68. return dataItem && dataItem.getMetadataColumn().isOlapColumn() || false;
  69. };
  70. return SuppressionPropertyProvider;
  71. }();
  72. return SuppressionPropertyProvider;
  73. });
  74. //# sourceMappingURL=SuppressionPropertyProvider.js.map