suggestions: Properly set VetoingId

This commit is contained in:
Aaron Lindsay 2017-01-07 08:39:22 -05:00
parent 9040e4fd9f
commit 908e10736a
2 changed files with 8 additions and 1 deletions

View File

@ -103,7 +103,11 @@ module.exports = React.createClass({
var suggestion = new Suggestion(); var suggestion = new Suggestion();
suggestion.AttendeeId = this.state.attendee.AttendeeId; suggestion.AttendeeId = this.state.attendee.AttendeeId;
suggestion.RestaurantName = this.state.suggestion; suggestion.RestaurantName = this.state.suggestion;
suggestion.VetoingId = this.getLastSuggestion(); var lastSuggestionIndex = this.getLastSuggestion();
if (lastSuggestionIndex > -1)
suggestion.VetoingId = this.props.suggestions[lastSuggestionIndex].SuggestionId;
else
suggestion.VetoingId = -1;
this.props.createSuggestion(suggestion); this.props.createSuggestion(suggestion);
this.setState({ this.setState({
attendee: null, attendee: null,

View File

@ -138,6 +138,7 @@ function Suggestion() {
Suggestion.prototype.toJSON = function() { Suggestion.prototype.toJSON = function() {
var json_obj = {}; var json_obj = {};
json_obj.SuggestionId = this.SuggestionId; json_obj.SuggestionId = this.SuggestionId;
json_obj.VetoingId = this.VetoingId;
json_obj.AttendeeId = this.AttendeeId; json_obj.AttendeeId = this.AttendeeId;
json_obj.RestaurantName = this.RestaurantName; json_obj.RestaurantName = this.RestaurantName;
return JSON.stringify(json_obj); return JSON.stringify(json_obj);
@ -148,6 +149,8 @@ Suggestion.prototype.fromJSON = function(json_input) {
if (json_obj.hasOwnProperty("SuggestionId")) if (json_obj.hasOwnProperty("SuggestionId"))
this.SuggestionId = json_obj.SuggestionId; this.SuggestionId = json_obj.SuggestionId;
if (json_obj.hasOwnProperty("VetoingId"))
this.VetoingId = json_obj.VetoingId;
if (json_obj.hasOwnProperty("AttendeeId")) if (json_obj.hasOwnProperty("AttendeeId"))
this.AttendeeId = json_obj.AttendeeId; this.AttendeeId = json_obj.AttendeeId;
if (json_obj.hasOwnProperty("RestaurantName")) if (json_obj.hasOwnProperty("RestaurantName"))