diff --git a/js/components/NewSuggestion.js b/js/components/NewSuggestion.js index 45a0534..b6941dd 100644 --- a/js/components/NewSuggestion.js +++ b/js/components/NewSuggestion.js @@ -103,7 +103,11 @@ module.exports = React.createClass({ var suggestion = new Suggestion(); suggestion.AttendeeId = this.state.attendee.AttendeeId; 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.setState({ attendee: null, diff --git a/js/models.js b/js/models.js index ae5e21b..8ba2eb2 100644 --- a/js/models.js +++ b/js/models.js @@ -138,6 +138,7 @@ function Suggestion() { Suggestion.prototype.toJSON = function() { var json_obj = {}; json_obj.SuggestionId = this.SuggestionId; + json_obj.VetoingId = this.VetoingId; json_obj.AttendeeId = this.AttendeeId; json_obj.RestaurantName = this.RestaurantName; return JSON.stringify(json_obj); @@ -148,6 +149,8 @@ Suggestion.prototype.fromJSON = function(json_input) { if (json_obj.hasOwnProperty("SuggestionId")) this.SuggestionId = json_obj.SuggestionId; + if (json_obj.hasOwnProperty("VetoingId")) + this.VetoingId = json_obj.VetoingId; if (json_obj.hasOwnProperty("AttendeeId")) this.AttendeeId = json_obj.AttendeeId; if (json_obj.hasOwnProperty("RestaurantName"))