diff --git a/chromebook-checkout-meteor/client/admin.css b/chromebook-checkout-meteor/client/admin.css index 1535ebb..3857fd4 100644 --- a/chromebook-checkout-meteor/client/admin.css +++ b/chromebook-checkout-meteor/client/admin.css @@ -2,7 +2,7 @@ margin-left:100px; margin-top: 16px; } -.yield:hover { +.yield:hover, .yieldc:hover { color: #E14C2B; } .row-admin { diff --git a/chromebook-checkout-meteor/client/admin.html b/chromebook-checkout-meteor/client/admin.html index 6c78573..cd30e85 100644 --- a/chromebook-checkout-meteor/client/admin.html +++ b/chromebook-checkout-meteor/client/admin.html @@ -42,7 +42,7 @@
Add a Cart
- +
diff --git a/chromebook-checkout-meteor/client/cart.js b/chromebook-checkout-meteor/client/cart.js index cfd0578..b08f2d5 100644 --- a/chromebook-checkout-meteor/client/cart.js +++ b/chromebook-checkout-meteor/client/cart.js @@ -6,7 +6,7 @@ var statusmap = { Meteor.subscribe('carts'); -Template.chromebook.helpers({ +Template.cart.helpers({ status_class: function() { return statusmap[this.status]; }, @@ -17,4 +17,24 @@ Template.chromebook.helpers({ return moment(this.last_checkout).fromNow(); } } +}); + +Template.cart.events({ + 'click .available': function() { + if ((carts.findOne({userid: Meteor.userId()}) === undefined) + || (Roles.userIsInRole(Meteor.userId(), ['admin', 'teacher']))) { + carts.update(this._id, {$set: {status: 1}}); + carts.update(this._id, {$set: {last_checkout: new Date()}}); + carts.update(this._id, {$set: {userid: Meteor.userId()}}); + carts.update(this._id, {$set: {user: Meteor.user().profile.name}}); + } + }, + 'click .checkedout': function() { + if (Meteor.userId() === this.userid) { + carts.update(this._id, {$set: {status: 0}}); + carts.update(this._id, {$set: {last_checkout: null}}); + carts.update(this._id, {$set: {userid: null}}); + carts.update(this._id, {$set: {user: null}}); + } + } }); \ No newline at end of file diff --git a/chromebook-checkout-meteor/client/chromebook.js b/chromebook-checkout-meteor/client/chromebook.js index 02ec30a..7394c81 100644 --- a/chromebook-checkout-meteor/client/chromebook.js +++ b/chromebook-checkout-meteor/client/chromebook.js @@ -6,8 +6,6 @@ var statusmap = { Meteor.subscribe('chromebook'); -//Meteor.subscribe('user'); - Template.chromebook.helpers({ status_class: function() { return statusmap[this.status]; @@ -22,15 +20,7 @@ Template.chromebook.helpers({ }); Template.chromebook.events({ - // 'click .available, click .unavailable, click .checkedout': function() { - // if (Roles.userIsInRole(Meteor.userId(), ['admin']) - // && Router.current().route.path() === '/admin') { - // var chromebook_number = $("input[name='anumber']")[0].value; - // var chromebook_serial = $("input[name='anumber']")[0].nextElementSibling.value; - // chromebook_number = this.number; - // chromebook_serial = this.serial; - // } - // }, + 'click .available': function() { if ((Chromebooks.findOne({userid: Meteor.userId()}) === undefined) || (Roles.userIsInRole(Meteor.userId(), ['admin', 'teacher']))) {