diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index e7c4e632..1c7fd9b8 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -624,10 +624,12 @@ HOME_INDEX: 'Forums Home', BTN_ADD_FORUM: 'Add New Forum', BTN_EDIT_FORUM: 'Edit Forum', - BTN_ADD: ' Add ', - BTN_EDIT: ' Edit ', + BTN_ADD: ' Add ', + BTN_EDIT: ' Edit ', + BTN_SAVE: ' Save ', + BTN_CANCEL: ' Cancel ', LINK_EDIT: 'Edit', - BTN_DELETE: ' Delete ', + BTN_DELETE: ' Delete ', BTN_SUBMIT: 'Submit New Topic', BTN_POST_NEW_TOPIC: 'Post New Topic', BTN_POST_NEW_REPLY: 'Post New Reply', @@ -651,6 +653,9 @@ PC_REQUIRED: 'Please enter topic content', POST_SEND_SUCCESSFULLY: 'Post new topic successfully', POST_SEND_FAILED: 'Post new topic failed', + REPLY_EDIT_SUCCESSFULLY: 'Reply content modify successfully', + REPLY_EDIT_FAILED: 'Reply content modify failed', + CATEGORY: { AFFAIRS: 'Affairs', DISCUSS: 'Discuss', @@ -675,6 +680,11 @@ REPLY_BY_1: 'by {{user}}', REPLY_BY_2: 'reply at {{createdAt}}', REPLY_BY_3: 'post at {{createdAt}}' + }, + TITLES: { + QUOTE: 'quote and reply', + EDIT: 'edit reply', + DELETE: 'delete reply' } }, diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 8b28d62d..4d5bb966 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -626,11 +626,13 @@ BTN_EDIT_FORUM: '编辑版块', BTN_ADD: ' 添加 ', BTN_EDIT: ' 编辑 ', + BTN_SAVE: ' 保存 ', + BTN_CANCEL: ' 取消 ', LINK_EDIT: '编辑', BTN_DELETE: ' 删除 ', BTN_SUBMIT: ' 提交新话题 ', BTN_POST_NEW_TOPIC: ' 发起新话题 ', - BTN_POST_NEW_REPLY: ' 回复 ', + BTN_POST_NEW_REPLY: ' 回 复 ', ADD_SUCCESSFULLY: '版块添加成功', ADD_FAILED: '版块添加失败', EDIT_SUCCESSFULLY: '版块编辑成功', @@ -651,6 +653,9 @@ PC_REQUIRED: '请输入话题内容', POST_SEND_SUCCESSFULLY: '新话题发布成功', POST_SEND_FAILED: '新话题发布失败', + REPLY_EDIT_SUCCESSFULLY: '回复内容修改成功', + REPLY_EDIT_FAILED: '回复内容修改失败', + CATEGORY: { AFFAIRS: '站务区', DISCUSS: '讨论区', @@ -675,6 +680,11 @@ REPLY_BY_1: '由 {{user}}', REPLY_BY_2: '回复于 at {{createdAt}}', REPLY_BY_3: '发表于 at {{createdAt}}' + }, + TITLES: { + QUOTE: '引用并回复', + EDIT: '编辑回复', + DELETE: '删除回复' } }, diff --git a/modules/core/client/directives/mt-markdown-editor.client.directive.js b/modules/core/client/directives/mt-markdown-editor.client.directive.js index ac2816d4..8a84ccda 100644 --- a/modules/core/client/directives/mt-markdown-editor.client.directive.js +++ b/modules/core/client/directives/mt-markdown-editor.client.directive.js @@ -24,7 +24,7 @@ language: localStorageService.get('storage_user_lang'), fullscreen: {enable: false}, onChange: function (e) { - ngModel.$setViewValue($('#postContent')[0].value); + ngModel.$setViewValue($('#' + attrs.mtMarkdownEditor)[0].value); } }); } diff --git a/modules/forums/client/controllers/forums-topic.client.controller.js b/modules/forums/client/controllers/forums-topic.client.controller.js index 63deda06..702b1d36 100644 --- a/modules/forums/client/controllers/forums-topic.client.controller.js +++ b/modules/forums/client/controllers/forums-topic.client.controller.js @@ -6,10 +6,10 @@ .controller('ForumsTopicController', ForumsTopicController); ForumsTopicController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsService', 'ScoreLevelService', '$filter', 'NotifycationService', - 'marked', 'ModalConfirmService', '$stateParams', 'TopicsService']; + 'marked', 'ModalConfirmService', '$stateParams', 'TopicsService', 'localStorageService', '$compile']; function ForumsTopicController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsService, ScoreLevelService, $filter, NotifycationService, - marked, ModalConfirmService, $stateParams, TopicsService) { + marked, ModalConfirmService, $stateParams, TopicsService, localStorageService, $compile) { var vm = this; vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig; vm.user = Authentication.user; @@ -68,5 +68,84 @@ var s = ScoreLevelService.getScoreLevelJson(vm.user.score); return s.currLevel; }; + + /** + * isTopicOwner + * @param t + * @returns {boolean} + */ + vm.isTopicOwner = function (t) { + if (t.user._id.str === vm.user._id) { + return true; + } else { + return false; + } + }; + + /** + * canEditTopic + * @param t + * @returns {boolean} + */ + vm.canEditTopic = function (t) { + if (vm.isTopicOwner(t) || vm.user.isOper) { + return true; + } else { + return false; + } + }; + + /** + * beginEditReply + * @param t + */ + vm.beginEditReply = function (t) { + var el = $('#' + t._id); + + el.markdown({ + autofocus: true, + savable: true, + hideable: true, + iconlibrary: 'fa', + resize: 'vertical', + language: localStorageService.get('storage_user_lang'), + fullscreen: {enable: false}, + onSave: function (e) { + if (e.isDirty()) { + //save content + t.content = e.getContent(); + t.$update(function (res) { + vm.topic = res; + NotifycationService.showSuccessNotify('FORUMS.REPLY_EDIT_SUCCESSFULLY'); + }, function (res) { + NotifycationService.showErrorNotify(res.data.message, 'FORUMS.REPLY_EDIT_FAILED'); + }); + + e.$options.hideable = true; + e.blur(); + } else { + e.$options.hideable = true; + e.blur(); + } + }, + onChange: function (e) { + e.$options.hideable = false; + }, + onShow: function (e) { + e.setContent(t.content); + + $('.md-footer').addClass('text-right'); + $('.md-footer')[0].childNodes[0].innerText = $translate.instant('FORUMS.BTN_SAVE'); + + var cbtn = angular.element(''); + cbtn.bind('click', function (evt) { + e.$options.hideable = true; + e.blur(); + }); + $('.md-footer').append(cbtn); + $compile($('.md-footer').contents())($scope); + } + }); + }; } }()); diff --git a/modules/forums/client/less/forum.less b/modules/forums/client/less/forum.less index e0577970..f2561526 100644 --- a/modules/forums/client/less/forum.less +++ b/modules/forums/client/less/forum.less @@ -301,7 +301,6 @@ border-top-right-radius: 3px; min-height: 42px; .reply-comment-header-text { - max-width: 70%; padding-top: 10px; padding-bottom: 10px; .user-ud-text { @@ -314,18 +313,30 @@ color: lighten(@gray-base, 60%); margin-left: 5px; } + .reply-comment-header-command { + margin-right: 15px; + .fa { + margin: 0 5px; + cursor: pointer; + &:hover { + color: @brand-primary + } + } + } } .reply-comment-body { - padding-right: 15px; - padding-left: 15px; + padding: 10px 15px; min-height: 42px; .reply-comment-body-text { - padding-top: 10px; + p:last-child { + margin-bottom: 0px; + } } .reply-comment-body-edited-text { font-size: 12px; color: lighten(@gray-base, 60%); margin-right: 15px; + margin-bottom: 0; } } } diff --git a/modules/forums/client/services/topics.client.service.js b/modules/forums/client/services/topics.client.service.js index 31b5dd5f..3fa59ce9 100644 --- a/modules/forums/client/services/topics.client.service.js +++ b/modules/forums/client/services/topics.client.service.js @@ -9,8 +9,8 @@ function TopicsService($resource) { return $resource('/api/topics/:forumId/:topicId', { - forumId: '@_forumId', - topicId: '@_topicId' + forumId: '@forum', + topicId: '@_id' }, { update: { method: 'PUT' diff --git a/modules/forums/client/views/post.client.view.html b/modules/forums/client/views/post.client.view.html index 7333810b..184faa7b 100644 --- a/modules/forums/client/views/post.client.view.html +++ b/modules/forums/client/views/post.client.view.html @@ -52,7 +52,7 @@
{{ 'FORUMS.PC_REQUIRED' | translate}}
diff --git a/modules/forums/client/views/topic.client.view.html b/modules/forums/client/views/topic.client.view.html index 526ca718..9a881195 100644 --- a/modules/forums/client/views/topic.client.view.html +++ b/modules/forums/client/views/topic.client.view.html @@ -79,7 +79,8 @@