personal work added
This commit is contained in:
parent
8d46da7f28
commit
3dd703f103
@ -98,17 +98,28 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
|
|||||||
var hide = Session.get("user").preferences.timeHide;
|
var hide = Session.get("user").preferences.timeHide;
|
||||||
|
|
||||||
for (var i = 0; i < courses.length; i++) { // For each user class.
|
for (var i = 0; i < courses.length; i++) { // For each user class.
|
||||||
found = classes.findOne({
|
if (courses[i] === Meteor.userId()) {
|
||||||
_id: courses[i]
|
found = {
|
||||||
});
|
_id: courses[i],
|
||||||
found.subscribers = found.subscribers.length;
|
name: "Personal",
|
||||||
found.mine = true;
|
subscribers: 1,
|
||||||
if (found.admin === Meteor.userId()) { // If user owns this class.
|
mine: false,
|
||||||
found.box = " owned";
|
box: " owned"
|
||||||
found.mine = false;
|
};
|
||||||
|
array.push(found);
|
||||||
|
} else {
|
||||||
|
found = classes.findOne({
|
||||||
|
_id: courses[i]
|
||||||
|
});
|
||||||
|
found.subscribers = found.subscribers.length;
|
||||||
|
found.mine = true;
|
||||||
|
if (found.admin === Meteor.userId()) { // If user owns this class.
|
||||||
|
found.box = " owned";
|
||||||
|
found.mine = false;
|
||||||
|
}
|
||||||
|
if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected.
|
||||||
|
array.push(found);
|
||||||
}
|
}
|
||||||
if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected.
|
|
||||||
array.push(found);
|
|
||||||
|
|
||||||
var thisWork = work.find({
|
var thisWork = work.find({
|
||||||
class: courses[i]
|
class: courses[i]
|
||||||
@ -300,7 +311,7 @@ Template.main.helpers({
|
|||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
},
|
},
|
||||||
eventMouseover: function (event, jsEvent, view) {
|
eventMouseover: function (event, jsEvent, view) {
|
||||||
this.style.boxShadow = "inset 0 0 0 99999px rgba(255,255,255,0.2)"
|
this.style.boxShadow = "inset 0 0 0 99999px rgba(255,255,255,0.2)";
|
||||||
},
|
},
|
||||||
eventMouseout: function (event, jsEvent, view) {
|
eventMouseout: function (event, jsEvent, view) {
|
||||||
this.style.boxShadow = "";
|
this.style.boxShadow = "";
|
||||||
@ -577,7 +588,7 @@ Template.main.events({
|
|||||||
area.value = "";
|
area.value = "";
|
||||||
Session.set("commentRestrict",null);
|
Session.set("commentRestrict",null);
|
||||||
},750);
|
},750);
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
// HANDLING INPUT CHANGING
|
// HANDLING INPUT CHANGING
|
||||||
'click .change' (event) { // Click changable inputs. Creates an input where the span is.
|
'click .change' (event) { // Click changable inputs. Creates an input where the span is.
|
||||||
@ -772,6 +783,7 @@ Template.main.events({
|
|||||||
},
|
},
|
||||||
'click #markDone' () { // Click done button.
|
'click #markDone' () { // Click done button.
|
||||||
serverData = [Session.get("currentWork")._id, "done"];
|
serverData = [Session.get("currentWork")._id, "done"];
|
||||||
|
console.log(serverData);
|
||||||
sendData("toggleWork");
|
sendData("toggleWork");
|
||||||
},
|
},
|
||||||
'click #markConfirm' () { // Click confirm button.
|
'click #markConfirm' () { // Click confirm button.
|
||||||
|
|||||||
@ -88,7 +88,7 @@ Meteor.publish('work', function() {
|
|||||||
return work.find({
|
return work.find({
|
||||||
// Only return work of enrolled classes
|
// Only return work of enrolled classes
|
||||||
class: {
|
class: {
|
||||||
$in: userprofile.profile.classes.concat(this.userId)
|
$in: userprofile.profile.classes
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -352,15 +352,14 @@ Meteor.methods({
|
|||||||
var currentclass = classes.findOne({
|
var currentclass = classes.findOne({
|
||||||
_id: currentwork.class
|
_id: currentwork.class
|
||||||
});
|
});
|
||||||
var authorized = currentclass.moderators.concat(currentclass.admin);
|
|
||||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
||||||
work.update({
|
work.update({
|
||||||
_id: currentwork._id
|
_id: currentwork._id
|
||||||
}, {
|
}, {
|
||||||
$set: change
|
$set: change
|
||||||
});
|
});
|
||||||
} else if ((_.contains(authorized, Meteor.userId()) ||
|
} else if ((currentwork.class === Meteor.userId() ||
|
||||||
currentwork.class === Meteor.userId() ||
|
_.contains(currentclass.moderators.concat(currentclass.admin), Meteor.userId()) ||
|
||||||
Meteor.userId() === currentwork.creator) &&
|
Meteor.userId() === currentwork.creator) &&
|
||||||
change.name.length <= 50 && change.description.length <= 150 &&
|
change.name.length <= 50 && change.description.length <= 150 &&
|
||||||
change.dueDate instanceof Date && change.dueDate.getTime() >= ref &&
|
change.dueDate instanceof Date && change.dueDate.getTime() >= ref &&
|
||||||
@ -390,8 +389,9 @@ Meteor.methods({
|
|||||||
});
|
});
|
||||||
var user = Meteor.userId();
|
var user = Meteor.userId();
|
||||||
if (typeof comment === "string" && comment.length <= 200 &&
|
if (typeof comment === "string" && comment.length <= 200 &&
|
||||||
_.contains(currentclass.subscribers, Meteor.userId()) &&
|
(workobject.class === Meteor.userId() ||
|
||||||
!_.contains(currentclass.banned, Meteor.userId())) {
|
(_.contains(currentclass.subscribers, Meteor.userId()) &&
|
||||||
|
!_.contains(currentclass.banned, Meteor.userId())))) {
|
||||||
var commentInfo = {
|
var commentInfo = {
|
||||||
"comment": input[0],
|
"comment": input[0],
|
||||||
"user": user,
|
"user": user,
|
||||||
@ -417,7 +417,7 @@ Meteor.methods({
|
|||||||
var currentclass = classes.findOne({
|
var currentclass = classes.findOne({
|
||||||
_id: workobject.class
|
_id: workobject.class
|
||||||
});
|
});
|
||||||
if (_.contains(currentclass.subscribers, Meteor.userId()) && _.contains(["confirmations", "reports", "done"], input[1])) {
|
if ((Meteor.userId() === workobject.class || _.contains(currentclass.subscribers, Meteor.userId())) && _.contains(["confirmations", "reports", "done"], input[1])) {
|
||||||
var userindex = workobject[input[1]].indexOf(Meteor.userId());
|
var userindex = workobject[input[1]].indexOf(Meteor.userId());
|
||||||
if (userindex === -1) {
|
if (userindex === -1) {
|
||||||
workobject[input[1]] = workobject[input[1]].concat(Meteor.userId());
|
workobject[input[1]] = workobject[input[1]].concat(Meteor.userId());
|
||||||
@ -447,9 +447,9 @@ Meteor.methods({
|
|||||||
var currentclass = classes.findOne({
|
var currentclass = classes.findOne({
|
||||||
_id: currentwork.class
|
_id: currentwork.class
|
||||||
});
|
});
|
||||||
var authorized = currentclass.moderators.concat(currentclass.admin);
|
|
||||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
_.contains(authorized, Meteor.userId()) || Meteor.userId() === currentwork.class) {
|
currentwork.class === Meteor.userId() ||
|
||||||
|
_.contains(currentclass.moderators.concat(currentclass.admin), Meteor.userId()) || Meteor.userId() === currentwork.class) {
|
||||||
work.remove({
|
work.remove({
|
||||||
_id: workId
|
_id: workId
|
||||||
});
|
});
|
||||||
@ -504,7 +504,7 @@ Meteor.methods({
|
|||||||
}).profile;
|
}).profile;
|
||||||
current.banner = "/Banners/defaultcover.jpg";
|
current.banner = "/Banners/defaultcover.jpg";
|
||||||
current.avatar = "/Avatars/" + (Math.floor(Math.random() * 10) + 1).toString() + ".png";
|
current.avatar = "/Avatars/" + (Math.floor(Math.random() * 10) + 1).toString() + ".png";
|
||||||
current.classes = [];
|
current.classes = [userId];
|
||||||
current.preferences = {
|
current.preferences = {
|
||||||
"theme": "light",
|
"theme": "light",
|
||||||
"mode": "classes",
|
"mode": "classes",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user