comments are displayed, comment server bug
This commit is contained in:
parent
5281bf4117
commit
6b2e56f067
@ -128,24 +128,24 @@
|
||||
<p class="workOptionText">Other</p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="workAttach">Attach other files</div>
|
||||
<!-- <div id="workAttach">Attach other files</div>
|
||||
<div id="workAttachmentHolder">
|
||||
{{#each work 'attachments'}}
|
||||
<a href={{link}}>{{filename}}</a>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div> -->
|
||||
{{#unless newWork}}
|
||||
<div id="workComments">
|
||||
<div>
|
||||
<h3>Comments</h3>
|
||||
<textarea id="workComment" rows="4" cols="50"></textarea>
|
||||
<div id="commentSubmit">Submit</div>
|
||||
</div>
|
||||
<div id="comment">
|
||||
{{#each work 'comments'}}
|
||||
{{> comment}}
|
||||
{{/each}}
|
||||
</div>
|
||||
<div>
|
||||
<textarea id="workComment" rows="4" cols="50"></textarea>
|
||||
<div id="commentSubmit">Submit</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/unless}}
|
||||
</div>
|
||||
@ -201,3 +201,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template name="comment">
|
||||
<div class="commentBox">
|
||||
<span class="commentComment">{{comment}}</span>
|
||||
<span class="commentUser">{{user}}</span>
|
||||
<span class="commentDate">{{date}}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -671,7 +671,9 @@ Template.main.events({
|
||||
},
|
||||
'click #commentSubmit' (event) {
|
||||
workId = Session.get("currentWork")._id;
|
||||
comment = document.getElementById('workComment').value;
|
||||
var input = document.getElementById('workComment');
|
||||
comment = input.value;
|
||||
input.value = "";
|
||||
if (comment !== "") {
|
||||
document.getElementById('workComment').value = "";
|
||||
Meteor.call('addComment', [comment, workId]);
|
||||
@ -889,5 +891,18 @@ function toDate(date) {
|
||||
function formReadable(input) {
|
||||
input.dueDate = getReadableDate(input.dueDate);
|
||||
input.type = input.type[0].toUpperCase() + input.type.slice(1);
|
||||
var comments = input.comments;
|
||||
for(var k = 0; k < comments.length; k++) {
|
||||
comments[k].user = Meteor.users.findOne({_id:comments[k].user}).profile.name;
|
||||
comments[k].date = moment(comments[k].date).calendar(null, { //change to time if recently posted
|
||||
sameDay: '[Today]',
|
||||
nextDay: '[Tomorrow]',
|
||||
nextWeek: 'dddd',
|
||||
lastDay: '[Yesterday]',
|
||||
lastWeek: '[Last] dddd',
|
||||
sameElse: 'MMMM Do'
|
||||
});
|
||||
}
|
||||
input.comments = comments;
|
||||
return input;
|
||||
}
|
||||
|
||||
@ -434,14 +434,17 @@ Meteor.methods({
|
||||
if (typeof comment === "string" && comment.length <= 200 &&
|
||||
foundsubs.indexOf(Meteor.userId()) != -1 &&
|
||||
currentclass.banned.indexOf(Meteor.userId()) === -1) {
|
||||
var comments = workobject.comments.concat(comment);
|
||||
commentInfo = {
|
||||
"comment":input[0],
|
||||
"user":user,
|
||||
"date": new Date()
|
||||
};
|
||||
var comments = workobject.comments.concat(commentInfo);
|
||||
work.update({
|
||||
_id: input[1]
|
||||
}, {
|
||||
$set: {
|
||||
comments: comments,
|
||||
user: user,
|
||||
time: new Date()
|
||||
comments: comments
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user