diff --git a/app/assets/javascripts/discourse/models/category.js b/app/assets/javascripts/discourse/models/category.js index b0382abd73b..b78421bd501 100644 --- a/app/assets/javascripts/discourse/models/category.js +++ b/app/assets/javascripts/discourse/models/category.js @@ -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' }); diff --git a/app/assets/javascripts/discourse/routes/discovery_categories_route.js b/app/assets/javascripts/discourse/routes/discovery_categories_route.js index 2910439c463..1c7ae9331e8 100644 --- a/app/assets/javascripts/discourse/routes/discovery_categories_route.js +++ b/app/assets/javascripts/discourse/routes/discovery_categories_route.js @@ -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'); }, diff --git a/app/assets/javascripts/discourse/templates/modal/edit-category-settings.js.handlebars b/app/assets/javascripts/discourse/templates/modal/edit-category-settings.js.handlebars index 5a146bd4274..8162cb6a483 100644 --- a/app/assets/javascripts/discourse/templates/modal/edit-category-settings.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/edit-category-settings.js.handlebars @@ -9,6 +9,15 @@ +
+
+
+ {{input type="checkbox" checked=allow_badges}} + {{i18n category.allow_badges_label}} +
+
+
+ {{#if emailInEnabled}}
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index cd973a7cbc0..7ed61c7c16e 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -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 diff --git a/app/models/site.rb b/app/models/site.rb index c9516f7ffa2..752f5124f37 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -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 diff --git a/app/serializers/category_serializer.rb b/app/serializers/category_serializer.rb index 4ed3e552a70..b270aec94a7 100644 --- a/app/serializers/category_serializer.rb +++ b/app/serializers/category_serializer.rb @@ -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 diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7cf00fd293b..52681f04e58 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -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"