UNPKG

react-widgetconfigurator

Version:

A React app for to generate out of box widgets

166 lines (132 loc) 7.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 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 _reactMarkettrendswidget = require("react-markettrendswidget"); var _reactMarkettrendswidget2 = _interopRequireDefault(_reactMarkettrendswidget); var _CopyModal = require("./CopyModal"); var _CopyModal2 = _interopRequireDefault(_CopyModal); 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 OutofBoxWidget = function (_Component) { _inherits(OutofBoxWidget, _Component); function OutofBoxWidget(props) { _classCallCheck(this, OutofBoxWidget); var _this = _possibleConstructorReturn(this, (OutofBoxWidget.__proto__ || Object.getPrototypeOf(OutofBoxWidget)).call(this, props)); _this.state = { widgetselectionsmultimeasure: { geographytype: '', geographyvalue: '', measure: 'MedSalePrice,AvgSaleOverListPrice', periodtype: '', period: '', geo: '', classtype: "Residential - Single Family" }, widgetselectionsmulticlass: { geographytype: '', geographyvalue: '', measure: 'MedSalePrice,SoldAvgDOM', periodtype: '', period: '', geo: '', classtype: 'Residential - Single Family,Residential - Common Interest' }, chartselections: { colors: [] } }; return _this; } // shouldComponentUpdate(nextProps, nextState){ // if(nextProps.widgetselections.geo===this.props.widgetselections.geo) // {return false;} else // {return true;} // } _createClass(OutofBoxWidget, [{ key: "componentWillMount", value: function componentWillMount() { // console.log('render charts'); var widgetselectionsmultimeasure = _extends({}, this.state.widgetselectionsmultimeasure); var widgetselectionsmulticlass = _extends({}, this.state.widgetselectionsmulticlass); var chartselections = _extends({}, this.state.chartselections); widgetselectionsmultimeasure.geo = this.props.widgetselections.geo; widgetselectionsmulticlass.geo = this.props.widgetselections.geo; widgetselectionsmultimeasure.period = this.props.widgetselections.period; widgetselectionsmulticlass.period = this.props.widgetselections.period; chartselections = this.props.chartselections; widgetselectionsmultimeasure.periodtype = this.props.widgetselections.periodtype; widgetselectionsmulticlass.periodtype = this.props.widgetselections.periodtype; this.setState({ widgetselectionsmultimeasure: widgetselectionsmultimeasure, widgetselectionsmulticlass: widgetselectionsmulticlass, chartselections: chartselections }); } }, { key: "componentWillReceiveProps", value: function componentWillReceiveProps(nextProps) { // console.log('render new charts'); var widgetselectionsmultimeasure = _extends({}, this.state.widgetselectionsmultimeasure); var widgetselectionsmulticlass = _extends({}, this.state.widgetselectionsmulticlass); var chartselections = _extends({}, this.state.chartselections); widgetselectionsmultimeasure.geo = nextProps.widgetselections.geo; widgetselectionsmulticlass.geo = nextProps.widgetselections.geo; widgetselectionsmultimeasure.period = nextProps.widgetselections.period; widgetselectionsmulticlass.period = nextProps.widgetselections.period; widgetselectionsmultimeasure.periodtype = nextProps.widgetselections.periodtype; widgetselectionsmulticlass.periodtype = nextProps.widgetselections.periodtype; chartselections = nextProps.chartselections; this.setState({ widgetselectionsmultimeasure: widgetselectionsmultimeasure, widgetselectionsmulticlass: widgetselectionsmulticlass, chartselections: chartselections }); } // ParentSettings(cindex,selectedcolor) { // console.log(cindex,selectedcolor); // let colors=this.state.colors; // colors[cindex]=selectedcolor.hex; // this.setState({ // colors // }); // } }, { key: "render", value: function render() { return _react2.default.createElement( _reactstrap.Container, { fluid: false }, _react2.default.createElement( _reactstrap.Row, null, _react2.default.createElement( _reactstrap.Col, { sm: { size: 12 } }, _react2.default.createElement( _reactMarkettrendswidget2.default, { widgetselections: this.state.widgetselectionsmultimeasure, assets: "", chartselections: this.state.chartselections }, " ", _react2.default.createElement(_CopyModal2.default, null) ) ) ), _react2.default.createElement( _reactstrap.Row, null, _react2.default.createElement( _reactstrap.Col, { sm: { size: 12 } }, _react2.default.createElement( _reactMarkettrendswidget2.default, { widgetselections: this.state.widgetselectionsmulticlass, assets: "", chartselections: this.state.chartselections }, " ", _react2.default.createElement(_CopyModal2.default, null) ) ) ) ); } }]); return OutofBoxWidget; }(_react.Component); exports.default = OutofBoxWidget; module.exports = exports["default"];