fixed carts(mostly)
This commit is contained in:
parent
6926ff3b33
commit
ccbf2cde10
@ -2,7 +2,7 @@
|
||||
margin-left:100px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
.yield:hover {
|
||||
.yield:hover, .yieldc:hover {
|
||||
color: #E14C2B;
|
||||
}
|
||||
.row-admin {
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
<h6>Add a Cart</h6> <!-- Adding Carts -->
|
||||
<form class="new-task">
|
||||
<input type="text" name="acnumber" placeholder="Cart Number (ex. A)" class="submission"/>
|
||||
<input type="submit" value="Submit" class="add" />
|
||||
<input type="submit" value="Submit" class="add addc" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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}});
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -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']))) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user