From 15b53ef6285640531ec2c1ccdb15cf1124d2d684 Mon Sep 17 00:00:00 2001 From: OldHawk Date: Tue, 4 Jul 2017 13:18:30 +0800 Subject: [PATCH] feat(forums): add delete CONFIRM --- modules/core/client/app/trans-string-en.js | 4 +++ modules/core/client/app/trans-string-zh.js | 4 +++ .../controllers/forums.client.controller.js | 30 ++++++++++++------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 1f6b1af2..66a06ebd 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -630,6 +630,10 @@ EDIT_FAILED: 'Forum edited failed', DELETE_SUCCESSFULLY: 'Forum deleted successfully', DELETE_FAILED: 'Forum deleted failed', + DELETE_CONFIRM_OK: 'Delete', + DELETE_CONFIRM_CANCEL: 'Cancel', + DELETE_CONFIRM_HEADER_TEXT: 'Delete Confirm', + DELETE_CONFIRM_BODY_TEXT: 'Are you sure want to delete this forum?', CATEGORY: { AFFAIRS: 'Affairs', DISCUSS: 'Discuss', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 5cdf5382..93ded9e4 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -630,6 +630,10 @@ EDIT_FAILED: '版块编辑失败', DELETE_SUCCESSFULLY: '版块删除成功', DELETE_FAILED: '版块删除失败', + DELETE_CONFIRM_OK: '删除', + DELETE_CONFIRM_CANCEL: '取消', + DELETE_CONFIRM_HEADER_TEXT: '删除确认', + DELETE_CONFIRM_BODY_TEXT: '您确定要删除这个版块吗?', CATEGORY: { AFFAIRS: '站务区', DISCUSS: '讨论区', diff --git a/modules/forums/client/controllers/forums.client.controller.js b/modules/forums/client/controllers/forums.client.controller.js index 5e6ff700..f423dd10 100644 --- a/modules/forums/client/controllers/forums.client.controller.js +++ b/modules/forums/client/controllers/forums.client.controller.js @@ -6,10 +6,10 @@ .controller('ForumsController', ForumsController); ForumsController.$inject = ['$scope', '$state', '$translate', 'Authentication', 'MeanTorrentConfig', 'ForumsAdminService', 'SideOverlay', '$filter', 'NotifycationService', - 'marked']; + 'marked', 'ModalConfirmService']; function ForumsController($scope, $state, $translate, Authentication, MeanTorrentConfig, ForumsAdminService, SideOverlay, $filter, NotifycationService, - marked) { + marked, ModalConfirmService) { var vm = this; vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig; vm.user = Authentication.user; @@ -99,14 +99,24 @@ * 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'); - }); + var modalOptions = { + closeButtonText: $translate.instant('FORUMS.DELETE_CONFIRM_CANCEL'), + actionButtonText: $translate.instant('FORUMS.DELETE_CONFIRM_OK'), + headerText: $translate.instant('FORUMS.DELETE_CONFIRM_HEADER_TEXT'), + bodyText: $translate.instant('FORUMS.DELETE_CONFIRM_BODY_TEXT') + }; + + ModalConfirmService.showModal({}, modalOptions) + .then(function (result) { + 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'); + }); + }); }; /**