UNPKG

rstarter-supporthq

Version:

15 lines (11 loc) 7.52 kB
webpackHotUpdate("bundle",{ /***/ "./src/General/Datatables/index.js": /*!*****************************************!*\ !*** ./src/General/Datatables/index.js ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _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; }; }();\n\nvar _react = __webpack_require__(/*! react */ \"./node_modules/react/index.js\");\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _reactRouterDom = __webpack_require__(/*! react-router-dom */ \"./node_modules/react-router-dom/esm/react-router-dom.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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; }\n\nfunction _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; }\n\nvar Datatable = function (_React$Component) {\n _inherits(Datatable, _React$Component);\n\n function Datatable(props) {\n _classCallCheck(this, Datatable);\n\n var _this = _possibleConstructorReturn(this, (Datatable.__proto__ || Object.getPrototypeOf(Datatable)).call(this, props));\n\n _this.state = {\n totalPages: 10,\n pages: [],\n columns: [{\n label: \"id\",\n name: \"id\",\n width: \"700\"\n }, {\n label: \"name\",\n name: \"name\",\n width: \"300\"\n }, {\n label: \"address\",\n name: \"address\",\n width: \"300\"\n }, {\n label: \"address2\",\n name: \"address2\",\n width: \"300\"\n }],\n tableData: [{ id: 1,\n name: \"fuad\",\n address2: \"bashabo\",\n address: \"bashabo\" }, { id: 2,\n name: \"faeid\" }, { id: 3,\n name: \"faeid\" }]\n };\n _this.onChangeTableParams = _this.onChangeTableParams.bind(_this);\n return _this;\n }\n\n _createClass(Datatable, [{\n key: 'setPages',\n value: function setPages() {\n var pages = this.state.totalPages;\n var numberOfPages = [];\n for (var i = 0; i < pages; i++) {\n numberOfPages.push(i + 1);\n }\n this.setState({ pages: numberOfPages });\n }\n }, {\n key: 'componentDidMount',\n value: function componentDidMount() {\n this.setPages();\n console.log(this.state.totalPages);\n }\n }, {\n key: 'onChangeTableParams',\n value: function onChangeTableParams(pageNo) {\n console.log(pageNo);\n }\n }, {\n key: 'componentWillMount',\n value: function componentWillMount() {}\n }, {\n key: 'render',\n value: function render() {\n var _this2 = this;\n\n return _react2.default.createElement(\n 'div',\n null,\n _react2.default.createElement(\n 'div',\n { className: 'table-responsive' },\n _react2.default.createElement(\n 'table',\n { className: 'table table-bordered' },\n _react2.default.createElement(\n 'thead',\n null,\n _react2.default.createElement(\n 'tr',\n null,\n this.state.columns.map(function (column, index) {\n return _react2.default.createElement(\n 'th',\n { width: column.width != null ? column.width + \"px\" : \"\" },\n column.label\n );\n })\n )\n ),\n _react2.default.createElement(\n 'tbody',\n null,\n this.state.tableData.map(function (column, index) {\n return _react2.default.createElement(\n 'tr',\n null,\n _this2.state.columns.map(function (data, indexOfData) {\n return _react2.default.createElement(\n 'td',\n null,\n column[data.name]\n );\n })\n );\n })\n )\n )\n ),\n _react2.default.createElement(\n 'div',\n { className: 'float-right' },\n _react2.default.createElement(\n 'nav',\n { 'aria-label': 'Page navigation' },\n _react2.default.createElement(\n 'ul',\n { className: 'pagination' },\n _react2.default.createElement(\n 'li',\n { className: 'page-item' },\n _react2.default.createElement(\n 'a',\n { className: 'page-link', href: '#' },\n 'Previous'\n )\n ),\n this.state.pages.map(function (page, index) {\n return _react2.default.createElement(\n 'li',\n { className: 'page-item ' },\n _react2.default.createElement(\n 'a',\n { className: 'page-link', onClick: function onClick(e) {\n $(\".pagination li\").each(function (e) {\n console.log(this);\n if ($(this).hasClass('active')) {\n $(this).removeClass('active');\n }\n });\n $(_this2).parent().addClass('active');\n _this2.onChangeTableParams(e.target.innerText);\n } },\n page\n )\n );\n }),\n _react2.default.createElement(\n 'li',\n { className: 'page-item' },\n _react2.default.createElement(\n 'a',\n { className: 'page-link', href: '#' },\n 'Next'\n )\n )\n )\n )\n )\n );\n }\n }]);\n\n return Datatable;\n}(_react2.default.Component);\n\nexports.default = Datatable;\n\n//# sourceURL=webpack:///./src/General/Datatables/index.js?"); /***/ }) })