Remainder of fix for not allowing someone to veto their own suggestion
This commit is contained in:
parent
c4ea521e52
commit
17d87a2b30
@ -37,14 +37,14 @@ module.exports = React.createClass({
|
|||||||
|
|
||||||
// Find the last suggestion, if possible
|
// Find the last suggestion, if possible
|
||||||
var lastSuggestion = null;
|
var lastSuggestion = null;
|
||||||
var lastSuggestionId = this.getLastSuggestion();
|
var lastSuggestionId = this.getLastSuggestion(props);
|
||||||
if (this.props.suggestions.hasOwnProperty(lastSuggestionId))
|
if (props.suggestions.hasOwnProperty(lastSuggestionId))
|
||||||
lastSuggestion = this.props.suggestions[lastSuggestionId];
|
lastSuggestion = props.suggestions[lastSuggestionId];
|
||||||
|
|
||||||
if (this.state.attendee == null ||
|
if (this.state.attendee == null ||
|
||||||
!props.attendees.hasOwnProperty(this.state.attendee.AttendeeId) ||
|
!props.attendees.hasOwnProperty(this.state.attendee.AttendeeId) ||
|
||||||
(lastSuggestion && lastSuggestion.AttendeeId == this.state.attendee.AttendeeId)) {
|
(lastSuggestion && lastSuggestion.AttendeeId == this.state.attendee.AttendeeId)) {
|
||||||
var attendeeList = this.getAttendeeList();
|
var attendeeList = this.getAttendeeList(props);
|
||||||
if (attendeeList.length >= 1) {
|
if (attendeeList.length >= 1) {
|
||||||
this.setState({
|
this.setState({
|
||||||
attendee: attendeeList[0]
|
attendee: attendeeList[0]
|
||||||
@ -56,23 +56,29 @@ module.exports = React.createClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getAttendeeList: function() {
|
getAttendeeList: function(props) {
|
||||||
|
if (!props)
|
||||||
|
props = this.props;
|
||||||
|
|
||||||
var attendeeList = [];
|
var attendeeList = [];
|
||||||
var lastSuggestion = null;
|
var lastSuggestion = null;
|
||||||
|
|
||||||
var lastSuggestionId = this.getLastSuggestion();
|
var lastSuggestionId = this.getLastSuggestion(props);
|
||||||
if (this.props.suggestions.hasOwnProperty(lastSuggestionId))
|
if (props.suggestions.hasOwnProperty(lastSuggestionId))
|
||||||
lastSuggestion = this.props.suggestions[lastSuggestionId];
|
lastSuggestion = props.suggestions[lastSuggestionId];
|
||||||
|
|
||||||
for (var attendeeId in this.props.attendees) {
|
for (var attendeeId in props.attendees) {
|
||||||
if (!lastSuggestion || lastSuggestion.AttendeeId != parseInt(attendeeId, 10))
|
if (!lastSuggestion || lastSuggestion.AttendeeId != parseInt(attendeeId, 10))
|
||||||
attendeeList.push(this.props.attendees[attendeeId]);
|
attendeeList.push(props.attendees[attendeeId]);
|
||||||
}
|
}
|
||||||
return attendeeList;
|
return attendeeList;
|
||||||
},
|
},
|
||||||
getLastSuggestion: function() {
|
getLastSuggestion: function(props) {
|
||||||
|
if (!props)
|
||||||
|
props = this.props;
|
||||||
|
|
||||||
var lastSuggestion = -1;
|
var lastSuggestion = -1;
|
||||||
for (var suggestionId in this.props.suggestions) {
|
for (var suggestionId in props.suggestions) {
|
||||||
if (suggestionId > lastSuggestion)
|
if (suggestionId > lastSuggestion)
|
||||||
lastSuggestion = suggestionId;
|
lastSuggestion = suggestionId;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user