default date for new work

This commit is contained in:
Kenneth Jao 2016-10-19 00:15:30 -04:00
parent 86eecc47ee
commit d08d38acdd

View File

@ -274,7 +274,7 @@ Template.registerHelper('work', (value) => {// Returns the specified work value.
var thisWork = Session.get("currentWork"); var thisWork = Session.get("currentWork");
if (Session.equals("currentWork", null)) return; if (Session.equals("currentWork", null)) return;
if (Session.get("newWork") && (thisWork[value] === true || thisWork[value] === undefined)) { if (Session.get("newWork") && (thisWork[value] === true || thisWork[value] === undefined)) {
return defaultWork[value]; return (value === "dueDate") ? getReadableDate(new Date((new Date()).valueOf() + 1000*3600*24)) : defaultWork[value];
} else { } else {
return formReadable(thisWork,value); return formReadable(thisWork,value);
} }
@ -965,7 +965,7 @@ function getHomeworkFormData() { // Get all data relating to work creation.
return $("#"+inputs[i]+" span")[0].childNodes[0].nodeValue.toLowerCase(); return $("#"+inputs[i]+" span")[0].childNodes[0].nodeValue.toLowerCase();
} else if (title === "dueDate") { } else if (title === "dueDate") {
var val = $("#"+inputs[i])[0].value; var val = $("#"+inputs[i])[0].value;
return (val.includes(defaultWork[title].slice(0,-3))) ? val : toDate(val); return toDate(val);
} else { } else {
return $("#"+inputs[i])[0].value; return $("#"+inputs[i])[0].value;
} }
@ -979,7 +979,7 @@ function getHomeworkFormData() { // Get all data relating to work creation.
function checkMissing() { function checkMissing() {
var no = false; var no = false;
for(var key in serverData) { for(var key in serverData) {
if(!_.contains(["name","dueDate","description","type"],key)) continue; if(!_.contains(["name","dueDate","type"],key)) continue;
var id = "w" + key.charAt(0).toUpperCase() + key.slice(1); var id = "w" + key.charAt(0).toUpperCase() + key.slice(1);
if(serverData[key] === true || serverData[key] === "") { if(serverData[key] === true || serverData[key] === "") {
no = true; no = true;