FIX: Category permissions were broken

This commit is contained in:
Robin Ward 2015-09-05 11:39:56 -04:00
parent fa7d38a773
commit 73526e1211
2 changed files with 17 additions and 11 deletions

View File

@ -1,19 +1,24 @@
import RestModel from 'discourse/models/rest';
import { on } from 'ember-addons/ember-computed-decorators';
const Category = RestModel.extend({
init: function() {
this._super();
var availableGroups = Em.A(this.get("available_groups"));
@on('init')
setupGroupsAndPermissions() {
const availableGroups = this.get('available_groups');
if (!availableGroups) { return; }
this.set("availableGroups", availableGroups);
this.set("permissions", Em.A(_.map(this.group_permissions, function(elem){
availableGroups.removeObject(elem.group_name);
return {
group_name: elem.group_name,
permission: Discourse.PermissionType.create({id: elem.permission_type})
};
})));
const groupPermissions = this.get('group_permissions');
if (groupPermissions) {
this.set('permissions', groupPermissions.map((elem) => {
availableGroups.removeObject(elem.group_name);
return {
group_name: elem.group_name,
permission: Discourse.PermissionType.create({id: elem.permission_type})
};
}));
}
},
availablePermissions: function(){

View File

@ -129,6 +129,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
editCategory(category) {
Category.reloadById(category.get('id')).then((atts) => {
const model = this.store.createRecord('category', atts.category);
model.setupGroupsAndPermissions();
this.site.updateCategory(model);
showModal('editCategory', { model });
this.controllerFor('editCategory').set('selectedTab', 'general');