123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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; }
- 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; }
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['react', 'prop-types', './CustomVisualItems', './NoCustomVisuals', '../util/CustomUtil'], function (React, PropTypes, CustomVisualItems, NoCustomVisuals, CustomUtil) {
- var Component = React.Component;
- var CONTENT_CLASS = 'vis-custom-vis-content';
- var CustomVisualsContentComponent = function (_Component) {
- _inherits(CustomVisualsContentComponent, _Component);
- function CustomVisualsContentComponent(props) {
- _classCallCheck(this, CustomVisualsContentComponent);
- var _this = _possibleConstructorReturn(this, _Component.call(this, props));
- var customVisAction = _this.props.customVisAction;
- customVisAction.setCustomVisualsContentComponent(_this);
- _this.state = {
- items: _this.props.items,
- isRefreshing: _this.props.isRefreshing
- };
- return _this;
- }
- CustomVisualsContentComponent.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
- this.setState({
- items: nextProps.items,
- isRefreshing: nextProps.isRefreshing
- });
- };
- CustomVisualsContentComponent.prototype.render = function render() {
- var _state = this.state,
- items = _state.items,
- isRefreshing = _state.isRefreshing;
- var _props = this.props,
- handlers = _props.handlers,
- customVisAction = _props.customVisAction;
- var hasItems = items.length > 0;
- if (isRefreshing) {
- return null;
- }
- return hasItems ? React.createElement(CustomVisualItems, {
- items: items,
- containerClass: CONTENT_CLASS,
- itemClass: 'prop-item',
- onContextMenuChange: this.onContextMenuChange.bind(this),
- handlers: handlers,
- customVisAction: customVisAction
- }) : React.createElement(NoCustomVisuals, {
- handlers: handlers,
- customVisAction: customVisAction
- });
- };
- CustomVisualsContentComponent.prototype.onContextMenuChange = function onContextMenuChange(itemToUpdateOrDelete, action) {
- var _this2 = this;
- if (action === 'delete') {
- var dashboardApi = this.props.dashboardApi;
- var refreshCustomVisDefinitions = this.props.handlers.refreshCustomVisDefinitions;
- return CustomUtil.deleteCustomVis(dashboardApi, itemToUpdateOrDelete.name, refreshCustomVisDefinitions).then(function (items) {
- var customVisAction = _this2.props.customVisAction;
- customVisAction.setItems(items);
- });
- }
- };
- return CustomVisualsContentComponent;
- }(Component);
- CustomVisualsContentComponent.propTypes = {
- items: PropTypes.array.isRequired,
- handlers: PropTypes.shape({
- refreshCustomVisDefinitions: PropTypes.func.isRequired
- }).isRequired,
- isRefreshing: PropTypes.bool,
- dashboardApi: PropTypes.object.isRequired,
- customVisAction: PropTypes.object.isRequired
- };
- CustomVisualsContentComponent.defaultProps = {
- isRefreshing: false
- };
- return CustomVisualsContentComponent;
- });
- //# sourceMappingURL=CustomVisualsContentComponent.js.map
|