a-chart
Version:
A-Chart is a ReactJS Library/Package to address all posibilities of Reporting Functionality
184 lines (145 loc) • 6.92 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _reactRedux = require("react-redux");
var _gridHeader = require("./gridHeader");
var _gridHeader2 = _interopRequireDefault(_gridHeader);
var _gridFooter = require("./gridFooter");
var _gridFooter2 = _interopRequireDefault(_gridFooter);
var _gridToolBar = require("./gridToolBar");
var _gridToolBar2 = _interopRequireDefault(_gridToolBar);
var _gridRow = require("./gridRow");
var _gridRow2 = _interopRequireDefault(_gridRow);
var _dataGrid = require("../../actions/dataGrid");
var ListFn = _interopRequireWildcard(_dataGrid);
var _utilFns = require("../../util/utilFns");
var Util = _interopRequireWildcard(_utilFns);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
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; }
//let Util=UtilR;
// const Row = (props) => {
// var cells = [], cVal;
// for (var key in props.d) {
// if (Util.colMatch(key, props.config.columnsToHide)) {
// continue;
// }
// if (props.config.formatters[key]) {
// try {
// cVal = props.config.formatters[key].apply(props.d, [props.d[key]]);
// } catch (e) {
// alert("Error Returned in Custom formatter:-" + key);
// }
// } else {
// cVal = props.d[key];
// }
// cells.push(<td key={props.rowId + key} className={"achart-column-" + key}>{cVal}</td>);
// }
// return (<tr className={(props.config.rowFocus) ? "onfocus" : ""}>
// {cells}
// </tr>);
// }
var Grid = function (_Component) {
_inherits(Grid, _Component);
function Grid(props) {
_classCallCheck(this, Grid);
return _possibleConstructorReturn(this, (Grid.__proto__ || Object.getPrototypeOf(Grid)).call(this, props));
// alert(1);
}
_createClass(Grid, [{
key: "componentWillMount",
value: function componentWillMount() {
//Util._prepHeader=Util._prepHeader.bind(this);
if (typeof this.props.itemSource === "string") {
// alert("from");
this.props.dispatch(ListFn.RenderListAPI(this.props.itemSource, this.props.config));
} else {
this.props.dispatch(ListFn.RenderList(this.props.itemSource, this.props.config));
}
}
}, {
key: "render",
value: function render() {
var _this2 = this;
if (!this.props.config.headersCReated) {
return _react2.default.createElement(
"div",
null,
"Preparing header data...."
);
}
return _react2.default.createElement(
"div",
{
className: "achart-gridHolder",
style: { width: this.props.config.width + "px" }
},
_react2.default.createElement("a", { id: "achart-dlink" }),
this.props.config.export || this.props.config.search ? _react2.default.createElement(_gridToolBar2.default, { config: this.props.config }) : "",
_react2.default.createElement(
"table",
{
className: "achart-grid",
id: this.props.config._tableId,
style: { width: "100%" }
},
_react2.default.createElement(
"thead",
{ className: "achart-gridHeader" },
this.props.config.header && this.props.config.headersCReated ? _react2.default.createElement(_gridHeader2.default, {
d: this.props.config.headers,
config: this.props.config
}) : ""
),
_react2.default.createElement(
"tbody",
null,
this.props.items.map(function (d, i) {
return _react2.default.createElement(_gridRow2.default, {
d: d,
config: _this2.props.config,
rowId: "gridRowid-" + i,
key: "gridRowid-" + i
});
}),
!this.props.items.length && _react2.default.createElement(_gridFooter.NoDataRow, {
d: this.props.config.headers,
config: this.props.config
})
),
this.props.items.length ? _react2.default.createElement(
"tfoot",
{ className: "achart-gridFooter" },
_react2.default.createElement(_gridFooter2.default, {
d: this.props.config.headers,
config: this.props.config
})
) : _react2.default.createElement("tfoot", null)
)
);
}
}]);
return Grid;
}(_react.Component);
//const mapDispatchToProps = (dispatch, ownProps) => { return { listLoad: dispatch({ type: "RENDER", items: ownProps.items }) } }
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
return {
listLoad: function listLoad(dispatch, ownProps) {
dispatch({ type: "RENDER", items: ownProps.items });
}
};
};
function select(state, ownProps) {
return {
// items: ownProps.items
items: state.dataGridR.items
//listData: state.fireReducer.listData
};
}
exports.default = (0, _reactRedux.connect)(select)(Grid);
;