Fixed editWork, and displays work information on click
This commit is contained in:
parent
6833e3a1cd
commit
00ded2965d
@ -145,7 +145,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template name="classModeWork">
|
<template name="classModeWork">
|
||||||
<div class="workCard">
|
<div class="workCard" workid="{{_id}}">
|
||||||
<div class="cWorkType" style="background-color:{{typeColor}}"></div>
|
<div class="cWorkType" style="background-color:{{typeColor}}"></div>
|
||||||
<div class="cWorkCont">
|
<div class="cWorkCont">
|
||||||
<p class="cWorkName">{{name}}</p>
|
<p class="cWorkName">{{name}}</p>
|
||||||
|
|||||||
@ -72,7 +72,6 @@ Template.registerHelper('myClasses', () => {
|
|||||||
thisWork[j].dueDate = getReadableDate(thisWork[j].dueDate);
|
thisWork[j].dueDate = getReadableDate(thisWork[j].dueDate);
|
||||||
thisWork[j].typeColor = workColors[thisWork[j].type];
|
thisWork[j].typeColor = workColors[thisWork[j].type];
|
||||||
}
|
}
|
||||||
console.log(thisWork);
|
|
||||||
array[i].thisClassWork = thisWork;
|
array[i].thisClassWork = thisWork;
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
@ -173,11 +172,11 @@ Template.main.helpers({
|
|||||||
return Session.get("currentWork")[value];
|
return Session.get("currentWork")[value];
|
||||||
},
|
},
|
||||||
workType() {
|
workType() {
|
||||||
type = Session.get("currentWork").type
|
type = Session.get("currentWork").type;
|
||||||
if(type.includes("edit")) {
|
if(type.includes("edit")) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
return workColors.type;
|
return workColors[type];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cWorkColor(type) {
|
cWorkColor(type) {
|
||||||
@ -289,7 +288,6 @@ Template.main.events({
|
|||||||
} else {
|
} else {
|
||||||
var attr = event.target.getAttribute("classid");
|
var attr = event.target.getAttribute("classid");
|
||||||
}
|
}
|
||||||
openDivFade(document.getElementsByClassName("overlay")[0]);
|
|
||||||
Session.set("newWork", true);
|
Session.set("newWork", true);
|
||||||
Session.set("currentWork",
|
Session.set("currentWork",
|
||||||
{
|
{
|
||||||
@ -299,6 +297,7 @@ Template.main.events({
|
|||||||
description:"Click here to edit...",
|
description:"Click here to edit...",
|
||||||
type:"Click here to edit..."
|
type:"Click here to edit..."
|
||||||
});
|
});
|
||||||
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
},
|
},
|
||||||
'click .change' (event) {
|
'click .change' (event) {
|
||||||
var ele = event.target;
|
var ele = event.target;
|
||||||
@ -409,7 +408,6 @@ Template.main.events({
|
|||||||
'click #workSubmit' () {
|
'click #workSubmit' () {
|
||||||
data = getHomeworkFormData();
|
data = getHomeworkFormData();
|
||||||
if(data === null) return;
|
if(data === null) return;
|
||||||
console.log(data);
|
|
||||||
Session.set("serverData",data);
|
Session.set("serverData",data);
|
||||||
if(Session.get("newWork")) {
|
if(Session.get("newWork")) {
|
||||||
sendData("createWork");
|
sendData("createWork");
|
||||||
@ -423,7 +421,17 @@ Template.main.events({
|
|||||||
'focus .op' (event) {
|
'focus .op' (event) {
|
||||||
event.target.click();
|
event.target.click();
|
||||||
},
|
},
|
||||||
|
'click .workCard' (event) {
|
||||||
|
var dom = event.target;
|
||||||
|
while(event.target.className !== "workCard") event.target = event.target.parentNode;
|
||||||
|
workid = event.target.getAttribute("workid");
|
||||||
|
Session.set("newWork",false);
|
||||||
|
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);
|
||||||
|
openDivFade(document.getElementsByClassName("overlay")[0]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function openDivFade(div) {
|
function openDivFade(div) {
|
||||||
@ -500,5 +508,5 @@ function getHomeworkFormData() {
|
|||||||
function getReadableDate(date) {
|
function getReadableDate(date) {
|
||||||
var days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
|
var days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];
|
||||||
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();
|
return days[date.getDay()]+", "+months[date.getMonth()]+" "+date.getDate()+", "+date.getFullYear();
|
||||||
}
|
}
|
||||||
@ -190,12 +190,12 @@ Meteor.methods({
|
|||||||
|
|
||||||
var currentclass = classes.findOne({
|
var currentclass = classes.findOne({
|
||||||
_id: work.findOne({
|
_id: work.findOne({
|
||||||
_id: workId
|
_id: change._id
|
||||||
}).class
|
}).class
|
||||||
});
|
});
|
||||||
var authorized = currentclass.moderators.push(currentclass.admin);
|
var authorized = currentclass.moderators.push(currentclass.admin);
|
||||||
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
if (Roles.userIsInRole(Meteor.userId(), ['superadmin', 'admin'])) {
|
||||||
Meteor.update({
|
work.update({
|
||||||
_id: change._id
|
_id: change._id
|
||||||
}, {
|
}, {
|
||||||
$set: change
|
$set: change
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user