From 2d6759d5a02feff6d55c075928d3c04fdf410146 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 5 Sep 2013 15:54:16 -0400 Subject: [PATCH] Add cancel button to delete replies dialog --- .../discourse/controllers/topic_controller.js | 38 ++++++++++--------- .../stylesheets/application/modal.css.scss | 4 ++ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic_controller.js b/app/assets/javascripts/discourse/controllers/topic_controller.js index 549682818da..4cec2cab213 100644 --- a/app/assets/javascripts/discourse/controllers/topic_controller.js +++ b/app/assets/javascripts/discourse/controllers/topic_controller.js @@ -463,24 +463,26 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected // If the user is staff and the post has replies, ask if they want to delete replies too. if (user.get('staff') && replyCount > 0) { - bootbox.confirm(I18n.t("post.controls.delete_replies.confirm", {count: replyCount}), - I18n.t("post.controls.delete_replies.no_value"), - I18n.t("post.controls.delete_replies.yes_value"), - function(result) { - - // If the user wants to delete replies, do that, otherwise delete the post as normal. - if (result) { - Discourse.Post.deleteMany([post], [post]); - self.get('postStream.posts').forEach(function (p) { - if (p === post || p.get('reply_to_post_number') === post.get('post_number')) { - p.setDeletedState(user); - } - }); - } else { - post.destroy(user); - } - - }); + bootbox.dialog(I18n.t("post.controls.delete_replies.confirm", {count: replyCount}), [ + {label: I18n.t("cancel"), + 'class': 'btn-danger right'}, + {label: I18n.t("post.controls.delete_replies.no_value"), + callback: function() { + post.destroy(user); + } + }, + {label: I18n.t("post.controls.delete_replies.yes_value"), + 'class': 'btn-primary', + callback: function() { + Discourse.Post.deleteMany([post], [post]); + self.get('postStream.posts').forEach(function (p) { + if (p === post || p.get('reply_to_post_number') === post.get('post_number')) { + p.setDeletedState(user); + } + }); + } + }, + ]); } else { post.destroy(user); } diff --git a/app/assets/stylesheets/application/modal.css.scss b/app/assets/stylesheets/application/modal.css.scss index 8cca44b6b17..ba2333c9b1a 100644 --- a/app/assets/stylesheets/application/modal.css.scss +++ b/app/assets/stylesheets/application/modal.css.scss @@ -126,6 +126,10 @@ margin-left: 5px; margin-bottom: 0; } +.modal-footer .btn.right { + float: right; +} + .modal-footer .btn-group .btn + .btn { margin-left: -1px; }