FIX: Category permissions were broken
This commit is contained in:
parent
fa7d38a773
commit
73526e1211
|
@ -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(){
|
||||||
|
|
|
@ -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');
|
||||||
|
|
Loading…
Reference in New Issue