Skip to content

Commit

Permalink
Fixes hasVote and toggleVote in poll.directive and updates function c…
Browse files Browse the repository at this point in the history
…alls in the poll entries div.
  • Loading branch information
clemmy committed Apr 9, 2015
1 parent 0e4aae4 commit c49f17a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions public/js/directives/poll.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ angular.module('rallly')
$scope.participant.name = comment.author.name;
}
});
this.toggleVote = function (date, participant) {
if (!_.contains(date.possible_times[0].voted_by, participant._id)) {
date.possible_times[0].voted_by.push(participant._id); // TODO: the [0] hack will be removed when the UI supports time
this.toggleVote = function (time, participant) {
if (!_.contains(time.voted_by, participant._id)) {
time.voted_by.push(participant._id);
} else {
_.remove(date.possible_times[0].voted_by, function (voter) {
_.remove(time.voted_by, function (voter) {
return voter.toString() === participant._id.toString();
});
}
};
this.hasVote = function (date, participant) {
return _.contains(date.possible_times[0].voted_by, participant._id);
this.hasVote = function (time, participant) {
return _.contains(time.voted_by, participant._id);
};
this.delete = function (participant) {
var modal = new ConfirmModal({
Expand Down
8 changes: 4 additions & 4 deletions public/templates/directives/poll.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
<div class="time-group" ng-repeat="date in event.dates track by date._id">
<div class="cell vote-cell" ng-repeat="time in date.possible_times">
<img src="/images/[email protected]" width="16" ng-hide="editMode"
ng-if="pollCtrl.hasVote(date, participant)"/>
ng-if="pollCtrl.hasVote(time, participant)"/>
<img src="/images/[email protected]" width="8" ng-hide="editMode"
ng-if="!pollCtrl.hasVote(date, participant)"/>
<input ng-checked="pollCtrl.hasVote(date, participant)" ng-show="editMode" type="checkbox"/>
ng-if="!pollCtrl.hasVote(time, participant)"/>
<input ng-checked="pollCtrl.hasVote(time, participant)" ng-show="editMode" type="checkbox"/>

<div class="overlay" ng-show="editMode" ng-click="pollCtrl.toggleVote(date, participant)"></div>
<div class="overlay" ng-show="editMode" ng-click="pollCtrl.toggleVote(time, participant)"></div>
</div>
</div>
<div class="cell action-cell" ng-hide="event.isClosed">
Expand Down

0 comments on commit c49f17a

Please sign in to comment.