UNPKG

react-widgetconfigurator

Version:

A React app for to generate out of box widgets

209 lines (176 loc) 8.62 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = undefined; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactstrap = require('reactstrap'); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _Trends = require('./Trends'); var _Trends2 = _interopRequireDefault(_Trends); var _reactPiewidget = require('react-piewidget'); var _reactPiewidget2 = _interopRequireDefault(_reactPiewidget); var _reactAculisttrendskpiwidget = require('react-aculisttrendskpiwidget'); var _reactAculisttrendskpiwidget2 = _interopRequireDefault(_reactAculisttrendskpiwidget); var _KPI_Trends = require('./KPI_Trends'); var _KPI_Trends2 = _interopRequireDefault(_KPI_Trends); var _TabbedTrends = require('./TabbedTrends'); var _TabbedTrends2 = _interopRequireDefault(_TabbedTrends); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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; } var WidgetTabs = function (_Component) { _inherits(WidgetTabs, _Component); function WidgetTabs(props) { _classCallCheck(this, WidgetTabs); var _this = _possibleConstructorReturn(this, (WidgetTabs.__proto__ || Object.getPrototypeOf(WidgetTabs)).call(this, props)); _this.toggle = _this.toggle.bind(_this); _this.state = { activeTab: '1', widgetselections: '', chartselections: '', kpiwidgetselections: '' }; return _this; } _createClass(WidgetTabs, [{ key: 'toggle', value: function toggle(tab) { if (this.state.activeTab !== tab) { this.setState({ activeTab: tab }); } } }, { key: 'componentWillMount', value: function componentWillMount() { // console.log('render charts'); var widgetselections = this.state.widgetselections; var chartselections = this.state.chartselections; var kpiwidgetselections = this.state.kpiwidgetselections; widgetselections = this.props.widgetselections; chartselections = this.props.chartselections; kpiwidgetselections = this.props.widgetselections; this.setState({ widgetselections: widgetselections, chartselections: chartselections, kpiwidgetselections: kpiwidgetselections }); } }, { key: 'componentWillReceiveProps', value: function componentWillReceiveProps(nextProps) { var widgetselections = this.state.widgetselections; var chartselections = this.state.chartselections; var kpiwidgetselections = this.state.kpiwidgetselections; widgetselections = nextProps.widgetselections; chartselections = nextProps.chartselections; kpiwidgetselections = nextProps.widgetselections; console.log("widgetselections will receive", widgetselections); console.log("kpiwidgetselections will receive", kpiwidgetselections); this.setState({ widgetselections: widgetselections, chartselections: chartselections, kpiwidgetselections: kpiwidgetselections }); } }, { key: 'render', value: function render() { var _this2 = this; var tab1widgets = this.state.activeTab == '1' ? _react2.default.createElement(_Trends2.default, { tabindex: '1', widgetselections: this.state.widgetselections, chartselections: this.state.chartselections, classtype: 'Residential - Single Family,Residential - Common Interest' }) : ''; var tab2widgets = this.state.activeTab == '2' ? _react2.default.createElement(_Trends2.default, { tabindex: '2', widgetselections: this.state.widgetselections, chartselections: this.state.chartselections, classtype: 'Residential - Single Family' }) : ''; var tab3widgets = this.state.activeTab == '3' ? _react2.default.createElement(_Trends2.default, { tabindex: '3', widgetselections: this.state.widgetselections, chartselections: this.state.chartselections, classtype: 'Residential - Common Interest' }) : ''; var tab4widgets = this.state.activeTab == '4' ? _react2.default.createElement(_KPI_Trends2.default, { widgetselections: this.state.kpiwidgetselections, assets: '' }) : ''; // let tab5widgets=this.state.activeTab=='5'?<TabbedTrends widgetsel ections={this.state.widgetselections} chartselections={this.state.chartselections} />:''; return _react2.default.createElement( 'div', { className: 'wcnavtabs' }, _react2.default.createElement( _reactstrap.Nav, { tabs: true }, _react2.default.createElement( _reactstrap.NavItem, null, _react2.default.createElement( _reactstrap.NavLink, { className: (0, _classnames2.default)({ active: this.state.activeTab === '1' }), onClick: function onClick() { _this2.toggle('1'); } }, 'Single Family vs Condo/Townhouse Trends' ) ), _react2.default.createElement( _reactstrap.NavItem, null, _react2.default.createElement( _reactstrap.NavLink, { className: (0, _classnames2.default)({ active: this.state.activeTab === '2' }), onClick: function onClick() { _this2.toggle('2'); } }, 'Single Family Trends' ) ), _react2.default.createElement( _reactstrap.NavItem, null, _react2.default.createElement( _reactstrap.NavLink, { className: (0, _classnames2.default)({ active: this.state.activeTab === '3' }), onClick: function onClick() { _this2.toggle('3'); } }, 'Condo/Townhouse Trends' ) ), _react2.default.createElement( _reactstrap.NavItem, null, _react2.default.createElement( _reactstrap.NavLink, { className: (0, _classnames2.default)({ active: this.state.activeTab === '4' }), onClick: function onClick() { _this2.toggle('4'); } }, 'Geography KPIs' ) ) ), _react2.default.createElement( _reactstrap.TabContent, { activeTab: this.state.activeTab }, _react2.default.createElement( _reactstrap.TabPane, { tabId: '1' }, tab1widgets ), _react2.default.createElement( _reactstrap.TabPane, { tabId: '2' }, tab2widgets ), _react2.default.createElement( _reactstrap.TabPane, { tabId: '3' }, tab3widgets ), _react2.default.createElement( _reactstrap.TabPane, { tabId: '4' }, tab4widgets ) ) ); } }]); return WidgetTabs; }(_react.Component); exports.default = WidgetTabs; module.exports = exports['default'];