Merge pull request #3782 from getabetterpic/fix-new-group-bug
Fix bug when adding new custom group
This commit is contained in:
commit
e0c12e5a32
|
@ -75,13 +75,14 @@ export default Ember.Controller.extend({
|
|||
|
||||
save() {
|
||||
const group = this.get('model'),
|
||||
groupsController = this.get("controllers.adminGroupsType");
|
||||
groupsController = this.get("controllers.adminGroupsType"),
|
||||
groupType = groupsController.get("type");
|
||||
|
||||
this.set('disableSave', true);
|
||||
|
||||
let promise = group.get("id") ? group.save() : group.create().then(() => groupsController.addObject(group));
|
||||
|
||||
promise.then(() => this.transitionToRoute("adminGroup", group))
|
||||
promise.then(() => this.transitionToRoute("adminGroup", groupType, group.get('name')))
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => this.set('disableSave', false));
|
||||
},
|
||||
|
@ -91,6 +92,11 @@ export default Ember.Controller.extend({
|
|||
groupsController = this.get('controllers.adminGroupsType'),
|
||||
self = this;
|
||||
|
||||
if (!group.get('id')) {
|
||||
self.transitionToRoute('adminGroupsType.index', 'custom');
|
||||
return;
|
||||
}
|
||||
|
||||
this.set('disableSave', true);
|
||||
|
||||
bootbox.confirm(
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
import Group from 'discourse/models/group';
|
||||
|
||||
export default Discourse.Route.extend({
|
||||
|
||||
model: function(params) {
|
||||
var groups = this.modelFor('adminGroupsType'),
|
||||
group = groups.findProperty('name', params.name);
|
||||
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'); }
|
||||
|
||||
|
|
|
@ -9,15 +9,5 @@ export default Discourse.Route.extend({
|
|||
setupController(controller, model){
|
||||
controller.set("type", this.get("type"));
|
||||
controller.set("model", model);
|
||||
},
|
||||
|
||||
actions: {
|
||||
newGroup() {
|
||||
const self = this;
|
||||
this.transitionTo("adminGroupsType", "custom").then(function() {
|
||||
var group = Discourse.Group.create({ automatic: false, visible: true });
|
||||
self.transitionTo("adminGroup", group);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
{{/each}}
|
||||
</ul>
|
||||
<div class='controls'>
|
||||
{{d-button action="newGroup" icon="plus" label="admin.groups.new"}}
|
||||
{{#link-to 'adminGroup' 'new' class="btn"}}
|
||||
{{fa-icon "plus"}} {{i18n 'admin.groups.new'}}
|
||||
{{/link-to}}
|
||||
{{#if controller.isAuto}}
|
||||
{{d-button action="refreshAutoGroups" icon="refresh" label="admin.groups.refresh" disabled=refreshingAutoGroups}}
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue