var Tbody; import './tr.js'; import autoBind from 'react-autobind'; export default window.Tbody = Tbody = class Tbody extends React.Component { constructor(props) { var ref, ref1, ref2, ref3, ref4; super(props); this.state = { columns: (ref = props.columns) != null ? ref : [], data: (ref1 = props.data) != null ? ref1 : [], controller: (ref2 = props.controller) != null ? ref2 : '', column_render: (ref3 = props.column_render) != null ? ref3 : {}, row_click: (ref4 = props.row_click) != null ? ref4 : '', sortable: props.sortable === true }; autoBind(this); this.tbody = null; this.rows = {}; } onSelect() { var base; return typeof (base = this.props).onSelect === "function" ? base.onSelect() : void 0; } getSelected() { var i, res, v; res = []; for (i in this.rows) { v = this.rows[i]; if (v != null) { if (v.state.selected) { res.push(v); } } } return res; } selectAll(x = true) { var i, results, v; results = []; for (i in this.rows) { v = this.rows[i]; if (v != null) { results.push(v.setSelect(x)); } else { results.push(void 0); } } return results; } componentWillReceiveProps(props) { return this.setState({ data: props.data }); } init() { var controller, data; console.log('intiSortable??'); ({ controller, data } = this.state); if (this.state.sortable) { return $(this.tbody).sortable({ handle: '.up_down', start: function (x, y, z) { return $(z).hide(); }, stop: function (x, y, z) { var $y, id, pos; $y = $(y); pos = $y.index(); id = $y.attr('data-id'); return API(controller + '/updatePosForID', { id: id, pos: pos }); } }); } } componentDidMount() { return this.init(); } renderTr(item) { var _this = this; return /*#__PURE__*/React.createElement(Tr, { data: item.data, id: item.id, controller: this.state.controller, column_render: this.state.column_render, row_click: this.state.row_click, key: item.id, openUadd: this.props.openUadd, sortable: this.state.sortable, onSelect: this.onSelect, ref: function (i) { return _this.rows[item.id] = i; } }); } render() { var _this2 = this; var data; ({ data } = this.state); return /*#__PURE__*/React.createElement("tbody", { ref: function (i) { return _this2.tbody = i; } }, data.map(this.renderTr)); } }; //# sourceMappingURL=tbody.js.map