2018-09-22 18:23:51 +00:00
|
|
|
import React, {Component} from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
|
|
import Checkbox from '@material-ui/core/Checkbox';
|
|
|
|
import TextField from '@material-ui/core/TextField';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
import { withStyles } from '@material-ui/core/styles';
|
|
|
|
import InputAdornment from '@material-ui/core/InputAdornment';
|
|
|
|
import {
|
|
|
|
Search
|
|
|
|
} from '@material-ui/icons';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This object is used for type checking the props of the component.
|
|
|
|
*/
|
|
|
|
const propTypes = {
|
|
|
|
query: PropTypes.string.isRequired,
|
|
|
|
columns: PropTypes.array.isRequired,
|
|
|
|
onUpdateQuery: PropTypes.func.isRequired,
|
|
|
|
onColumnChange: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
const styles = theme => ({
|
|
|
|
root: {
|
|
|
|
display: 'flex',
|
|
|
|
flexWrap: 'wrap',
|
|
|
|
},
|
|
|
|
margin: {
|
|
|
|
margin: theme.spacing.unit,
|
|
|
|
},
|
|
|
|
textField: {
|
|
|
|
flexBasis: 280,
|
2018-09-28 07:10:44 +00:00
|
|
|
borderColor: "#139657"
|
2018-09-22 18:23:51 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description The Search page component of the table.
|
|
|
|
* @constructor
|
|
|
|
* @param {Object} props - The props that were defined by the caller of this component.
|
|
|
|
*/
|
|
|
|
class EnhancedSearch extends Component {
|
|
|
|
|
|
|
|
render() {
|
2018-11-04 19:42:22 +00:00
|
|
|
const {query, onUpdateQuery, onColumnChange, textComponent} = this.props;
|
2018-09-22 18:23:51 +00:00
|
|
|
const { classes } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="search-books">
|
|
|
|
<div className="search-books-bar">
|
|
|
|
<div className="search-books-input-wrapper" style={{ textAlign: 'left', marginLeft: 20}}>
|
2018-11-11 23:39:14 +00:00
|
|
|
<div className="row">
|
2018-11-14 00:07:04 +00:00
|
|
|
<div className="col-md-4 box-search"> <TextField
|
2018-11-11 23:39:14 +00:00
|
|
|
style={{ textAlign: 'left', width: '100%',borderColor: "#139657" }}
|
2018-11-07 14:49:14 +00:00
|
|
|
id="outlined-adornment-weight"
|
|
|
|
className={classNames(classes.margin, classes.textField)}
|
|
|
|
variant="outlined"
|
|
|
|
label="Search"
|
|
|
|
placeholder="Enter search term"
|
|
|
|
value={query}
|
|
|
|
onChange={(event) => onUpdateQuery(event.target.value)}
|
|
|
|
InputProps={{
|
|
|
|
startAdornment: <InputAdornment position="start"><Search /></InputAdornment>,
|
|
|
|
}}
|
2018-11-11 23:39:14 +00:00
|
|
|
/> </div>
|
|
|
|
|
|
|
|
<div className="col-md-8"> {textComponent}</div>
|
|
|
|
</div>
|
2018-09-22 18:23:51 +00:00
|
|
|
<br />
|
|
|
|
{this.props.showSearchColumns && this.props.columns.map(column => (
|
|
|
|
<FormControlLabel
|
|
|
|
key={column.name}
|
|
|
|
control={
|
|
|
|
<Checkbox
|
|
|
|
checked={column.checked}
|
|
|
|
onChange={onColumnChange(column.name)}
|
|
|
|
color="primary"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
label={column.name}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type checking the props of the component
|
|
|
|
EnhancedSearch.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default withStyles(styles)(EnhancedSearch);
|