32 lines
657 B
JavaScript
Raw Normal View History

2015-01-11 20:41:35 -05:00
var statusmap = {
0: "available",
1: "checkedout",
2: "unavailable"
}
Meteor.subscribe('carts');
2015-01-12 21:05:09 -05:00
Template.cart.helpers({
2015-01-11 20:41:35 -05:00
status_class: function() {
return statusmap[this.status];
},
time_ago: function() {
if (this.last_checkout === null) {
return "";
} else {
return moment(this.last_checkout).fromNow();
}
},
url: function() {
return Router.current().originalUrl.replace("http://cbook.meteor.com/", "");
2015-01-11 20:41:35 -05:00
}
2015-01-12 21:05:09 -05:00
});
Template.cart.events({
'click .available': function() {
2015-02-07 11:27:10 -05:00
Meteor.call('availablecart', this);
2015-01-12 21:05:09 -05:00
},
'click .checkedout': function() {
2015-02-07 11:27:10 -05:00
Meteor.call('checkedoutcart', this);
2015-01-12 21:05:09 -05:00
}
2015-01-11 20:41:35 -05:00
});