From b4363de28010076dae27476694d08ff4cc80331f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 3 Dec 2014 16:03:42 +0100 Subject: [PATCH] FIX: reload current page when deleting a user --- app/assets/javascripts/admin/models/admin_user.js | 5 +++-- app/assets/javascripts/admin/routes/admin-users-list.js.es6 | 4 ++++ .../javascripts/discourse/controllers/user-card.js.es6 | 4 ---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index 816690031be..06dd114e476 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -314,9 +314,10 @@ Discourse.AdminUser = Discourse.User.extend({ destroy: function(opts) { var user = this; + var location = document.location.pathname; var performDestroy = function(block) { - var formData = { context: window.location.pathname }; + var formData = { context: location }; if (block) { formData["block_email"] = true; formData["block_urls"] = true; @@ -330,7 +331,7 @@ Discourse.AdminUser = Discourse.User.extend({ data: formData }).then(function(data) { if (data.deleted) { - document.location = "/admin/users/list/active"; + document.location = location; } else { bootbox.alert(I18n.t("admin.user.delete_failed")); if (data.user) { diff --git a/app/assets/javascripts/admin/routes/admin-users-list.js.es6 b/app/assets/javascripts/admin/routes/admin-users-list.js.es6 index 3a9c406b2c3..bf460971bb6 100644 --- a/app/assets/javascripts/admin/routes/admin-users-list.js.es6 +++ b/app/assets/javascripts/admin/routes/admin-users-list.js.es6 @@ -9,6 +9,10 @@ export default Discourse.Route.extend({ bootbox.alert(I18n.t("admin.export_csv.failed")); } }); + }, + + deleteUser: function(user) { + Discourse.AdminUser.create(user).destroy({ deletePosts: true }); } } diff --git a/app/assets/javascripts/discourse/controllers/user-card.js.es6 b/app/assets/javascripts/discourse/controllers/user-card.js.es6 index 369bf7c81a1..a3b71cfb189 100644 --- a/app/assets/javascripts/discourse/controllers/user-card.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-card.js.es6 @@ -98,10 +98,6 @@ export default ObjectController.extend({ postStream.cancelFilter(); postStream.refresh(); this.close(); - }, - - deleteUser: function(user) { - user.destroy({ deletePosts: true }); } }