Skip to content

Commit

Permalink
Step 17.39: Add checking methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kisiela authored and DAB0mB committed Dec 14, 2016
1 parent e362c34 commit 8bdb432
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions imports/ui/components/partyRsvp/partyRsvp.js
@@ -1,5 +1,6 @@
import angular from 'angular';
import angularMeteor from 'angular-meteor';
import _ from 'underscore';

import { Meteor } from 'meteor/meteor';

Expand All @@ -9,14 +10,23 @@ class PartyRsvp {
yes() {
this.answer('yes');
}
isYes() {
return this.isAnswer('yes');
}

maybe() {
this.answer('maybe');
}
isMaybe() {
return this.isAnswer('maybe');
}

no() {
this.answer('no');
}
isNo() {
return this.isAnswer('no');
}

answer(answer) {
Meteor.call('rsvp', this.party._id, answer, (error) => {
Expand All @@ -27,6 +37,14 @@ class PartyRsvp {
}
});
}
isAnswer(answer) {
if(this.party) {
return !!_.findWhere(this.party.rsvps, {
user: Meteor.userId(),
rsvp: answer
});
}
}
}

const name = 'partyRsvp';
Expand Down

0 comments on commit 8bdb432

Please sign in to comment.