'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: Dashboard * (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', 'react-dom', 'ca-ui-toolkit', 'jquery', 'underscore', '../ExtensionBaseView'], function (React, ReactDOM, toolkit, $, _, BaseView) { var Grid = toolkit.Grid, GridCell = toolkit.GridCell; var ForecastDetailsView = function (_BaseView) { _inherits(ForecastDetailsView, _BaseView); function ForecastDetailsView(options) { _classCallCheck(this, ForecastDetailsView); return _possibleConstructorReturn(this, _BaseView.call(this, options)); } ForecastDetailsView.prototype.render = function render(container, resultTable) { this.table = resultTable; this.containerNode = container; BaseView.clearContainer(this.containerNode); // class name is needed for using style from ba-ui-toolkit this.containerNode.classList.add('ba-theme-waca'); return this._renderReactGrid(); }; ForecastDetailsView.prototype._renderReactGrid = function _renderReactGrid() { var _this2 = this; return new Promise(function (resolve) { var props = { numColumns: _this2.table.getNumColumns(), numRows: _this2.table.getNumRows(), fixedRows: _this2.table.getNumHeaderRows(), fixedColumns: _this2.table.getNumFixedColumns(), autoMeasureColumnWidth: true, autoMeasureRowHeight: true, dataCellRenderer: _this2._cellRenderer.bind(_this2, _this2.table.getCell.bind(_this2.table)), fixedRowCellRenderer: _this2._cellRenderer.bind(_this2, _this2.table.getHeader.bind(_this2.table)), fixedColumnCellRenderer: _this2._cellRenderer.bind(_this2, _this2.table.getFixedColumn.bind(_this2.table)) }; ReactDOM.render(React.createElement(Grid, props), _this2.containerNode, function () { return resolve(props); }); }); }; ForecastDetailsView.prototype._cellRenderer = function _cellRenderer(getDataFn, rowIndex, colIndex, gridCellProps) { var data = getDataFn(rowIndex, colIndex); gridCellProps.style = _.extend({}, gridCellProps.style, data.style.gridCell || {}); return this._getCellComponent(data.value, gridCellProps, data.style.cellValue.alignment); }; ForecastDetailsView.prototype._getCellComponent = function _getCellComponent(value, gridCellProps, alignment) { return React.createElement( GridCell, gridCellProps, React.createElement( 'div', { style: BaseView.CELL.style[alignment || 'left'] }, value || '' ) ); }; return ForecastDetailsView; }(BaseView); return ForecastDetailsView; }); //# sourceMappingURL=ForecastDetailsView.js.map