discourse/app/assets/javascripts/admin/routes/admin-group.js.es6
getabetterpic 87725206cd Fix bug when adding new custom group
When adding a new group, if Delete was clicked before saving the
group, the modal would come up, but the Yes confirmation would
do nothing. This fixes that by taking an approach similar to the
Badges and checks to see if the Group is new, and if it is, just
returns to the index instead of invoking the confirm modal.

This also fixes the redirect after saving a new Group.
2015-09-17 10:23:58 -04:00

28 lines
606 B
JavaScript

import Group from 'discourse/models/group';
export default Discourse.Route.extend({
model: function(params) {
var groups = this.modelFor('adminGroupsType');
if (params.name === 'new') {
return Group.create({
automatic: false,
visible: true
});
}
var group = groups.findProperty('name', params.name);
if (!group) { return this.transitionTo('adminGroups.index'); }
return group;
},
setupController: function(controller, model) {
controller.set("model", model);
controller.set("model.usernames", null);
model.findMembers();
}
});