Add cancel button to delete replies dialog

This commit is contained in:
Robin Ward 2013-09-05 15:54:16 -04:00
parent 73711bc4b8
commit 2d6759d5a0
2 changed files with 24 additions and 18 deletions

View File

@ -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 the user is staff and the post has replies, ask if they want to delete replies too.
if (user.get('staff') && replyCount > 0) { if (user.get('staff') && replyCount > 0) {
bootbox.confirm(I18n.t("post.controls.delete_replies.confirm", {count: replyCount}), bootbox.dialog(I18n.t("post.controls.delete_replies.confirm", {count: replyCount}), [
I18n.t("post.controls.delete_replies.no_value"), {label: I18n.t("cancel"),
I18n.t("post.controls.delete_replies.yes_value"), 'class': 'btn-danger right'},
function(result) { {label: I18n.t("post.controls.delete_replies.no_value"),
callback: function() {
// If the user wants to delete replies, do that, otherwise delete the post as normal. post.destroy(user);
if (result) { }
},
{label: I18n.t("post.controls.delete_replies.yes_value"),
'class': 'btn-primary',
callback: function() {
Discourse.Post.deleteMany([post], [post]); Discourse.Post.deleteMany([post], [post]);
self.get('postStream.posts').forEach(function (p) { self.get('postStream.posts').forEach(function (p) {
if (p === post || p.get('reply_to_post_number') === post.get('post_number')) { if (p === post || p.get('reply_to_post_number') === post.get('post_number')) {
p.setDeletedState(user); p.setDeletedState(user);
} }
}); });
} else {
post.destroy(user);
} }
},
}); ]);
} else { } else {
post.destroy(user); post.destroy(user);
} }

View File

@ -126,6 +126,10 @@
margin-left: 5px; margin-left: 5px;
margin-bottom: 0; margin-bottom: 0;
} }
.modal-footer .btn.right {
float: right;
}
.modal-footer .btn-group .btn + .btn { .modal-footer .btn-group .btn + .btn {
margin-left: -1px; margin-left: -1px;
} }