mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
move post
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
"reply": "Reply",
|
"reply": "Reply",
|
||||||
"edit": "Edit",
|
"edit": "Edit",
|
||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
|
"move": "Move",
|
||||||
"fork": "Fork",
|
"fork": "Fork",
|
||||||
"banned": "banned",
|
"banned": "banned",
|
||||||
"link": "Link",
|
"link": "Link",
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
"loading": "Loading",
|
"loading": "Loading",
|
||||||
"more_posts": "More Posts",
|
"more_posts": "More Posts",
|
||||||
"move_topic": "Move Topic",
|
"move_topic": "Move Topic",
|
||||||
|
"move_post": "Move Post",
|
||||||
"fork_topic": "Fork Topic",
|
"fork_topic": "Fork Topic",
|
||||||
"topic_will_be_moved_to": "This topic will be moved to the category",
|
"topic_will_be_moved_to": "This topic will be moved to the category",
|
||||||
"fork_topic_instruction": "Click the posts you want to fork",
|
"fork_topic_instruction": "Click the posts you want to fork",
|
||||||
|
|||||||
@@ -465,6 +465,50 @@ define(['composer'], function(composer) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#post-container').on('click', '.move', function(e) {
|
||||||
|
var moveModal = $('#move-post-modal'),
|
||||||
|
moveBtn = moveModal.find('#move_post_commit'),
|
||||||
|
topicId = moveModal.find('#topicId'),
|
||||||
|
post = $(this),
|
||||||
|
pid = $(this).parents('li').attr('data-pid');
|
||||||
|
|
||||||
|
moveModal.removeClass('hide');
|
||||||
|
moveModal.css("position", "fixed")
|
||||||
|
.css("left", Math.max(0, (($(window).width() - $(moveModal).outerWidth()) / 2) + $(window).scrollLeft()) + "px")
|
||||||
|
.css("top", "0px")
|
||||||
|
.css("z-index", "2000");
|
||||||
|
|
||||||
|
moveModal.find('.close,#move_post_cancel').on('click', function() {
|
||||||
|
moveModal.addClass('hide');
|
||||||
|
});
|
||||||
|
|
||||||
|
topicId.on('change', function() {
|
||||||
|
if(topicId.val().length) {
|
||||||
|
moveBtn.removeAttr('disabled');
|
||||||
|
} else {
|
||||||
|
moveBtn.attr('disabled', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
moveBtn.on('click', function() {
|
||||||
|
socket.emit('api:topic.movePost', {pid: pid, tid: topicId.val()}, function(err) {
|
||||||
|
if(err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
post.fadeOut(500, function() {
|
||||||
|
post.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
moveModal.addClass('hide');
|
||||||
|
$('#topicId').val('');
|
||||||
|
|
||||||
|
app.alertSuccess('Post moved!');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$('#post-container').on('click', '.chat', function(e) {
|
$('#post-container').on('click', '.chat', function(e) {
|
||||||
var username = $(this).parents('li.row').attr('data-username');
|
var username = $(this).parents('li.row').attr('data-username');
|
||||||
var touid = $(this).parents('li.row').attr('data-uid');
|
var touid = $(this).parents('li.row').attr('data-uid');
|
||||||
|
|||||||
@@ -97,6 +97,9 @@
|
|||||||
<div class="btn-group post-tools">
|
<div class="btn-group post-tools">
|
||||||
<button class="btn btn-sm btn-default edit" type="button" title="[[topic:edit]]"><i class="fa fa-pencil"></i></button>
|
<button class="btn btn-sm btn-default edit" type="button" title="[[topic:edit]]"><i class="fa fa-pencil"></i></button>
|
||||||
<button class="btn btn-sm btn-default delete" type="button" title="[[topic:delete]]"><i class="fa fa-trash-o"></i></button>
|
<button class="btn btn-sm btn-default delete" type="button" title="[[topic:delete]]"><i class="fa fa-trash-o"></i></button>
|
||||||
|
<!-- IF !@first -->
|
||||||
|
<button class="btn btn-sm btn-default move" type="button" title="[[topic:move]]"><i class="fa fa-arrows"></i></button>
|
||||||
|
<!-- ENDIF !@first -->
|
||||||
</div>
|
</div>
|
||||||
<!-- ENDIF posts.display_moderator_tools -->
|
<!-- ENDIF posts.display_moderator_tools -->
|
||||||
</div>
|
</div>
|
||||||
@@ -209,28 +212,50 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="fork-thread-modal" class="hide" tabindex="-1" role="dialog" aria-labelledby="Chat" aria-hidden="true" data-backdrop="none">
|
<div id="fork-thread-modal" class="hide" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true" data-backdrop="none">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
<h4>[[topic:fork_topic]]</h4>
|
<h4>[[topic:fork_topic]]</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="title">Title</label>
|
<label for="title">Title</label>
|
||||||
<input id="fork-title" type="text" class="form-control" placeholder="Enter new thread title"><br/>
|
<input id="fork-title" type="text" class="form-control" placeholder="Enter new thread title"><br/>
|
||||||
<label>[[topic:fork_topic_instruction]]</label> <br/>
|
<label>[[topic:fork_topic_instruction]]</label> <br/>
|
||||||
<span id="fork-pids"></span>
|
<span id="fork-pids"></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal" id="fork_thread_cancel">[[global:buttons.close]]</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal" id="fork_thread_cancel">[[global:buttons.close]]</button>
|
||||||
<button type="button" class="btn btn-primary" id="fork_thread_commit" disabled>[[topic:confirm_fork]]</button>
|
<button type="button" class="btn btn-primary" id="fork_thread_commit" disabled>[[topic:confirm_fork]]</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="move-post-modal" class="hide" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true" data-backdrop="none">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h4>[[topic:move_post]]</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="topicId">Topic ID</label>
|
||||||
|
<input id="topicId" type="text" class="form-control" placeholder="Enter topic ID"><br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal" id="move_post_cancel">[[global:buttons.close]]</button>
|
||||||
|
<button type="button" class="btn btn-primary" id="move_post_commit" disabled>[[topic:confirm_move]]</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -242,13 +242,7 @@ var async = require('async'),
|
|||||||
function move(pid, next) {
|
function move(pid, next) {
|
||||||
postTools.privileges(pid, uid, function(privileges) {
|
postTools.privileges(pid, uid, function(privileges) {
|
||||||
if(privileges.editable) {
|
if(privileges.editable) {
|
||||||
posts.getPostField(pid, 'timestamp', function(err, timestamp) {
|
Topics.movePostToTopic(pid, tid, next);
|
||||||
if(err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
Topics.movePostToTopic(pid, postData.tid, tid, timestamp, next);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
@@ -259,13 +253,35 @@ var async = require('async'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.movePostToTopic = function(pid, oldTid, newTid, timestamp, callback) {
|
Topics.movePostToTopic = function(pid, tid, callback) {
|
||||||
Topics.removePostFromTopic(oldTid, pid);
|
threadTools.exists(tid, function(exists) {
|
||||||
Topics.decreasePostCount(oldTid);
|
if(!exists) {
|
||||||
|
return callback(new Error('Topic doesn\'t exist'));
|
||||||
|
}
|
||||||
|
|
||||||
posts.setPostField(pid, 'tid', newTid);
|
posts.getPostField(pid, 'tid', function(err, oldTid) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
Topics.onNewPostMade(newTid, pid, timestamp, callback);
|
if(!oldTid) {
|
||||||
|
return callback(new Error('Post doesn\'t exist'));
|
||||||
|
}
|
||||||
|
|
||||||
|
Topics.removePostFromTopic(oldTid, pid, function(err) {
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
Topics.decreasePostCount(oldTid);
|
||||||
|
|
||||||
|
posts.setPostField(pid, 'tid', tid);
|
||||||
|
|
||||||
|
Topics.increasePostCount(tid);
|
||||||
|
Topics.addPostToTopic(tid, pid, callback);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.getTopicData = function(tid, callback) {
|
Topics.getTopicData = function(tid, callback) {
|
||||||
@@ -1032,8 +1048,8 @@ var async = require('async'),
|
|||||||
db.listAppend('tid:' + tid + ':posts', pid, callback);
|
db.listAppend('tid:' + tid + ':posts', pid, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.removePostFromTopic = function(tid, pid) {
|
Topics.removePostFromTopic = function(tid, pid, callback) {
|
||||||
db.listRemoveAll('tid:' + tid + ':posts', pid);
|
db.listRemoveAll('tid:' + tid + ':posts', pid, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.getPids = function(tid, callback) {
|
Topics.getPids = function(tid, callback) {
|
||||||
|
|||||||
@@ -638,6 +638,22 @@ websockets.init = function(io) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('api:topic.movePost', function(data, callback) {
|
||||||
|
if(!uid) {
|
||||||
|
socket.emit('event:alert', {
|
||||||
|
title: 'Can't fork',
|
||||||
|
message: 'Guests can't fork topics!',
|
||||||
|
type: 'warning',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
topics.movePostToTopic(data.pid, data.tid, function(err, data) {
|
||||||
|
callback(err?{message:err.message}:null, data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('api:topic.move', function(data) {
|
socket.on('api:topic.move', function(data) {
|
||||||
threadTools.move(data.tid, data.cid, socket);
|
threadTools.move(data.tid, data.cid, socket);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user