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

View File

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