Fixed the helper errors that appeared, fixed #3

This commit is contained in:
Kenneth Jao 2016-08-17 23:39:51 -04:00
parent 09e29aea96
commit 6fc1ec14c9
3 changed files with 31 additions and 13 deletions

View File

@ -4,11 +4,6 @@ import {
import './main.html'; import './main.html';
Meteor.subscribe('schools');
Meteor.subscribe('classes');
Meteor.subscribe('work');
Meteor.subscribe('users');
var openValues = { var openValues = {
"menu": "-25%", "menu": "-25%",
"options": "-20%" "options": "-20%"
@ -178,9 +173,11 @@ Template.main.helpers({
return "width:"+w.toString()+"px;height:"+h.toString()+"px;margin-left:"+-0.5*w.toString()+"px;margin-top:"+-0.5*h.toString()+"px"; return "width:"+w.toString()+"px;height:"+h.toString()+"px;margin-left:"+-0.5*w.toString()+"px;margin-top:"+-0.5*h.toString()+"px";
}, },
work(value) { work(value) {
if(Session.get("currentWork") === null) return;
return Session.get("currentReadableWork")[value]; return Session.get("currentReadableWork")[value];
}, },
workType() { workType() {
if(Session.get("currentWork") === null) return;
type = Session.get("currentWork").type; type = Session.get("currentWork").type;
if(type.includes("edit")) { if(type.includes("edit")) {
return; return;

View File

@ -195,6 +195,7 @@ Template.profile.helpers({
return Session.get("confirmText"); return Session.get("confirmText");
}, },
selectedClass(val) { selectedClass(val) {
if(Session.get("selectedClass") === null) return;
var usertype = ["moderators","banned"]; var usertype = ["moderators","banned"];
var attribute = Session.get("selectClassId"); var attribute = Session.get("selectClassId");
var array = classes.findOne({_id:attribute}); var array = classes.findOne({_id:attribute});

View File

@ -1,7 +1,17 @@
Router.route('/', function() { Router.route('/', {
waitOn: function() {
if (!Meteor.userId()) { if (!Meteor.userId()) {
this.redirect('/login'); this.redirect('/login');
} else { } else {
return [
Meteor.subscribe('classes',this.params._id),
Meteor.subscribe('schools',this.params._id),
Meteor.subscribe('work',this.params._id),
Meteor.subscribe('users',this.params._id)
];
}
},
action: function() {
this.render("main"); this.render("main");
} }
}); });
@ -16,10 +26,20 @@ Router.route('/login', function() {
} }
}); });
Router.route('/profile', function() { Router.route('/profile', {
waitOn: function() {
if (!Meteor.userId()) { if (!Meteor.userId()) {
this.redirect("/login"); this.redirect('/login');
} else { } else {
return [
Meteor.subscribe('classes',this.params._id),
Meteor.subscribe('schools',this.params._id),
Meteor.subscribe('work',this.params._id),
Meteor.subscribe('users',this.params._id)
];
}
},
action: function() {
this.render("profile"); this.render("profile");
} }
}); });