Seach: autosubmit from search page
This commit is contained in:
@ -103,7 +103,6 @@ class UserIndex extends ImmutablePureComponent {
|
||||
<Column>
|
||||
<SimpleForm style={{ paddingBottom: 0 }}>
|
||||
<TextInput
|
||||
value={this.state.q}
|
||||
onChange={this.handleQueryChange}
|
||||
placeholder={intl.formatMessage(messages.searchPlaceholder)}
|
||||
/>
|
||||
|
||||
@ -6,30 +6,41 @@ import {
|
||||
showSearch,
|
||||
} from '../../../actions/search';
|
||||
import Search from '../components/search';
|
||||
import { debounce } from 'lodash';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
value: state.getIn(['search', 'value']),
|
||||
submitted: state.getIn(['search', 'submitted']),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
const mapDispatchToProps = (dispatch, { autoSubmit }) => {
|
||||
|
||||
onChange(value) {
|
||||
dispatch(changeSearch(value));
|
||||
},
|
||||
|
||||
onClear() {
|
||||
dispatch(clearSearch());
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
const debouncedSubmit = debounce(() => {
|
||||
dispatch(submitSearch());
|
||||
},
|
||||
}, 900);
|
||||
|
||||
onShow() {
|
||||
dispatch(showSearch());
|
||||
},
|
||||
return {
|
||||
onChange(value) {
|
||||
dispatch(changeSearch(value));
|
||||
|
||||
});
|
||||
if (autoSubmit) {
|
||||
debouncedSubmit();
|
||||
}
|
||||
},
|
||||
|
||||
onClear() {
|
||||
dispatch(clearSearch());
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
dispatch(submitSearch());
|
||||
},
|
||||
|
||||
onShow() {
|
||||
dispatch(showSearch());
|
||||
},
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Search);
|
||||
|
||||
@ -12,7 +12,7 @@ const messages = defineMessages({
|
||||
const Search = ({ intl }) => (
|
||||
<div className='column search-page'>
|
||||
<ColumnHeader icon='search' title={intl.formatMessage(messages.heading)} />
|
||||
<SearchContainer />
|
||||
<SearchContainer autoSubmit />
|
||||
<div className='drawer__pager'>
|
||||
<div className='drawer__inner darker'>
|
||||
<SearchResultsContainer />
|
||||
|
||||
Reference in New Issue
Block a user