BUGFIX: incorrect ordering in category permissions

FEATURE: UI for categories that we allow badges on
This commit is contained in:
Sam 2014-07-10 12:01:46 +10:00
parent 928848c0a8
commit 2f8d139ec0
7 changed files with 30 additions and 6 deletions

View File

@ -10,9 +10,11 @@ Discourse.Category = Discourse.Model.extend({
init: function() {
this._super();
this.set("availableGroups", Em.A(this.get("available_groups")));
var availableGroups = Em.A(this.get("available_groups"));
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})
@ -70,7 +72,8 @@ Discourse.Category = Discourse.Model.extend({
email_in_allow_strangers: this.get('email_in_allow_strangers'),
parent_category_id: this.get('parent_category_id'),
logo_url: this.get('logo_url'),
background_url: this.get('background_url')
background_url: this.get('background_url'),
allow_badges: this.get('allow_badges')
},
type: this.get('id') ? 'PUT' : 'POST'
});

View File

@ -44,7 +44,8 @@ Discourse.DiscoveryCategoriesRoute = Discourse.Route.extend(Discourse.OpenCompos
createCategory: function() {
Discourse.Route.showModal(this, 'editCategory', Discourse.Category.create({
color: 'AB9364', text_color: 'FFFFFF', group_permissions: [{group_name: 'everyone', permission_type: 1}],
available_groups: Discourse.Site.current().group_names
available_groups: Discourse.Site.current().group_names,
allow_badges: true
}));
this.controllerFor('editCategory').set('selectedTab', 'general');
},

View File

@ -9,6 +9,15 @@
</div>
</section>
<section class='field'>
<div class="allow-badges">
<div>
{{input type="checkbox" checked=allow_badges}}
{{i18n category.allow_badges_label}}
</div>
</div>
</section>
{{#if emailInEnabled}}
<section class='field'>
<div class="email-in-fields">

View File

@ -119,7 +119,16 @@ class CategoriesController < ApplicationController
end
end
params.permit(*required_param_keys, :position, :email_in, :email_in_allow_strangers, :parent_category_id, :auto_close_hours, :logo_url, :background_url, :permissions => [*p.try(:keys)])
params.permit(*required_param_keys,
:position,
:email_in,
:email_in_allow_strangers,
:parent_category_id,
:auto_close_hours,
:logo_url,
:background_url,
:allow_badges,
:permissions => [*p.try(:keys)])
end
end

View File

@ -30,7 +30,7 @@ class Site
end
def group_names
@group_name ||= Group.pluck(:name)
@group_name ||= Group.order(:name).pluck(:name)
end
def categories

View File

@ -7,7 +7,8 @@ class CategorySerializer < BasicCategorySerializer
:position,
:email_in,
:email_in_allow_strangers,
:can_delete
:can_delete,
:allow_badges
def group_permissions
@group_permissions ||= begin

View File

@ -1185,6 +1185,7 @@ en:
auto_close_units: "hours"
email_in: "Custom incoming email address:"
email_in_allow_strangers: "Accept emails from anonymous users with no accounts"
allow_badges_label: "Allow badges"
edit_permissions: "Edit Permissions"
add_permission: "Add Permission"
this_year: "this year"