Bug fixes
This commit is contained in:
parent
00ded2965d
commit
57aeb4d34b
@ -39,6 +39,7 @@ Session.set("sidebar", null);
|
|||||||
Session.set("mode", null); // Change to user preferences
|
Session.set("mode", null); // Change to user preferences
|
||||||
Session.set("newWork",null);
|
Session.set("newWork",null);
|
||||||
Session.set("currentWork",null);
|
Session.set("currentWork",null);
|
||||||
|
Session.set("currentReadableWork",null);
|
||||||
Session.set("modifying",null);
|
Session.set("modifying",null);
|
||||||
Session.set("radioDiv",null);
|
Session.set("radioDiv",null);
|
||||||
Session.set("radioOffset",null);
|
Session.set("radioOffset",null);
|
||||||
@ -169,7 +170,7 @@ Template.main.helpers({
|
|||||||
return "width:"+w.toString()+"px;height:"+h.toString()+"px;margin-left:"+-.5*w.toString()+"px;margin-top:"+-.5*h.toString()+"px";
|
return "width:"+w.toString()+"px;height:"+h.toString()+"px;margin-left:"+-.5*w.toString()+"px;margin-top:"+-.5*h.toString()+"px";
|
||||||
},
|
},
|
||||||
work(value) {
|
work(value) {
|
||||||
return Session.get("currentWork")[value];
|
return Session.get("currentReadableWork")[value];
|
||||||
},
|
},
|
||||||
workType() {
|
workType() {
|
||||||
type = Session.get("currentWork").type;
|
type = Session.get("currentWork").type;
|
||||||
@ -179,9 +180,6 @@ Template.main.helpers({
|
|||||||
return workColors[type];
|
return workColors[type];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cWorkColor(type) {
|
|
||||||
return workColors["type"];
|
|
||||||
},
|
|
||||||
newWork() {
|
newWork() {
|
||||||
return Session.get("newWork");
|
return Session.get("newWork");
|
||||||
},
|
},
|
||||||
@ -189,9 +187,9 @@ Template.main.helpers({
|
|||||||
if(Session.get("newWork")) {
|
if(Session.get("newWork")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(Meteor.userId() === work.findOne({_id: Session.get("workId")}).creator ||
|
if(Meteor.userId() === Session.get("currentWork").creator ||
|
||||||
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin']) ||
|
||||||
classes.findOne({_id: work.findOne({_id: Session.get("workId")}).class}).moderators.indexOf(Meteor.userId()) !== -1
|
classes.findOne({_id: Session.get("currentWork")._id}).moderators.indexOf(Meteor.userId()) !== -1
|
||||||
) return true;
|
) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,10 +254,8 @@ Template.main.events({
|
|||||||
Session.set("serverData",getHomeworkFormData())
|
Session.set("serverData",getHomeworkFormData())
|
||||||
sendData("editWork");
|
sendData("editWork");
|
||||||
} else {
|
} else {
|
||||||
clearHomeworkForm();
|
|
||||||
}
|
}
|
||||||
Session.set("newWork",null);
|
Session.set("newWork",null);
|
||||||
Session.set("currentWork",null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.target.id !== sessval &&
|
if (event.target.id !== sessval &&
|
||||||
@ -289,7 +285,7 @@ Template.main.events({
|
|||||||
var attr = event.target.getAttribute("classid");
|
var attr = event.target.getAttribute("classid");
|
||||||
}
|
}
|
||||||
Session.set("newWork", true);
|
Session.set("newWork", true);
|
||||||
Session.set("currentWork",
|
Session.set("currentReadableWork",
|
||||||
{
|
{
|
||||||
name:"Name | Click here to edit...",
|
name:"Name | Click here to edit...",
|
||||||
class:attr,
|
class:attr,
|
||||||
@ -297,6 +293,7 @@ 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});
|
||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
},
|
},
|
||||||
'click .change' (event) {
|
'click .change' (event) {
|
||||||
@ -406,9 +403,8 @@ Template.main.events({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
'click #workSubmit' () {
|
'click #workSubmit' () {
|
||||||
data = getHomeworkFormData();
|
if(getHomeworkFormData() === null) return;
|
||||||
if(data === null) return;
|
Session.set("serverData",Session.get("currentWork"));
|
||||||
Session.set("serverData",data);
|
|
||||||
if(Session.get("newWork")) {
|
if(Session.get("newWork")) {
|
||||||
sendData("createWork");
|
sendData("createWork");
|
||||||
} else {
|
} else {
|
||||||
@ -416,7 +412,6 @@ Template.main.events({
|
|||||||
}
|
}
|
||||||
Session.set("newWork",null);
|
Session.set("newWork",null);
|
||||||
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
closeDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
Session.set("currentWork", null);
|
|
||||||
},
|
},
|
||||||
'focus .op' (event) {
|
'focus .op' (event) {
|
||||||
event.target.click();
|
event.target.click();
|
||||||
@ -427,9 +422,9 @@ 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});
|
||||||
thisWork.dueDate = getReadableDate(thisWork.dueDate);
|
|
||||||
thisWork.type = thisWork.type[0].toUpperCase() + thisWork.type.slice(1);
|
|
||||||
Session.set("currentWork",thisWork);
|
Session.set("currentWork",thisWork);
|
||||||
|
var thisReadWork = formReadable(thisWork);
|
||||||
|
Session.set("currentReadableWork",thisReadWork);
|
||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -470,7 +465,8 @@ function closeInput(sessval) {
|
|||||||
span.style.display = "initial";
|
span.style.display = "initial";
|
||||||
Session.set("modifying", null);
|
Session.set("modifying", null);
|
||||||
if(!Session.get("newWork")) {
|
if(!Session.get("newWork")) {
|
||||||
Session.set("serverData",getHomeworkFormData());
|
if(getHomeworkFormData() === null) return;
|
||||||
|
Session.set("serverData",Session.get("currentWork"));
|
||||||
sendData("editWork");
|
sendData("editWork");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -487,12 +483,18 @@ function getHomeworkFormData() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(value.includes("Click here to edit")) {
|
if(value.includes("Click here to edit")) {
|
||||||
value = "Missing field";
|
inputs[i].childNodes[0].nodeValue = "Missing field";
|
||||||
inputs[i].style.color = "#FF1A1A";
|
inputs[i].style.color = "#FF1A1A";
|
||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var desc = document.getElementById("workDesc");
|
||||||
|
if(desc.childNodes[0].nodeValue.includes("Click here to edit")) {
|
||||||
|
desc.childNodes[0].nodeValue = "Missing field";
|
||||||
|
desc.style.color = "#FF1A1A";
|
||||||
|
stop = true;
|
||||||
|
}
|
||||||
if(stop) return null;
|
if(stop) return null;
|
||||||
|
|
||||||
var data = Session.get("currentWork");
|
var data = Session.get("currentWork");
|
||||||
@ -500,9 +502,10 @@ function getHomeworkFormData() {
|
|||||||
data.dueDate = new Date(document.getElementById("workDate").childNodes[0].nodeValue);
|
data.dueDate = new Date(document.getElementById("workDate").childNodes[0].nodeValue);
|
||||||
data.description = document.getElementById("workDesc").childNodes[0].nodeValue;
|
data.description = document.getElementById("workDesc").childNodes[0].nodeValue;
|
||||||
data.type = document.getElementById("workType").childNodes[0].nodeValue.toLowerCase();
|
data.type = document.getElementById("workType").childNodes[0].nodeValue.toLowerCase();
|
||||||
Session.set("currentWork", data);
|
|
||||||
|
|
||||||
return data;
|
Session.set("currentWork", data);
|
||||||
|
var readableData = formReadable(data);
|
||||||
|
Session.set("currentReadableWork", readableData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReadableDate(date) {
|
function getReadableDate(date) {
|
||||||
@ -510,3 +513,9 @@ function getReadableDate(date) {
|
|||||||
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
|
var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
|
||||||
return days[date.getDay()]+", "+months[date.getMonth()]+" "+date.getDate()+", "+date.getFullYear();
|
return days[date.getDay()]+", "+months[date.getMonth()]+" "+date.getDate()+", "+date.getFullYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formReadable(input) {
|
||||||
|
input.dueDate = input.dueDate.getFullYear()+"-"+input.dueDate.getMonth()+"-"+input.dueDate.getDate();
|
||||||
|
input.type = input.type[0].toUpperCase() + input.type.slice(1);
|
||||||
|
return input;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user