web-beautify filter
This commit is contained in:
parent
b98f229c0b
commit
8eaaff37f4
@ -81,7 +81,9 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
|
|||||||
var hide = Meteor.user().profile.preferences.timeHide;
|
var hide = Meteor.user().profile.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({_id:courses[i]});
|
found = classes.findOne({
|
||||||
|
_id: courses[i]
|
||||||
|
});
|
||||||
found.subscribers = found.subscribers.length;
|
found.subscribers = found.subscribers.length;
|
||||||
found.mine = true;
|
found.mine = true;
|
||||||
if (found.admin === Meteor.userId()) { // If user owns this class.
|
if (found.admin === Meteor.userId()) { // If user owns this class.
|
||||||
@ -91,7 +93,9 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
|
|||||||
if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected.
|
if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected.
|
||||||
array.push(found);
|
array.push(found);
|
||||||
|
|
||||||
var thisWork = work.find({class: courses[i]}).fetch();
|
var thisWork = work.find({
|
||||||
|
class: courses[i]
|
||||||
|
}).fetch();
|
||||||
|
|
||||||
if (classDisp.length !== 0 && classDisp.indexOf(found._id) === -1) { // Filter classes based on filter.
|
if (classDisp.length !== 0 && classDisp.indexOf(found._id) === -1) { // Filter classes based on filter.
|
||||||
array[i].thisClassWork = [];
|
array[i].thisClassWork = [];
|
||||||
@ -242,7 +246,9 @@ Template.main.helpers({
|
|||||||
var works = userClasses[i].thisClassWork;
|
var works = userClasses[i].thisClassWork;
|
||||||
for (var j = 0; j < works.length; j++) {
|
for (var j = 0; j < works.length; j++) {
|
||||||
var work = works[j];
|
var work = works[j];
|
||||||
var currClass = classes.findOne({_id: work.class});
|
var currClass = classes.findOne({
|
||||||
|
_id: work.class
|
||||||
|
});
|
||||||
var inRole = false;
|
var inRole = false;
|
||||||
|
|
||||||
if (Meteor.userId() === work.creator ||
|
if (Meteor.userId() === work.creator ||
|
||||||
@ -265,7 +271,9 @@ Template.main.helpers({
|
|||||||
callback(events);
|
callback(events);
|
||||||
},
|
},
|
||||||
eventDrop: function(event, delta, revertFunc) { // When user drops from click-dragging.
|
eventDrop: function(event, delta, revertFunc) { // When user drops from click-dragging.
|
||||||
var current = work.findOne({_id:event.id});
|
var current = work.findOne({
|
||||||
|
_id: event.id
|
||||||
|
});
|
||||||
var date = event.start.format().split("-");
|
var date = event.start.format().split("-");
|
||||||
current.dueDate = new Date(date[0], parseInt(date[1]) - 1, date[2], 11, 59, 59);
|
current.dueDate = new Date(date[0], parseInt(date[1]) - 1, date[2], 11, 59, 59);
|
||||||
serverData = current;
|
serverData = current;
|
||||||
@ -273,7 +281,9 @@ Template.main.helpers({
|
|||||||
},
|
},
|
||||||
eventClick: function(event, jsEvent, view) { // On-click for work.
|
eventClick: function(event, jsEvent, view) { // On-click for work.
|
||||||
Session.set("newWork", false);
|
Session.set("newWork", false);
|
||||||
var thisWork = work.findOne({_id:event.id});
|
var thisWork = work.findOne({
|
||||||
|
_id: event.id
|
||||||
|
});
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
var thisReadWork = formReadable(thisWork);
|
var thisReadWork = formReadable(thisWork);
|
||||||
Session.set("currentReadableWork", thisReadWork);
|
Session.set("currentReadableWork", thisReadWork);
|
||||||
@ -372,7 +382,9 @@ Template.main.helpers({
|
|||||||
if (Session.get("newWork")) {
|
if (Session.get("newWork")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
var currClass = classes.findOne({_id: Session.get("currentWork")["class"]});
|
var currClass = classes.findOne({
|
||||||
|
_id: Session.get("currentWork")["class"]
|
||||||
|
});
|
||||||
if (Meteor.userId() === Session.get("currentWork").creator ||
|
if (Meteor.userId() === Session.get("currentWork").creator ||
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
@ -384,7 +396,8 @@ Template.main.helpers({
|
|||||||
if (Session.get("refetchEvents")) {
|
if (Session.get("refetchEvents")) {
|
||||||
$("#fullcalendar").fullCalendar('refetchEvents');
|
$("#fullcalendar").fullCalendar('refetchEvents');
|
||||||
Session.set("refetchEvents", null);
|
Session.set("refetchEvents", null);
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.main.events({
|
Template.main.events({
|
||||||
@ -509,7 +522,9 @@ Template.main.events({
|
|||||||
description: "Click here to edit...",
|
description: "Click here to edit...",
|
||||||
type: "Click here to edit..."
|
type: "Click here to edit..."
|
||||||
});
|
});
|
||||||
Session.set("currentWork",{class:attr});
|
Session.set("currentWork", {
|
||||||
|
class: attr
|
||||||
|
});
|
||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
},
|
},
|
||||||
'click .workCard' (event) { // Display work information on work card click.
|
'click .workCard' (event) { // Display work information on work card click.
|
||||||
@ -518,13 +533,17 @@ Template.main.events({
|
|||||||
workid = event.target.getAttribute("workid");
|
workid = event.target.getAttribute("workid");
|
||||||
|
|
||||||
Session.set("newWork", false);
|
Session.set("newWork", false);
|
||||||
var thisWork = work.findOne({_id:workid});
|
var thisWork = work.findOne({
|
||||||
|
_id: workid
|
||||||
|
});
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
var thisReadWork = formReadable(thisWork);
|
var thisReadWork = formReadable(thisWork);
|
||||||
Session.set("currentReadableWork", thisReadWork);
|
Session.set("currentReadableWork", thisReadWork);
|
||||||
|
|
||||||
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
||||||
var currClass = classes.findOne({_id: Session.get("currentWork")["class"]});
|
var currClass = classes.findOne({
|
||||||
|
_id: Session.get("currentWork")["class"]
|
||||||
|
});
|
||||||
if (!(Meteor.userId() === Session.get("currentWork").creator || // If user has permission.
|
if (!(Meteor.userId() === Session.get("currentWork").creator || // If user has permission.
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
@ -537,7 +556,9 @@ Template.main.events({
|
|||||||
// 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.
|
||||||
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
||||||
var currClass = classes.findOne({_id: Session.get("currentWork")["class"]});
|
var currClass = classes.findOne({
|
||||||
|
_id: Session.get("currentWork")["class"]
|
||||||
|
});
|
||||||
if (!(Meteor.userId() === Session.get("currentWork").creator || // If user has permission.
|
if (!(Meteor.userId() === Session.get("currentWork").creator || // If user has permission.
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
@ -598,7 +619,9 @@ Template.main.events({
|
|||||||
},
|
},
|
||||||
'click .radio' (event) { // Click dropdown input. Opens the dropdown menu.
|
'click .radio' (event) { // Click dropdown input. Opens the dropdown menu.
|
||||||
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
if (!Session.get("newWork") && !document.getElementById("optionsContainer").contains(event.target)) {
|
||||||
var currClass = classes.findOne({_id: Session.get("currentWork")["class"]});
|
var currClass = classes.findOne({
|
||||||
|
_id: Session.get("currentWork")["class"]
|
||||||
|
});
|
||||||
if (!(Meteor.userId() === Session.get("currentWork").creator ||
|
if (!(Meteor.userId() === Session.get("currentWork").creator ||
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
|
||||||
@ -674,7 +697,9 @@ Template.main.events({
|
|||||||
if (comment !== "") {
|
if (comment !== "") {
|
||||||
document.getElementById('workComment').value = "";
|
document.getElementById('workComment').value = "";
|
||||||
Meteor.call('addComment', [comment, workId], function(err, result) {
|
Meteor.call('addComment', [comment, workId], function(err, result) {
|
||||||
var thisWork = work.findOne({_id:workId});
|
var thisWork = work.findOne({
|
||||||
|
_id: workId
|
||||||
|
});
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
var thisReadWork = formReadable(thisWork);
|
var thisReadWork = formReadable(thisWork);
|
||||||
Session.set("currentReadableWork", thisReadWork);
|
Session.set("currentReadableWork", thisReadWork);
|
||||||
@ -733,15 +758,17 @@ Template.main.events({
|
|||||||
var date = calWorkDate.split("-");
|
var date = calWorkDate.split("-");
|
||||||
date = new Date(date[0], parseInt(date[1]) - 1, date[2], 11, 59, 59);
|
date = new Date(date[0], parseInt(date[1]) - 1, date[2], 11, 59, 59);
|
||||||
Session.set("newWork", true);
|
Session.set("newWork", true);
|
||||||
Session.set("currentReadableWork",
|
Session.set("currentReadableWork", {
|
||||||
{
|
|
||||||
name: "Name | Click here to edit...",
|
name: "Name | Click here to edit...",
|
||||||
class: classid,
|
class: classid,
|
||||||
dueDate: getReadableDate(date),
|
dueDate: getReadableDate(date),
|
||||||
description: "Click here to edit...",
|
description: "Click here to edit...",
|
||||||
type: "Click here to edit..."
|
type: "Click here to edit..."
|
||||||
});
|
});
|
||||||
Session.set("currentWork",{class:classid,dueDate:date});
|
Session.set("currentWork", {
|
||||||
|
class: classid,
|
||||||
|
dueDate: date
|
||||||
|
});
|
||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
} else { // Normal clicking turns on filter.
|
} else { // Normal clicking turns on filter.
|
||||||
var array = Session.get("classDisp");
|
var array = Session.get("classDisp");
|
||||||
@ -795,7 +822,9 @@ function sendData(funcName) { // Call Meteor function, and do actions after func
|
|||||||
Meteor.call(funcName, serverData, function(err, result) {
|
Meteor.call(funcName, serverData, function(err, result) {
|
||||||
if (funcName === "toggleWork") {
|
if (funcName === "toggleWork") {
|
||||||
var workId = Session.get("currentWork")._id;
|
var workId = Session.get("currentWork")._id;
|
||||||
var thisWork = work.findOne({_id:workId});
|
var thisWork = work.findOne({
|
||||||
|
_id: workId
|
||||||
|
});
|
||||||
Session.set("currentWork", thisWork);
|
Session.set("currentWork", thisWork);
|
||||||
var thisReadWork = formReadable(thisWork);
|
var thisReadWork = formReadable(thisWork);
|
||||||
Session.set("currentReadableWork", thisReadWork);
|
Session.set("currentReadableWork", thisReadWork);
|
||||||
@ -901,7 +930,11 @@ function formReadable(input) { // Makes work information readable by users.
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < input.done.length; i++) { // Display users who marked as done.
|
for (var i = 0; i < input.done.length; i++) { // Display users who marked as done.
|
||||||
input.done[i] = {"user":Meteor.users.findOne({_id:input.done[i]}).profile.name};
|
input.done[i] = {
|
||||||
|
"user": Meteor.users.findOne({
|
||||||
|
_id: input.done[i]
|
||||||
|
}).profile.name
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.confirmations.indexOf(Meteor.userId()) !== -1) { // If user confirmed.
|
if (input.confirmations.indexOf(Meteor.userId()) !== -1) { // If user confirmed.
|
||||||
@ -924,8 +957,14 @@ function formReadable(input) { // Makes work information readable by users.
|
|||||||
if (!Session.get("newWork")) { // Don't display comments if user is creating work.
|
if (!Session.get("newWork")) { // Don't display comments if user is creating work.
|
||||||
for (var k = 0; k < comments.length; k++) {
|
for (var k = 0; k < comments.length; k++) {
|
||||||
var re = comments.length - k - 1;
|
var re = comments.length - k - 1;
|
||||||
resort[re] = {"comment":comments[k].comment,"date":null,"user":null};
|
resort[re] = {
|
||||||
resort[re].user = Meteor.users.findOne({_id:comments[k].user}).profile.name;
|
"comment": comments[k].comment,
|
||||||
|
"date": null,
|
||||||
|
"user": null
|
||||||
|
};
|
||||||
|
resort[re].user = Meteor.users.findOne({
|
||||||
|
_id: comments[k].user
|
||||||
|
}).profile.name;
|
||||||
resort[re].date = moment(comments[k].date).fromNow();
|
resort[re].date = moment(comments[k].date).fromNow();
|
||||||
}
|
}
|
||||||
input.comments = resort;
|
input.comments = resort;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user