mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-06 01:49:29 +02:00
feat(forums): moderators/oper/admin can toggle set topic readonly status
This commit is contained in:
@@ -634,6 +634,8 @@
|
||||
BTN_SUBMIT_REPLY: 'Submit New Reply',
|
||||
BTN_POST_NEW_TOPIC: 'Post New Topic',
|
||||
BTN_POST_NEW_REPLY: 'Post New Reply',
|
||||
BTN_SET_READONLY: 'Set Readonly',
|
||||
BTN_UNSET_READONLY: 'Unset Readonly',
|
||||
ADD_SUCCESSFULLY: 'Forum added successfully',
|
||||
ADD_FAILED: 'Forum added failed',
|
||||
EDIT_SUCCESSFULLY: 'Forum edited successfully',
|
||||
@@ -659,6 +661,8 @@
|
||||
POST_REPLY_FAILED: 'Post new reply failed',
|
||||
TOPIC_EDIT_SUCCESSFULLY: 'Reply content modify successfully',
|
||||
TOPIC_EDIT_FAILED: 'Reply content modify failed',
|
||||
TOPIC_TOGGLE_READONLY_SUCCESSFULLY: 'Toggle set topic readonly successfully',
|
||||
TOPIC_TOGGLE_READONLY_FAILED: 'Toggle set topic readonly failed',
|
||||
REPLY_EDIT_SUCCESSFULLY: 'Reply content modify successfully',
|
||||
REPLY_EDIT_FAILED: 'Reply content modify failed',
|
||||
DELETE_TOPIC_SUCCESSFULLY: 'Topic deleted successfully',
|
||||
|
||||
@@ -634,6 +634,8 @@
|
||||
BTN_SUBMIT_REPLY: '提交回复',
|
||||
BTN_POST_NEW_TOPIC: '发起新话题 ',
|
||||
BTN_POST_NEW_REPLY: '回复',
|
||||
BTN_SET_READONLY: '设为只读',
|
||||
BTN_UNSET_READONLY: '取消只读',
|
||||
ADD_SUCCESSFULLY: '版块添加成功',
|
||||
ADD_FAILED: '版块添加失败',
|
||||
EDIT_SUCCESSFULLY: '版块编辑成功',
|
||||
@@ -659,6 +661,8 @@
|
||||
POST_REPLY_FAILED: '回复内容提交失败',
|
||||
TOPIC_EDIT_SUCCESSFULLY: '话题内容编辑成功',
|
||||
TOPIC_EDIT_FAILED: '话题内容编辑失败',
|
||||
TOPIC_TOGGLE_READONLY_SUCCESSFULLY: '只读状态切换成功',
|
||||
TOPIC_TOGGLE_READONLY_FAILED: '只读状态切换失败',
|
||||
REPLY_EDIT_SUCCESSFULLY: '回复内容修改成功',
|
||||
REPLY_EDIT_FAILED: '回复内容修改失败',
|
||||
DELETE_TOPIC_SUCCESSFULLY: '话题删除成功',
|
||||
|
||||
@@ -301,6 +301,27 @@
|
||||
}, 500);
|
||||
};
|
||||
|
||||
/**
|
||||
* toggleReadonly
|
||||
* @param t
|
||||
*/
|
||||
vm.toggleReadonly = function (t) {
|
||||
var topic = new TopicsService({
|
||||
forum: vm.forum._id,
|
||||
_id: t._id
|
||||
});
|
||||
|
||||
console.log(topic);
|
||||
|
||||
topic.$toggleTopicReadonly(function (res) {
|
||||
vm.topic = res;
|
||||
NotifycationService.showSuccessNotify('FORUMS.TOPIC_TOGGLE_READONLY_SUCCESSFULLY');
|
||||
}, function (res) {
|
||||
NotifycationService.showErrorNotify(res.data.message, 'FORUMS.TOPIC_TOGGLE_READONLY_FAILED');
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* postReply
|
||||
* @param isValid
|
||||
|
||||
@@ -14,6 +14,14 @@
|
||||
}, {
|
||||
update: {
|
||||
method: 'PUT'
|
||||
},
|
||||
toggleTopicReadonly: {
|
||||
method: 'PUT',
|
||||
url: '/api/topics/:forumId/:topicId/toggleTopicReadonly',
|
||||
params: {
|
||||
forumId: '@forum',
|
||||
topicId: '@_id'
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,11 +50,15 @@
|
||||
</ul>
|
||||
</div>
|
||||
<div class="box-post-btn">
|
||||
<a class="btn btn-success btn-width-100"
|
||||
ng-if="!vm.topic.readOnly || vm.canEdit(vm.topic)"
|
||||
href="#" ng-click="vm.beginPostReply();">{{'FORUMS.BTN_POST_NEW_TOPIC' | translate}}</a>
|
||||
<div ng-if="!vm.topic.readOnly || vm.canEdit(vm.topic)">
|
||||
<a class="btn btn-success btn-width-100"
|
||||
href="#" ng-click="vm.beginPostReply();">{{'FORUMS.BTN_POST_NEW_TOPIC' | translate}}</a>
|
||||
<a class="btn btn-default btn-width-100"
|
||||
href="#" ng-click="vm.toggleReadonly(vm.topic);">{{ vm.topic.readOnly ? 'FORUMS.BTN_UNSET_READONLY' : 'FORUMS.BTN_SET_READONLY' | translate}}</a>
|
||||
</div>
|
||||
|
||||
<h5 class="text-danger text-uppercase" translate="FORUMS.READ_ONLY_REPLY" ng-if="vm.topic.readOnly && !vm.canEdit(vm.topic)"></h5>
|
||||
<h5 class="text-danger text-uppercase" translate="FORUMS.READ_ONLY_REPLY"
|
||||
ng-if="vm.topic.readOnly && !vm.canEdit(vm.topic)"></h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -140,6 +140,27 @@ exports.updateTopic = function (req, res) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* toggleTopicReadonly
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.toggleTopicReadonly = function (req, res) {
|
||||
var topic = req.topic;
|
||||
|
||||
topic.readOnly = !topic.readOnly;
|
||||
|
||||
topic.save(function (err) {
|
||||
if (err) {
|
||||
return res.status(422).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
res.json(topic);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* deleteTopic
|
||||
* @param req
|
||||
|
||||
@@ -21,7 +21,8 @@ exports.invokeRolesPolicies = function () {
|
||||
{resources: '/api/forums/:forumId', permissions: '*'},
|
||||
{resources: '/api/topics/:forumId', permissions: '*'},
|
||||
{resources: '/api/topics/:forumId/:topicId', permissions: '*'},
|
||||
{resources: '/api/topics/:forumId/:topicId/:replyId', permissions: '*'}
|
||||
{resources: '/api/topics/:forumId/:topicId/:replyId', permissions: '*'},
|
||||
{resources: '/api/topics/:forumId/:topicId/toggleTopicReadonly', permissions: '*'}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -23,6 +23,9 @@ module.exports = function (app) {
|
||||
.delete(forums.deleteTopic)
|
||||
.post(forums.postNewReply);
|
||||
|
||||
app.route('/api/topics/:forumId/:topicId/toggleTopicReadonly').all(forumsPolicy.isAllowed)
|
||||
.put(forums.toggleTopicReadonly);
|
||||
|
||||
app.route('/api/topics/:forumId/:topicId/:replyId').all(forumsPolicy.isAllowed)
|
||||
.put(forums.updateReply)
|
||||
.delete(forums.deleteReply);
|
||||
|
||||
Reference in New Issue
Block a user