From db85d38145af1877b6558680d3d421cbaf963451 Mon Sep 17 00:00:00 2001 From: Yaman Qalieh Date: Mon, 22 Aug 2016 16:52:04 -0400 Subject: [PATCH] createcomments --- hourglass/.meteor/packages | 1 + hourglass/client/main/main.html | 1 + hourglass/client/main/main.js | 12 ++++++++++-- hourglass/server/main.js | 4 +++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hourglass/.meteor/packages b/hourglass/.meteor/packages index 70cdd71..b09dea7 100644 --- a/hourglass/.meteor/packages +++ b/hourglass/.meteor/packages @@ -31,3 +31,4 @@ rzymek:fullcalendar momentjs:moment eternicode:bootstrap-datepicker shell-server +http diff --git a/hourglass/client/main/main.html b/hourglass/client/main/main.html index 9ffeb87..451732c 100644 --- a/hourglass/client/main/main.html +++ b/hourglass/client/main/main.html @@ -100,6 +100,7 @@

Comments

+
Submit
{{#each work 'comments'}} diff --git a/hourglass/client/main/main.js b/hourglass/client/main/main.js index 4f1a6e9..4d0680b 100644 --- a/hourglass/client/main/main.js +++ b/hourglass/client/main/main.js @@ -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; diff --git a/hourglass/server/main.js b/hourglass/server/main.js index fdceac0..233e25d 100644 --- a/hourglass/server/main.js +++ b/hourglass/server/main.js @@ -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({