Fixed adding work bug

This commit is contained in:
Kenneth Jao 2016-08-18 18:47:03 -04:00
parent 15f1ba4085
commit 6cac521b59

View File

@ -78,13 +78,14 @@ Template.registerHelper('myClasses', () => {
array[i].thisClassWork = thisWork;
}
Session.set("noclass",false);
console.log(array);
return array;
}
});
Template.main.helpers({
schoolName() {
Session.set("calendarclasses", Meteor.user().profile.classes);
Session.set("calendarclasses", Meteor.user().profile.classes);
return " - " + Meteor.user().profile.school;
},
iconColor(icon) {
@ -136,7 +137,7 @@ Template.main.helpers({
calendarOptions() {
var events = [];
calendarclasses = Session.get("calendarclasses");
var cursor = work.find({class: {$in: userclasses}});
var cursor = work.find({class: {$in: calendarclasses}});
cursor.forEach(function(current) {
backgroundColor = calendarColors[current.type];
title = current.name;
@ -304,13 +305,15 @@ Template.main.events({
openDivFade(document.getElementsByClassName("overlay")[0]);
},
'click .change' (event) {
if(!(Meteor.userId() === Session.get("currentWork").creator ||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
classes.findOne({_id: Session.get("currentWork")._id}).moderators.indexOf(Meteor.userId()) !== -1 ||
classes.findOne({_id: Session.get("currentWork")._id}).blockEdit.indexOf(Meteor.userId()) !== -1 ||
classes.findOne({_id: Session.get("currentWork")._id}).banned.indexOf(Meteor.userId()) !== -1
)) return;
if(!Session.get("newWork")) {
if(!(Meteor.userId() === Session.get("currentWork").creator ||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
classes.findOne({_id: Session.get("currentWork")._id}).moderators.indexOf(Meteor.userId()) !== -1 ||
classes.findOne({_id: Session.get("currentWork")._id}).blockEdit.indexOf(Meteor.userId()) !== -1 ||
classes.findOne({_id: Session.get("currentWork")._id}).banned.indexOf(Meteor.userId()) !== -1
)) return;
}
var ele = event.target;
var sessval = Session.get("modifying");
if (ele.id !== sessval && sessval !== null) closeInput(sessval);