Skip to content

Commit

Permalink
Linter 2 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Loic Teixeira committed Apr 30, 2017
1 parent 76489f0 commit bb3bdee
Show file tree
Hide file tree
Showing 11 changed files with 918 additions and 919 deletions.
124 changes: 62 additions & 62 deletions wagtailmodelchoosers/client/components/AutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,84 @@ const getSuggestionValue = suggestion => suggestion.name;
const renderSuggestion = () => null;

const defaultProps = {
filter: '',
filter: '',
};

const propTypes = {
onLoadSuggestions: PropTypes.func.isRequired,
onLoadStart: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
endpoint: PropTypes.string.isRequired,
filter: PropTypes.string,
onLoadSuggestions: PropTypes.func.isRequired,
onLoadStart: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
endpoint: PropTypes.string.isRequired,
filter: PropTypes.string,
};

class AutoComplete extends Component {
constructor(props) {
super(props);
constructor(props) {
super(props);

this.state = {
value: '',
suggestions: [],
};
this.state = {
value: '',
suggestions: [],
};

this.loadSuggestions = this.loadSuggestions.bind(this);
this.onSuggestionsUpdateRequested = this.onSuggestionsUpdateRequested.bind(this);
this.onChange = this.onChange.bind(this);
}
this.loadSuggestions = this.loadSuggestions.bind(this);
this.onSuggestionsUpdateRequested = this.onSuggestionsUpdateRequested.bind(this);
this.onChange = this.onChange.bind(this);
}

loadSuggestions(suggestionValue) {
const { filter, endpoint, onLoadSuggestions } = this.props;
const url = `${endpoint}/?search=${suggestionValue}${filter}`;
loadSuggestions(suggestionValue) {
const { filter, endpoint, onLoadSuggestions } = this.props;
const url = `${endpoint}/?search=${suggestionValue}${filter}`;

fetch(url, {
credentials: 'same-origin',
})
.then(res => res.json())
.then(json => {
this.setState({
suggestions: json.results,
loading: false,
}, () => {
onLoadSuggestions(json.results);
});
fetch(url, {
credentials: 'same-origin',
})
.then(res => res.json())
.then(json => {
this.setState({
suggestions: json.results,
loading: false,
}, () => {
onLoadSuggestions(json.results);
});
}
});
}

onSuggestionsUpdateRequested({ value }) {
const { onLoadStart } = this.props;
onLoadStart();
this.loadSuggestions(value);
}
onSuggestionsUpdateRequested({ value }) {
const { onLoadStart } = this.props;
onLoadStart();
this.loadSuggestions(value);
}

onChange(event, { newValue }) {
const { onChange } = this.props;
onChange(event, { newValue }) {
const { onChange } = this.props;

this.setState({
value: newValue,
}, () => {
onChange(newValue);
});
}
this.setState({
value: newValue,
}, () => {
onChange(newValue);
});
}

render() {
const { value, suggestions } = this.state;
render() {
const { value, suggestions } = this.state;

return (
<div>
<Autosuggest
suggestions={suggestions}
onSuggestionsUpdateRequested={this.onSuggestionsUpdateRequested}
getSuggestionValue={getSuggestionValue}
renderSuggestion={renderSuggestion}
inputProps={{
placeholder: 'Type to search',
value: value,
onChange: this.onChange,
}}
/>
</div>
);
}
return (
<div>
<Autosuggest
suggestions={suggestions}
onSuggestionsUpdateRequested={this.onSuggestionsUpdateRequested}
getSuggestionValue={getSuggestionValue}
renderSuggestion={renderSuggestion}
inputProps={{
placeholder: 'Type to search',
value: value,
onChange: this.onChange,
}}
/>
</div>
);
}
}

AutoComplete.defaultProps = defaultProps;
Expand Down
Loading

0 comments on commit bb3bdee

Please sign in to comment.