diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js
index 99038a8d..d2bd4cfe 100644
--- a/modules/core/client/app/trans-string-en.js
+++ b/modules/core/client/app/trans-string-en.js
@@ -657,6 +657,8 @@
POST_TOPIC_FAILED: 'Post new topic failed',
POST_REPLY_SUCCESSFULLY: 'Post new reply successfully',
POST_REPLY_FAILED: 'Post new reply failed',
+ TOPIC_EDIT_SUCCESSFULLY: 'Reply content modify successfully',
+ TOPIC_EDIT_FAILED: 'Reply content modify failed',
REPLY_EDIT_SUCCESSFULLY: 'Reply content modify successfully',
REPLY_EDIT_FAILED: 'Reply content modify failed',
DELETE_TOPIC_SUCCESSFULLY: 'Topic deleted successfully',
@@ -665,6 +667,10 @@
DELETE_TOPIC_CONFIRM_CANCEL: 'Cancel',
DELETE_TOPIC_CONFIRM_HEADER_TEXT: 'Delete Topic',
DELETE_TOPIC_CONFIRM_BODY_TEXT: 'Are you sure want to delete this topic?',
+ DELETE_REPLY_SUCCESSFULLY: 'Reply deleted successfully',
+ DELETE_REPLY_FAILED: 'Reply deleted failed',
+ DELETE_REPLY_CONFIRM_HEADER_TEXT: 'Delete Reply',
+ DELETE_REPLY_CONFIRM_BODY_TEXT: 'Are you sure want to delete this reply?',
CATEGORY: {
AFFAIRS: 'Affairs',
diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js
index 13b48615..1a0b4579 100644
--- a/modules/core/client/app/trans-string-zh.js
+++ b/modules/core/client/app/trans-string-zh.js
@@ -655,14 +655,22 @@
PRC_REQUIRED: '请输入回复内容',
POST_TOPIC_SUCCESSFULLY: '新话题发布成功',
POST_TOPIC_FAILED: '新话题发布失败',
+ POST_REPLY_SUCCESSFULLY: '回复内容提交成功',
+ POST_REPLY_FAILED: '回复内容提交失败',
+ TOPIC_EDIT_SUCCESSFULLY: '话题内容编辑成功',
+ TOPIC_EDIT_FAILED: '话题内容编辑失败',
REPLY_EDIT_SUCCESSFULLY: '回复内容修改成功',
REPLY_EDIT_FAILED: '回复内容修改失败',
DELETE_TOPIC_SUCCESSFULLY: '话题删除成功',
DELETE_TOPIC_FAILED: '话题删除失败',
DELETE_TOPIC_CONFIRM_OK: '删除',
DELETE_TOPIC_CONFIRM_CANCEL: '取消',
- DELETE_TOPIC_CONFIRM_HEADER_TEXT: '删除确认',
+ DELETE_TOPIC_CONFIRM_HEADER_TEXT: '删除话题',
DELETE_TOPIC_CONFIRM_BODY_TEXT: '您确定要删除这个话题?',
+ DELETE_REPLY_SUCCESSFULLY: '回复删除成功',
+ DELETE_REPLY_FAILED: '回复删除失败',
+ DELETE_REPLY_CONFIRM_HEADER_TEXT: '删除回复',
+ DELETE_REPLY_CONFIRM_BODY_TEXT: '您确定要删除这条回复?',
CATEGORY: {
AFFAIRS: '站务区',
diff --git a/modules/forums/client/controllers/forums-topic.client.controller.js b/modules/forums/client/controllers/forums-topic.client.controller.js
index 45d85640..733e2640 100644
--- a/modules/forums/client/controllers/forums-topic.client.controller.js
+++ b/modules/forums/client/controllers/forums-topic.client.controller.js
@@ -74,7 +74,7 @@
* @param t
* @returns {boolean}
*/
- vm.isTopicOwner = function (t) {
+ vm.isOwner = function (t) {
if (t) {
if (t.user._id.str === vm.user._id) {
return true;
@@ -89,9 +89,9 @@
* @param t
* @returns {boolean}
*/
- vm.canEditTopic = function (t) {
+ vm.canEdit = function (t) {
if (t) {
- if (vm.isTopicOwner(t) || vm.user.isOper) {
+ if (vm.isOwner(t) || vm.user.isOper) {
return true;
} else {
return false;
@@ -120,9 +120,9 @@
t.content = e.getContent();
t.$update(function (res) {
vm.topic = res;
- NotifycationService.showSuccessNotify('FORUMS.REPLY_EDIT_SUCCESSFULLY');
+ NotifycationService.showSuccessNotify('FORUMS.TOPIC_EDIT_SUCCESSFULLY');
}, function (res) {
- NotifycationService.showErrorNotify(res.data.message, 'FORUMS.REPLY_EDIT_FAILED');
+ NotifycationService.showErrorNotify(res.data.message, 'FORUMS.TOPIC_EDIT_FAILED');
});
e.$options.hideable = true;
@@ -175,6 +175,33 @@
});
};
+ /**
+ * beginDeleteReply
+ * @param reply
+ */
+ vm.beginDeleteReply = function (reply) {
+ var modalOptions = {
+ closeButtonText: $translate.instant('FORUMS.DELETE_TOPIC_CONFIRM_CANCEL'),
+ actionButtonText: $translate.instant('FORUMS.DELETE_TOPIC_CONFIRM_OK'),
+ headerText: $translate.instant('FORUMS.DELETE_REPLY_CONFIRM_HEADER_TEXT'),
+ bodyText: $translate.instant('FORUMS.DELETE_REPLY_CONFIRM_BODY_TEXT')
+ };
+
+ ModalConfirmService.showModal({}, modalOptions)
+ .then(function (result) {
+ RepliesService.remove({
+ forumId: vm.forum._id,
+ topicId: vm.topic._id,
+ replyId: reply._id
+ }, function (res) {
+ vm.topic = res;
+ NotifycationService.showSuccessNotify('FORUMS.DELETE_REPLY_SUCCESSFULLY');
+ }, function (res) {
+ NotifycationService.showErrorNotify(res.data.message, 'FORUMS.DELETE_REPLY_FAILED');
+ });
+ });
+ };
+
/**
* beginPostReply
*/
diff --git a/modules/forums/client/views/topic.client.view.html b/modules/forums/client/views/topic.client.view.html
index bdf62f65..1e2f27b6 100644
--- a/modules/forums/client/views/topic.client.view.html
+++ b/modules/forums/client/views/topic.client.view.html
@@ -96,11 +96,11 @@
title="{{'FORUMS.TITLES.REPLY_QUOTE' | translate}}">
@@ -140,12 +140,12 @@
title="{{'FORUMS.TITLES.REPLY_QUOTE' | translate}}">
+ ng-show="vm.canEdit(rep);"
+ ng-click="vm.beginEditReply(rep)">
+ ng-show="vm.canEdit(rep);"
+ ng-click="vm.beginDeleteReply(rep);">
diff --git a/modules/forums/server/controllers/forums.server.controller.js b/modules/forums/server/controllers/forums.server.controller.js
index 7bad59b1..197fd39f 100644
--- a/modules/forums/server/controllers/forums.server.controller.js
+++ b/modules/forums/server/controllers/forums.server.controller.js
@@ -225,7 +225,28 @@ exports.updateReply = function (req, res) {
* @param res
*/
exports.deleteReply = function (req, res) {
- console.log('-----deleteReply-----');
+ var forum = req.forum;
+ var topic = req.topic;
+
+ topic._replies.forEach(function (r) {
+ if (r._id.equals(req.params.replyId)) {
+ topic._replies.pull(r);
+ topic.replyCount--;
+ topic.save(function (err) {
+ if (err) {
+ return res.status(422).send({
+ message: errorHandler.getErrorMessage(err)
+ });
+ } else {
+ res.json(topic);
+ }
+ });
+ }
+ });
+
+ forum.update({
+ $inc: {replyCount: -1}
+ }).exec();
};
/**
@@ -257,31 +278,3 @@ exports.topicById = function (req, res, next, id) {
next();
});
};
-
-/**
- * Invitation middleware
- */
-exports.replyById = function (req, res, next, id) {
-
- if (!mongoose.Types.ObjectId.isValid(id)) {
- return res.status(400).send({
- message: 'Reply is invalid'
- });
- }
-
- Reply.findById(id)
- .populate('user', 'username displayName profileImageURL uploaded downloaded score')
- .populate('updatedBy', 'username displayName profileImageURL uploaded downloaded score')
- .populate('_scoreList.user', 'username displayName profileImageURL uploaded downloaded')
- .exec(function (err, reply) {
- if (err) {
- return next(err);
- } else if (!reply) {
- return res.status(404).send({
- message: 'No reply with that identifier has been found'
- });
- }
- req.reply = reply;
- next();
- });
-};
diff --git a/modules/forums/server/routes/forums.server.routes.js b/modules/forums/server/routes/forums.server.routes.js
index 0fc6d133..f4284467 100644
--- a/modules/forums/server/routes/forums.server.routes.js
+++ b/modules/forums/server/routes/forums.server.routes.js
@@ -28,5 +28,4 @@ module.exports = function (app) {
.delete(forums.deleteReply);
app.param('topicId', forums.topicById);
- app.param('replyId', forums.replyById);
};