Fix merge conflict

This commit is contained in:
Kenneth Jao 2016-09-05 00:16:26 -04:00
commit c2d06c9036
3 changed files with 319 additions and 268 deletions

View File

@ -1,3 +1,4 @@
/* jshint esversion: 6 */
import {
Template
} from 'meteor/templating';
@ -22,6 +23,18 @@ var workColors = {
"other": "#852E6D"
};
// Creates variables for due dates
var ref = {
"1 Day": 1,
"2 Days": 2,
"1 Week": 7,
"1 Month": 30,
"Never": 0,
"Yes": true,
"No": false
};
// Reactive variables.
Session.set("user",null);
Session.set("calendarClasses", null);
@ -73,7 +86,9 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
var hide = Session.get("user").preferences.timeHide;
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.mine = true;
if (found.admin === Meteor.userId()) { // If user owns this class.
@ -83,7 +98,9 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected.
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.
array[i].thisClassWork = [];
@ -92,13 +109,14 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
for (var j = 0; j < thisWork.length; j++) { // For each work in class.
if (hide !== 0) { // Time to hide isn't never.
var due = (moment(thisWork[j].dueDate))["_d"];
var offset = (moment().subtract(hide,'days'))["_d"];
var due = (moment(thisWork[j].dueDate))._d;
var offset = (moment().subtract(hide, 'days'))._d;
if (offset > due) { // If due is before hide days before today
thisWork[j] = "no";
j = 0;
}
}
if(thisWork[j] !== "no" && Session.get("user").preferences.done) { // If done filter is true
if(thisWork[j].done.indexOf(Meteor.userId()) !== -1) { // If user marked this work done.
thisWork[j] = "no";
@ -109,7 +127,7 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
}
while (thisWork.indexOf("no") !== -1) thisWork.splice(thisWork.indexOf("no"), 1); // Splice all filtered works.
for(var j = 0; j < thisWork.length; j++) {
for (j = 0; j < thisWork.length; j++) {
thisWork[j].realDate = thisWork[j].dueDate;
thisWork[j].dueDate = moment(thisWork[j].dueDate).calendar(null, {
sameDay: '[Today]',
@ -127,8 +145,8 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
}
thisWork[j].typeColor = workColors[thisWork[j].type];
thisWork[j].confirmationLength = thisWork[j].confirmations.length // Counts the number of confirmations and reports for a particular work.
thisWork[j].reportLength = thisWork[j].reports.length
thisWork[j].confirmationLength = thisWork[j].confirmations.length; // Counts the number of confirmations and reports for a particular work.
thisWork[j].reportLength = thisWork[j].reports.length;
var hoverHighlight = Session.get("classDispHover"); // Highlight/scale related class works on hover.
if (hoverHighlight !== null && hoverHighlight === found._id) {
@ -172,13 +190,11 @@ Template.main.helpers({
defaultMode() { //Loads the default display mode for user.
if(load) {
Session.set("mode",Session.get("user").preferences.mode);
load = false;
}
return;
},
bgSrc() { // Returns background.
var pic = "Backgrounds/"+themeColors[Session.get("user").preferences.theme].background;
return pic;
return "Backgrounds/"+ themeColors[Session.get("user").preferences.theme].background;
},
menuStatus() { // Status of of menu sidebar.
if (Session.equals("sidebar", "menuContainer")) {
@ -199,11 +215,8 @@ Template.main.helpers({
}
},
modeStatus(status) { // Color status of display modes.
if (Session.equals("mode",status)) {
if (!Session.equals("mode",status)) return;
return themeColors[Session.get("user").preferences.theme].highlightText;
} else {
return;
}
},
currMode(name) { // Status of display mode.
var mode = Session.get("mode");
@ -232,7 +245,9 @@ Template.main.helpers({
var works = userClasses[i].thisClassWork;
for (var j = 0; j < works.length; j++) {
var work = works[j];
var currClass = classes.findOne({_id: work.class})
var currClass = classes.findOne({
_id: work.class
});
var inRole = false;
if (Meteor.userId() === work.creator ||
@ -249,13 +264,15 @@ Template.main.helpers({
borderColor: "#444",
startEditable: inRole,
className: "workevent " + work.class,
})
});
}
}
callback(events);
},
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("-");
current.dueDate = new Date(date[0], parseInt(date[1]) - 1, date[2], 11, 59, 59);
serverData = current;
@ -263,7 +280,9 @@ Template.main.helpers({
},
eventClick: function(event, jsEvent, view) { // On-click for work.
Session.set("newWork", false);
var thisWork = work.findOne({_id:event.id})
var thisWork = work.findOne({
_id: event.id
});
Session.set("currentWork", thisWork);
var thisReadWork = formReadable(thisWork);
Session.set("currentReadableWork", thisReadWork);
@ -286,7 +305,6 @@ Template.main.helpers({
calColor() { // Sets the color of the calendar according to theme
return "color:"+themeColors[Session.get("user").preferences.theme].calendar;
},
calCreWork() { // Display instructions for creating a work.
if (Session.get("calCreWork")) return true;
return false;
@ -358,7 +376,9 @@ Template.main.helpers({
if (Session.get("newWork")) {
return true;
} 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 ||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
@ -370,7 +390,8 @@ Template.main.helpers({
if (Session.get("refetchEvents")) {
$("#fullcalendar").fullCalendar('refetchEvents');
Session.set("refetchEvents", null);
} }
}
}
});
Template.main.events({
@ -421,10 +442,11 @@ Template.main.events({
!event.target.parentNode.className.includes("workOptions") &&
!event.target.parentNode.className.includes("prefOptions") &&
event.target.readOnly !== true) {
var radio;
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
var radio = "prefOptions";
radio = "prefOptions";
} else {
var radio = "workOptions";
radio = "workOptions";
}
for (var i = 0; i < document.getElementsByClassName(radio).length; i++) {
try {
@ -479,10 +501,11 @@ Template.main.events({
Session.set("sidebar", null); // Closes all sidebars.
},
'click .creWork' (event) { // Cick add work button.
var attr;
if (event.target.className !== "creWork") {
var attr = event.target.parentNode.getAttribute("classid");
attr = event.target.parentNode.getAttribute("classid");
} else {
var attr = event.target.getAttribute("classid");
attr = event.target.getAttribute("classid");
}
Session.set("newWork", true);
Session.set("currentReadableWork", // Default readable work.
@ -493,7 +516,9 @@ Template.main.events({
description: "Click here to edit...",
type: "Click here to edit..."
});
Session.set("currentWork",{class:attr});
Session.set("currentWork", {
class: attr
});
openDivFade(document.getElementsByClassName("overlay")[0]);
},
'click .workCard' (event) { // Display work information on work card click.
@ -502,26 +527,32 @@ Template.main.events({
workid = event.target.getAttribute("workid");
Session.set("newWork", false);
var thisWork = work.findOne({_id:workid});
var thisWork = work.findOne({
_id: workid
});
Session.set("currentWork", thisWork);
var thisReadWork = formReadable(thisWork);
Session.set("currentReadableWork", thisReadWork);
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.
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
currClass.banned.indexOf(Meteor.userId()) !== -1)) {
var inputs = $('#editWork .change').css("cursor", "default");
};
}
}
openDivFade(document.getElementsByClassName("overlay")[0]);
},
// HANDLING INPUT CHANGING
'click .change' (event) { // Click changable inputs. Creates an input where the span is.
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.
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
@ -582,7 +613,9 @@ Template.main.events({
},
'click .radio' (event) { // Click dropdown input. Opens the dropdown menu.
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 ||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
currClass.moderators.indexOf(Meteor.userId()) !== -1 ||
@ -591,10 +624,11 @@ Template.main.events({
}
var op = event.target;
var radio;
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
var radio = "prefOptions";
radio = "prefOptions";
} else {
var radio = "workOptions";
radio = "workOptions";
}
try {
for (var i = 0; i < document.getElementsByClassName(radio).length; i++) { // Close any previously open menus.
@ -657,7 +691,9 @@ Template.main.events({
if (comment !== "") {
document.getElementById('workComment').value = "";
Meteor.call('addComment', [comment, workId], function(err, result) {
var thisWork = work.findOne({_id:workId});
var thisWork = work.findOne({
_id: workId
});
Session.set("currentWork", thisWork);
var thisReadWork = formReadable(thisWork);
Session.set("currentReadableWork", thisReadWork);
@ -680,7 +716,7 @@ Template.main.events({
sendData("deleteWork");
closeDivFade(document.getElementsByClassName("overlay")[0]);
},
'keyup #workComment' (event) { // Restrict length on comment.
'input #workComment' (event) { // Restrict length on comment.
var chars = 200 - event.target.value.length;
document.getElementById("commentRestrict").style.color = "#7E7E7E";
if (chars === 200) { // Don't display if nothing in comment.
@ -689,19 +725,18 @@ Template.main.events({
} else if (chars === 0) {
document.getElementById("commentRestrict").style.color = "#FF1A1A"; // Make text red if 0 characters left.
}
Session.set("commentRestrict", "Characters left: " + chars.toString());
Session.set("commentRestrict", chars.toString() + " characters left");
},
'click #markDone' () { // Click done button.
serverData = [Session.get("currentWork")._id, "done"]
serverData = [Session.get("currentWork")._id, "done"];
sendData("toggleWork");
},
'click #markConfirm' () { // Click confirm button.
serverData = [Session.get("currentWork")._id, "confirmations"]
serverData = [Session.get("currentWork")._id, "confirmations"];
sendData("toggleWork");
},
'click #markReport' () { // Click report button.
serverData = [Session.get("currentWork")._id, "reports"]
serverData = [Session.get("currentWork")._id, "reports"];
sendData("toggleWork");
},
// CLASS FILTERS
@ -715,17 +750,19 @@ Template.main.events({
Session.set("sidebar", null);
var date = calWorkDate.split("-");
var 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("currentReadableWork",
{
Session.set("currentReadableWork", {
name: "Name | Click here to edit...",
class: classid,
dueDate: getReadableDate(date),
description: "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]);
} else { // Normal clicking turns on filter.
var array = Session.get("classDisp");
@ -741,10 +778,11 @@ Template.main.events({
Session.set("classDisp", []);
},
'mouseover .sideClass' (event) { // Highlight/scale filter on-hover.
var div;
if (event.target.className !== "sideClass") {
var div = event.target.parentNode;
div = event.target.parentNode;
} else {
var div = event.target;
div = event.target;
}
while (div.getAttribute("classid") === null) div = div.parentNode;
var classid = div.getAttribute("classid");
@ -778,7 +816,9 @@ function sendData(funcName) { // Call Meteor function, and do actions after func
Meteor.call(funcName, serverData, function(err, result) {
if (funcName === "toggleWork") {
var workId = Session.get("currentWork")._id;
var thisWork = work.findOne({_id:workId});
var thisWork = work.findOne({
_id: workId
});
Session.set("currentWork", thisWork);
var thisReadWork = formReadable(thisWork);
Session.set("currentReadableWork", thisReadWork);
@ -789,10 +829,11 @@ function sendData(funcName) { // Call Meteor function, and do actions after func
function closeInput(modifyingInput) { // Close a changeable input and change it back to span.
var input = document.getElementById(modifyingInput + "a");
var span = document.getElementById(modifyingInput);
var color;
if (Session.equals("sidebar", "optionsContainer") || Session.equals("sidebar", "both")) {
var color = "#000";
color = "#000";
} else {
var color = "#8C8C8C";
color = "#8C8C8C";
}
span.style.color = color;
input.parentNode.removeChild(input);
@ -883,7 +924,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.
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.
@ -906,8 +951,14 @@ function formReadable(input) { // Makes work information readable by users.
if (!Session.get("newWork")) { // Don't display comments if user is creating work.
for (var k = 0; k < comments.length; k++) {
var re = comments.length - k - 1;
resort[re] = {"comment":comments[k].comment,"date":null,"user":null};
resort[re].user = Meteor.users.findOne({_id:comments[k].user}).profile.name;
resort[re] = {
"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();
}
input.comments = resort;

View File

@ -1,4 +1,4 @@
//meteor things
/* jshint esversion: 6 */
import {
Meteor
} from 'meteor/meteor';