remove class if non-existant
This commit is contained in:
parent
ddab8b86c2
commit
655d5821e9
@ -59,25 +59,37 @@ Template.registerHelper('overlayDim', (part) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Template.registerHelper('myClasses', () => {
|
Template.registerHelper('myClasses', () => {
|
||||||
|
var invalid = [];
|
||||||
if (Meteor.user().profile.classes === undefined || Meteor.user().profile.classes.length === 0) {
|
if (Meteor.user().profile.classes === undefined || Meteor.user().profile.classes.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
var array = [];
|
var array = [];
|
||||||
var courses = Meteor.user().profile.classes;
|
var courses = Meteor.user().profile.classes;
|
||||||
|
|
||||||
for(var i = 0; i < courses.length; i++) {
|
for(var i = 0; i < courses.length; i++) {
|
||||||
array.push(classes.findOne({_id:courses[i]}));
|
found = classes.findOne({_id:courses[i]});
|
||||||
var thisWork = work.find({class:array[i]["_id"]}).fetch();
|
if (found) {
|
||||||
|
array.push(found);
|
||||||
|
var thisWork = work.find({class: array.slice(-1)[0]}).fetch();
|
||||||
|
|
||||||
for(var j = 0; j < thisWork.length; j++) {
|
for(var j = 0; j < thisWork.length; j++) {
|
||||||
thisWork[j].dueDate = getReadableDate(thisWork[j].dueDate);
|
thisWork[j].dueDate = getReadableDate(thisWork[j].dueDate);
|
||||||
thisWork[j].typeColor = workColors[thisWork[j].type];
|
thisWork[j].typeColor = workColors[thisWork[j].type];
|
||||||
}
|
}
|
||||||
array[i].thisClassWork = thisWork;
|
array[i].thisClassWork = thisWork;
|
||||||
|
} else {
|
||||||
|
invalid.push(i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
for(var i = 0; i < invalid.length; i++) {
|
||||||
|
array.splice(invalid[i], 1);
|
||||||
|
courses.splice(invalid[i], 1);
|
||||||
|
}
|
||||||
|
userprofile = Meteor.user().profile;
|
||||||
|
userprofile.classes = courses;
|
||||||
|
Meteor.call("editProfile", userprofile);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
Template.main.helpers({
|
Template.main.helpers({
|
||||||
schoolName() {
|
schoolName() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user