Fixed calendar display, and added date moving on calendar

This commit is contained in:
Kenneth Jao 2016-08-18 20:27:18 -04:00
parent a0357f23bb
commit bca216cf65
3 changed files with 44 additions and 28 deletions

View File

@ -663,3 +663,8 @@ input, textarea {
.fc-button:hover { .fc-button:hover {
background-color: rgba(255,255,255,0.9) !important; background-color: rgba(255,255,255,0.9) !important;
} }
.workevent span {
padding: 2%;
display: inline-block;
}

View File

@ -53,7 +53,7 @@
{{#if currMode 'calendar'}} {{#if currMode 'calendar'}}
<div id="calbg" style="{{calbg}}"></div> <div id="calbg" style="{{calbg}}"></div>
<div id="calendar" style="{{calCenter}}"> <div id="calendar" style="{{calCenter}}">
{{> fullcalendar calendarOptions id="fullcalendar"}} {{> fullcalendar calendarOptions}}
</div> </div>
{{/if}} {{/if}}
</div> </div>

View File

@ -85,6 +85,7 @@ Template.registerHelper('myClasses', () => {
array[i].thisClassWork = thisWork; array[i].thisClassWork = thisWork;
} }
Session.set("noclass",false); Session.set("noclass",false);
Session.set("calendarclasses", Meteor.user().profile.classes);
return array; return array;
} }
@ -92,7 +93,6 @@ Template.registerHelper('myClasses', () => {
Template.main.helpers({ Template.main.helpers({
schoolName() { schoolName() {
Session.set("calendarclasses", Meteor.user().profile.classes);
return " - " + Meteor.user().profile.school; return " - " + Meteor.user().profile.school;
}, },
iconColor(icon) { iconColor(icon) {
@ -143,16 +143,18 @@ Template.main.helpers({
}, },
calendarOptions() { calendarOptions() {
var events = []; var events = [];
calendarclasses = Session.get("calendarclasses"); var cursor = work.find({class: {$in: Session.get("calendarclasses")}});
var cursor = work.find({class: {$in: calendarclasses}});
cursor.forEach(function(current) { cursor.forEach(function(current) {
backgroundColor = calendarColors[current.type]; backgroundColor = workColors[current.type];
title = current.name; title = current.name;
duedate = current.dueDate.toISOString().slice(0, 10); duedate = current.dueDate.toISOString().slice(0, 10);
events.push({ events.push({
id: current._id,
start: duedate, start: duedate,
title: title, title: title,
backgroundColor: backgroundColor backgroundColor: backgroundColor,
startEditable: true,
className: "workevent",
}); });
}); });
return { return {
@ -163,6 +165,13 @@ Template.main.helpers({
month: 'Month', month: 'Month',
week: 'Week', week: 'Week',
day: 'Day' day: 'Day'
},
eventDrop: function(event, delta, revertFunc) {
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);
Session.set("serverData",current);
sendData("editWork");
} }
}; };
}, },
@ -263,14 +272,15 @@ Template.main.events({
!document.getElementById("optionsContainer").contains(event.target)) { !document.getElementById("optionsContainer").contains(event.target)) {
Session.set("sidebar", null); Session.set("sidebar", null);
} }
if(e === "overlay") { if(e === "overlay") {
closeDivFade(document.getElementsByClassName("overlay")[0]); closeDivFade(document.getElementsByClassName("overlay")[0]);
if(!Session.get("newWork")) { if(!Session.get("newWork")) {
if(getHomeworkFormData() === null) return; if(getHomeworkFormData() === null) return;
Session.set("serverData",Session.get("currentWork")); Session.set("serverData",Session.get("currentWork"));
sendData("editWork"); sendData("editWork");
} }
Session.set("newWork",null); Session.set("newWork",null);
} }
if (event.target.id !== sessval && if (event.target.id !== sessval &&
@ -279,11 +289,12 @@ Template.main.events({
!event.target.parentNode.className.includes("workOptions")) { !event.target.parentNode.className.includes("workOptions")) {
closeInput(sessval); closeInput(sessval);
} }
if (!event.target.className.includes("radio") && if (!event.target.className.includes("radio") &&
!Session.equals("radioDiv", null) && !Session.equals("radioDiv", null) &&
!event.target.parentNode.className.includes("workOptions") && !event.target.parentNode.className.includes("workOptions") &&
event.target.readOnly !== true) { event.target.readOnly !== true) {
var opnum = (parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset"))).toString(); var opnum = parseInt(Session.get("radioDiv")) - parseInt(Session.get("radioOffset"));
for (var i = 0; i < document.getElementsByClassName("workOptions").length; i++) { for (var i = 0; i < document.getElementsByClassName("workOptions").length; i++) {
try { try {
closeDivFade(document.getElementsByClassName("workOptions")[i]); closeDivFade(document.getElementsByClassName("workOptions")[i]);
@ -294,21 +305,21 @@ Template.main.events({
} }
}, },
'click .creWork' (event) { 'click .creWork' (event) {
if(event.target.className !== "creWork") { if(event.target.className !== "creWork") {
var attr = event.target.parentNode.getAttribute("classid"); var attr = event.target.parentNode.getAttribute("classid");
} else { } else {
var attr = event.target.getAttribute("classid"); var attr = event.target.getAttribute("classid");
} }
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:attr, class:attr,
dueDate:"Click here to edit...", dueDate:"Click here to edit...",
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 .change' (event) { 'click .change' (event) {
@ -458,7 +469,7 @@ Template.main.events({
'focus #workDatea' () { 'focus #workDatea' () {
$('#workDatea').datepicker({ $('#workDatea').datepicker({
format: 'DD, MM d, yyyy', format: 'DD, MM d, yyyy',
startDate: 'd', startDate: (new Date(Date.now())).toISOString().slice(0,10),
todayHighlight: true, todayHighlight: true,
autoclose: true autoclose: true