Add confirmation modal to admin group deletion
This commit is contained in:
committed by
Michael Campagnaro
parent
58e7c3e1f3
commit
9616767bff
@@ -33,12 +33,16 @@ Discourse.AdminGroupsController = Ember.Controller.extend({
|
||||
},
|
||||
|
||||
destroy: function(group){
|
||||
var list = this.get("model");
|
||||
if(group.get("id")){
|
||||
group.destroy().then(function(){
|
||||
list.removeObject(group);
|
||||
});
|
||||
}
|
||||
var _this = this;
|
||||
return bootbox.confirm(I18n.t("admin.groups.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
||||
if (result) {
|
||||
group.destroy().then(function(deleted) {
|
||||
if (deleted) {
|
||||
_this.get("model").removeObject(group);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -36,12 +36,18 @@ Discourse.Group = Discourse.Model.extend({
|
||||
}.property('users'),
|
||||
|
||||
destroy: function(){
|
||||
if(!this.id) return;
|
||||
|
||||
var group = this;
|
||||
group.set('disableSave', true);
|
||||
|
||||
return Discourse.ajax("/admin/groups/" + this.get("id"), {type: "DELETE"})
|
||||
return Discourse.ajax("/admin/groups/" + group.id, {type: "DELETE"})
|
||||
.then(function(){
|
||||
return true;
|
||||
}, function(jqXHR, status, error) {
|
||||
group.set('disableSave', false);
|
||||
bootbox.alert(I18n.t("admin.groups.delete_failed"));
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user