meraproject/lib/js/bws/react/table/table.min.js

3 lines
3.5 KiB
JavaScript
Raw Permalink Normal View History

var Table;import"./thead.js";import"./tbody.js";import"./TableTitle.js";import"./../ui/pagination.js";import"./../ui/modal.js";import"./../common.js";import autoBind from"react-autobind";export default window.Table=Table=class extends React.Component{constructor(t){super(t),this.state=this.prepareProps(t),this.pagination=null,this.force_page=null,autoBind(this)}prepareProps(t){var e,l,i,r,n,a,o,s,d,h,c,u,p,_,g;return e=t.data,console.log("query",e,e.query),{columns:null!=(l=e.columns)?l:[],data:null!=(i=e.data)?i:[],pages:null!=(s=e.pages)?s:0,page:null!=(d=e.page)?d:0,controller:null!=(h=e.controller)?h:"",column_render:null!=(c=e.column_render)?c:{},title:null!=(u=e.title)?u:{},init_data:null!=(p=e.init_data)?p:{},row_click:null!=(_=e.row_click)?_:-1,count:null!=(g=e.count)?g:10,where:null!=(r=e.where)?r:null,hide_thead:!0===e.hide_thead,hide_title:!0===e.hide_title,sortable:!0===e.sortable,hide_columns:null!=(n=e.hide_columns)?n:[],sort:null!=(a=e.sort)?a:[],filter:null!=(o=e.filter)?o:[]}}destroy(){return Controllers.remove(this.state.controller,this)}componentDidMount(){return $(this.wrap).on("destroyed ",this.destroy),Controllers.add(this.state.controller,this),A.P.initMini($(this.wrap))}aReload(t){var e;try{t=JSON.parse(t)}catch(e){e,t={}}return e=this.prepareProps({data:t}),this.setState(e,function(){return psUpdate(),this.tbody.init()}),A.P.initMini($(this.wrap))}openUadd(){var t;return null!=(t=this.title)?t.createNew():void 0}reload(){var t,e,l,i,r,n,a,o,s,d,h,c,u;return({count:t,row_click:s,init_data:a,where:u,hide_thead:i,hide_title:r,hide_columns:l,sortable:c,sort:h,filter:e}=this.state),o=0,null!==this.force_page?(o=this.force_page,this.force_page=null):null!=this.pagination&&(o=this.pagination.state.now-1),d={page:o,2:h,7:t,4:u,row_click:s,init_data:a,hide_thead:i,hide_title:r,HIDE_COLUMNS:l,sortable:c,filter:e},API(this.state.controller+"/getTableData",d,this.aReload.bind(this)),n={page:o,count:t,filter:e},H.SEARCH.setValue(this.state.controller,JSON.stringify(n))}onDelete(){var t,e,l,i,r;for(r=this.tbody.getSelected(),e=[],this.onSelectAll(!1),l=0,i=r.length;l<i;l++)t=r[l],e.push(t.state.id);return API(this.state.controller+"/removeByIds",{ids:e},this.reload)}onSelectAll(t){return this.tbody.selectAll(t),this.title.setSelectCount(t?this.state.data.length:0),this.thead.setSelected(t)}onSelectRow(){var t;return t=this.tbody.getSelected(),this.title.setSelectCount(t.length),this.thead.setSelected(t.length===this.state.data.length)}setFilter(t){return this.force_page=0,this.pagination.setNow(1),this.setState({filter:t},this.reload)}render(){var t,e,l,i,r,n,a,o,s,d,h=this;return({columns:t,data:l,pages:o,page:a,controller:e,title:d,init_data:n,hide_thead:i,hide_title:r,sortable:s}=this.state),React.createElement("div",{ref:function(t){return h.wrap=t}},React.createElement(TableTitle,{controller:e,title:d,init_data:n,ref:function(t){return h.title=t},hide_title:r,onDelete:this.onDelete}),React.createElement("table",{cellPadding:0,cellSpacing:0},React.createElement(Thead,{columns:t,hide_thead:i,sortable:s,ref:function(t){return h.thead=t},onSelect:this.onSelectAll,onSetFilter:this.setFilter}),React.createElement(Tbody,{columns:t,data:l,controller:e,column_render:this.state.column_render,row_click:this.state.row_click,openUadd:this.openUadd,sortable:s,onSelect:this.onSelectRow,ref:function(t){return h.tbody=t}})),React.createElement(Pagination,{ref:function(t){return h.pagination=t},pages:o,now:a+1,onChange:this.reload}))}};
//# sourceMappingURL=table.min.js.map