createcomments

This commit is contained in:
Yaman Qalieh 2016-08-22 16:52:04 -04:00
parent e68ffb9dba
commit db85d38145
4 changed files with 15 additions and 3 deletions

View File

@ -31,3 +31,4 @@ rzymek:fullcalendar
momentjs:moment
eternicode:bootstrap-datepicker
shell-server
http

View File

@ -100,6 +100,7 @@
<div>
<h3>Comments</h3>
<textarea id="workComment" rows="4" cols="50"></textarea>
<div id="commentSubmit">Submit</div>
</div>
<div id="comment">
{{#each work 'comments'}}

View File

@ -407,7 +407,7 @@ Template.main.events({
input.typ = "text";
input.style.height = 0.9 * dim.height.toString() + "px";
}
if(!event.target.id === "workDate") input.value = ele.childNodes[0].nodeValue;
if(event.target.id !== "workDate") input.value = ele.childNodes[0].nodeValue;
input.className = "changeInput";
input.style.width = "70%";
@ -495,6 +495,14 @@ Template.main.events({
}
}
},
'click #commentSubmit' (event) {
workId = Session.get("currentWork")._id;
comment = document.getElementById('workComment').value;
if (comment !== "") {
document.getElementById('workComment').value = "";
Meteor.call('addComment', [comment, workId]);
}
},
'click #workSubmit' () {
if(getHomeworkFormData() === null) return;
Session.set("serverData",Session.get("currentWork"));
@ -593,7 +601,7 @@ function closeInput(sessval) {
} else {
span.childNodes[0].nodeValue = input.value;
}
span.style.display = "initial";
span.style.display = "initial";
Session.set("modifying", null);
if(!Session.get("newWork")) {
if(getHomeworkFormData() === null) return;

View File

@ -368,6 +368,7 @@ Meteor.methods({
}
},
'addComment': function(input) {
var comment = input[0];
var workobject = work.findOne({
_id: input[1]
});
@ -375,8 +376,9 @@ Meteor.methods({
_id: workobject.class
});
var user = Meteor.userId();
foundsubs = currentclass.subscribers;
if (typeof comment === "string" && comment.length <= 200 &&
currentclass.subscribers.indexOf(Meteor.userId()) != -1 &&
foundsubs.indexOf(Meteor.userId()) != -1 &&
currentclass.banned.indexOf(Meteor.userId()) === -1) {
var comments = workobject.comments.concat(comment);
work.update({