diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 6718f038..1f6b1af2 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -622,8 +622,14 @@ BTN_ADD_FORUM: 'Add New Forum', BTN_EDIT_FORUM: 'Edit Forum', BTN_ADD: '  Add   ', + BTN_EDIT: '  Edit   ', + BTN_DELETE: ' Delete  ', ADD_SUCCESSFULLY: 'Forum added successfully', ADD_FAILED: 'Forum added failed', + EDIT_SUCCESSFULLY: 'Forum edited successfully', + EDIT_FAILED: 'Forum edited failed', + DELETE_SUCCESSFULLY: 'Forum deleted successfully', + DELETE_FAILED: 'Forum deleted failed', CATEGORY: { AFFAIRS: 'Affairs', DISCUSS: 'Discuss', @@ -633,6 +639,7 @@ NAME: 'Forum Name', ORDER: 'Forum Order', CMD: 'Command', + MODERATORS: 'Moderators', DESC: 'Description', CATEGORY: 'Category', READONLY: 'Only oper/admin can post new topic' diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 58a88e78..5cdf5382 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -621,9 +621,15 @@ FORUMS: { BTN_ADD_FORUM: '添加版块', BTN_EDIT_FORUM: '编辑版块', - BTN_ADD: '  添加   ', + BTN_ADD: '  添加  ', + BTN_EDIT: '  编辑  ', + BTN_DELETE: ' 删除  ', ADD_SUCCESSFULLY: '版块添加成功', ADD_FAILED: '版块添加失败', + EDIT_SUCCESSFULLY: '版块编辑成功', + EDIT_FAILED: '版块编辑失败', + DELETE_SUCCESSFULLY: '版块删除成功', + DELETE_FAILED: '版块删除失败', CATEGORY: { AFFAIRS: '站务区', DISCUSS: '讨论区', @@ -633,6 +639,7 @@ NAME: '版块名称', ORDER: '版块序号', CMD: '操作选项', + MODERATORS: '版主', DESC: '描述', CATEGORY: '分类', READONLY: '只有管理员可以发起新话题' diff --git a/modules/forums/client/controllers/forums.client.controller.js b/modules/forums/client/controllers/forums.client.controller.js index 1d3a42a9..5e6ff700 100644 --- a/modules/forums/client/controllers/forums.client.controller.js +++ b/modules/forums/client/controllers/forums.client.controller.js @@ -5,15 +5,15 @@ .module('forums') .controller('ForumsController', ForumsController); - ForumsController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsAdminService', 'SideOverlay', '$filter', 'NotifycationService']; + ForumsController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsAdminService', 'SideOverlay', '$filter', 'NotifycationService', + 'marked']; - function ForumsController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsAdminService, SideOverlay, $filter, NotifycationService) { + function ForumsController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsAdminService, SideOverlay, $filter, NotifycationService, + marked) { var vm = this; vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig; vm.user = Authentication.user; - vm.forum = {}; - /** * init */ @@ -25,24 +25,35 @@ }; /** - * openSideOverlay + * popupCreateForum * @param evt */ - vm.openSideOverlay = function (evt, f) { - if (f) { - vm.forum = f; - } else { - vm.forum = { - name: '', - desc: '', - category: 'discuss', - order: 0, - readOnly: false - }; - } + vm.popupCreateForum = function (evt) { + vm.forum = { + name: '', + desc: '', + category: 'discuss', + order: 0, + readOnly: false + }; + + vm.actionTitle = 'FORUMS.BTN_ADD_FORUM'; + vm.isEdit = false; vm.categoryChanged(); SideOverlay.open(evt, 'popupSlide'); }; + /** + * popupEditForum + * @param evt + */ + vm.popupEditForum = function (evt, f) { + if (f) { + vm.forum = f; + vm.actionTitle = 'FORUMS.BTN_EDIT_FORUM'; + vm.isEdit = true; + SideOverlay.open(evt, 'popupSlide'); + } + }; /** * @@ -62,14 +73,42 @@ var f = new ForumsAdminService(vm.forum); f.$save(function (res) { NotifycationService.showSuccessNotify('FORUMS.ADD_SUCCESSFULLY'); - vm.forum = {}; + vm.forum = undefined; SideOverlay.close(null, 'popupSlide'); - $state.reload(); + vm.init(); }, function (res) { NotifycationService.showErrorNotify(res.data.message, 'FORUMS.ADD_FAILED'); }); }; + /** + * editForum + */ + vm.editForum = function () { + vm.forum.$update(function (res) { + NotifycationService.showSuccessNotify('FORUMS.EDIT_SUCCESSFULLY'); + vm.forum = undefined; + SideOverlay.close(null, 'popupSlide'); + vm.init(); + }, function (res) { + NotifycationService.showErrorNotify(res.data.message, 'FORUMS.EDIT_FAILED'); + }); + }; + + /** + * deleteForum + */ + vm.deleteForum = function () { + vm.forum.$remove(function (res) { + NotifycationService.showSuccessNotify('FORUMS.DELETE_SUCCESSFULLY'); + vm.forum = undefined; + SideOverlay.close(null, 'popupSlide'); + vm.init(); + }, function (res) { + NotifycationService.showErrorNotify(res.data.message, 'FORUMS.DELETE_FAILED'); + }); + }; + /** * getForumDesc * @param f diff --git a/modules/forums/client/less/forum.less b/modules/forums/client/less/forum.less index 75d312a1..f4454494 100644 --- a/modules/forums/client/less/forum.less +++ b/modules/forums/client/less/forum.less @@ -27,5 +27,6 @@ .forum-list { .forum-desc { word-break: break-all; + color: #999; } } diff --git a/modules/forums/client/services/forums.client.service.js b/modules/forums/client/services/forums.client.service.js index 0fd06b22..0991999e 100644 --- a/modules/forums/client/services/forums.client.service.js +++ b/modules/forums/client/services/forums.client.service.js @@ -9,7 +9,7 @@ function ForumsAdminService($resource) { return $resource('/api/admin/forums/:forumId', { - forumId: '@_Id' + forumId: '@_id' }, { update: { method: 'PUT' @@ -25,7 +25,7 @@ function ForumsService($resource) { return $resource('/api/forums/:forumId', { - forumId: '@_Id' + forumId: '@_id' }, { update: { method: 'PUT' diff --git a/modules/forums/client/views/admin/configure.client.view.html b/modules/forums/client/views/admin/configure.client.view.html index 9608e7e5..d7c4fff6 100644 --- a/modules/forums/client/views/admin/configure.client.view.html +++ b/modules/forums/client/views/admin/configure.client.view.html @@ -1,7 +1,7 @@
- +
@@ -16,13 +16,13 @@ {{'FORUMS.FIELDS.NAME' | translate}} {{'FORUMS.FIELDS.ORDER' | translate}} - {{'FORUMS.FIELDS.CMD' | translate}} + {{'FORUMS.FIELDS.MODERATORS' | translate}} -

{{f.name}} R

+

{{f.name}} R[Edit]

@@ -38,7 +38,7 @@
-

{{'FORUMS.BTN_ADD_FORUM' | translate}}

+

{{vm.actionTitle | translate}}

  • @@ -88,8 +88,19 @@
    + +
    diff --git a/modules/forums/server/controllers/forums.admin.server.controller.js b/modules/forums/server/controllers/forums.admin.server.controller.js index d6fcd828..f3c2f3da 100644 --- a/modules/forums/server/controllers/forums.admin.server.controller.js +++ b/modules/forums/server/controllers/forums.admin.server.controller.js @@ -61,6 +61,7 @@ exports.update = function (req, res) { forum.desc = req.body.desc; forum.order = req.body.order; forum.readOnly = req.body.readOnly; + forum.category = req.body.category; forum.save(function (err) { if (err) {