Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Closes #43. Edit History modal still needs to style updates but it do…

…es the job for now
  • Loading branch information...
commit eae7ca9543e97aa376f44bd75d965912daa0a569 1 parent 3f64b9f
@SlashmanX authored
View
7 app.js
@@ -6,6 +6,7 @@ var SM = require('./server/modules/socket-manager');
var CM = require('./server/modules/category-manager');
var AM = require('./server/modules/account-manager');
var FM = require('./server/modules/forum-manager');
+var PM = require('./server/modules/post-manager');
var func = require('./server/controllers/func.js');
var app = express();
@@ -81,6 +82,12 @@ socket.sockets.on('connection', function(client){
callback(forum);
})
});
+
+ client.on('getPostEditHistory', function(data, callback) {
+ PM.getPostEditHistory(data.id, function(e, history) {
+ callback(e, history);
+ });
+ });
client.on('disconnect', function(){
client.leave(hs.sessionID);
View
18 public/js/views/topic.js
@@ -33,6 +33,24 @@ jQuery(document).ready(function() {
});
});
$('.modal-confirm').modal({show: true});
+ });
+
+ $('.post-edit-history').on('click', function(e) {
+
+ console.log('here');
+ e.preventDefault();
+ var postID = $(this).parentsUntil('section').parent().attr('id').replace('post-', '');
+ $('#modal-confirm-header').text('Post History');
+ socket.emit('getPostEditHistory', {id: postID}, function(err, history) {
+ $('#modal-confirm-body').html("");
+ var editHtml = "";
+ for(var h in history) {
+ editHtml += "<h4>On "+ history[h].dateEdited +" "+ history[h].editedBy.username +" changed this post to: </h4><p> "+ history[h].newBody +"</p><hr />";
+ }
+ $('#modal-confirm-body').html(editHtml);
+ $('#modal-confirm-ok').text('Close').addClass('btn-primary');
+ $('.modal-confirm').modal({show: true});
+ });
})
$('.delete-post').on('click', function(e) {
View
7 server/modules/post-manager.js
@@ -115,6 +115,13 @@ PM.getPostInfo = function(pid, callback)
callback(postInfo);
})
}
+PM.getPostEditHistory = function(pid, callback)
+{
+ Post.findById(pid).select('editHistory').populate('editHistory.editedBy').exec(function(e, postInfo){
+ if(e) callback(e)
+ else callback(null, postInfo.editHistory);
+ })
+}
PM.getTopic = function(tid, callback)
{
Post.find({topic: tid}).populate('author').populate('editHistory.editedBy').sort({postedOn: 1}).exec(function(e, posts) {
View
4 server/views/partials/post.jade
@@ -43,6 +43,10 @@ section.topic-post(id = 'post-'+ post._id)
button.btn.edit-post(type='button')
i.icon-edit
| Edit
+ if (((user.username == post.author.username) && (user.role && user.role.permissions.CAN_EDIT_OWN_POSTS)) || (user.role && user.role.permissions.CAN_EDIT_OTHERS_POSTS)) && post.editHistory.length > 0
+ button.btn.post-edit-history(type='button')
+ i.icon-briefcase
+ | View Edit History
if user.username != post.author.username
button.btn.btn-warning.report-post(type='button')
i.icon-legal
Please sign in to comment.
Something went wrong with that request. Please try again.