import React from 'react'; import TableColumnMixin from '../mixins/table_column_mixin'; import GeneralUtils from '../utils/general_utils'; let TableHeader = React.createClass({ mixins: [TableColumnMixin], propTypes: { columnMap: React.PropTypes.object.isRequired, itemList: React.PropTypes.array.isRequired, fetchList: React.PropTypes.func.isRequired, orderAsc: React.PropTypes.bool.isRequired }, sortIndex(i) { let orderAsc; if(this.props.orderAsc) { orderAsc = false; } else { orderAsc = true; } this.props.fetchList(1, 10, null, Object.keys(this.props.columnMap)[i], orderAsc); }, render() { let columnMapValuesList = GeneralUtils.valuesOfObject(this.props.columnMap); let calcHeaderText = (val, i, columnClass) => { let s = ""; if(columnMapValuesList[i].canBeOrdered) { let boundClick = this.sortIndex.bind(this, i); let carretDirection = 'glyphicon-triangle-'; if(this.props.orderAsc) { carretDirection += 'top'; } else { carretDirection += 'bottom'; } return (