Filter out already used popular suggestions

This commit is contained in:
Aaron Lindsay 2016-12-29 21:22:00 -05:00
parent 49409f84d2
commit 298b3b7cea

View File

@ -82,6 +82,21 @@ module.exports = React.createClass({
suggestion.RestaurantName = this.state.suggestion; suggestion.RestaurantName = this.state.suggestion;
suggestion.VetoingId = this.getLastSuggestion(); suggestion.VetoingId = this.getLastSuggestion();
this.props.createSuggestion(suggestion); this.props.createSuggestion(suggestion);
this.setState({
attendee: null,
suggestion: null
});
},
unusedPopularSuggestions: function() {
var props = this.props;
return props.popularSuggestions.filter(
function(suggestion){
for (var suggestionId in props.suggestions) {
if (props.suggestions[suggestionId].RestaurantName == suggestion.RestaurantName)
return false;
}
return true;
});
}, },
render: function() { render: function() {
var attendeeList = this.getAttendeeList(); var attendeeList = this.getAttendeeList();
@ -101,7 +116,7 @@ module.exports = React.createClass({
<Col xs={4}> <Col xs={4}>
<Combobox <Combobox
value={this.state.suggestion} value={this.state.suggestion}
data={this.props.popularSuggestions} data={this.unusedPopularSuggestions()}
valueField='RestaurantName' valueField='RestaurantName'
textField='RestaurantName' textField='RestaurantName'
onChange={this.onChangeSuggestion} /> onChange={this.onChangeSuggestion} />