Skip to content

Commit

Permalink
Add cancel button to delete replies dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed Sep 5, 2013
1 parent 73711bc commit 2d6759d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
38 changes: 20 additions & 18 deletions app/assets/javascripts/discourse/controllers/topic_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application/modal.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2d6759d

Please sign in to comment.