CustomVisualItems.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. /**
  6. * Licensed Materials - Property of IBM
  7. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['react', 'prop-types', 'ca-ui-toolkit', '../VisualizationContentContainer', '../VisualItem'], function (React, PropTypes, UI_Toolkit, VisualizationContentContainer, VisualItem) {
  11. var FlexLayout = UI_Toolkit.FlexLayout,
  12. FlexItem = UI_Toolkit.FlexItem;
  13. var CustomVisualItems = function (_VisualizationContent) {
  14. _inherits(CustomVisualItems, _VisualizationContent);
  15. function CustomVisualItems(props) {
  16. _classCallCheck(this, CustomVisualItems);
  17. var _this = _possibleConstructorReturn(this, _VisualizationContent.call(this, props));
  18. _this.target = undefined;
  19. _this.targetName = undefined;
  20. _this.state = {
  21. isContextMenuOpen: false,
  22. items: _this.props.items
  23. };
  24. return _this;
  25. }
  26. CustomVisualItems.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  27. this.setState({
  28. items: nextProps.items
  29. });
  30. };
  31. CustomVisualItems.prototype.render = function render() {
  32. var _this2 = this;
  33. var items = this.state.items;
  34. var containerClass = this.props.containerClass;
  35. var contentItems = [];
  36. items.forEach(function (item) {
  37. contentItems.push(_this2.renderVisualizationItem(item));
  38. });
  39. return React.createElement(
  40. FlexLayout,
  41. {
  42. className: containerClass,
  43. fullHeight: true,
  44. direction: 'column',
  45. justifyContent: 'flex-start'
  46. },
  47. React.createElement(
  48. FlexItem,
  49. null,
  50. React.createElement(
  51. FlexLayout,
  52. {
  53. fullHeight: true,
  54. direction: 'row',
  55. wrap: 'wrap'
  56. },
  57. contentItems
  58. )
  59. )
  60. );
  61. };
  62. CustomVisualItems.prototype.renderVisualizationItem = function renderVisualizationItem(item) {
  63. var _props = this.props,
  64. onContextMenuChange = _props.onContextMenuChange,
  65. handlers = _props.handlers;
  66. return React.createElement(VisualItem, {
  67. item: item,
  68. handlers: handlers,
  69. onContextMenuChange: onContextMenuChange,
  70. openSelectBundleFileDialog: this.props.handlers.openSelectBundleFileDialog,
  71. customVisAction: this.props.customVisAction
  72. });
  73. };
  74. return CustomVisualItems;
  75. }(VisualizationContentContainer);
  76. CustomVisualItems.propTypes = {
  77. items: PropTypes.array,
  78. isRefreshing: PropTypes.bool,
  79. containerClass: PropTypes.string.isRequired,
  80. itemClass: PropTypes.string.isRequired,
  81. handlers: PropTypes.shape({
  82. openSelectBundleFileDialog: PropTypes.func.isRequired
  83. }).isRequired,
  84. customVisAction: PropTypes.object.isRequired
  85. };
  86. CustomVisualItems.defaultProps = {
  87. items: [],
  88. onContextMenuChange: function onContextMenuChange() {}
  89. };
  90. return CustomVisualItems;
  91. });
  92. //# sourceMappingURL=CustomVisualItems.js.map