diff --git a/app/assets/javascripts/admin/controllers/admin_site_settings_category_controller.js b/app/assets/javascripts/admin/controllers/admin_site_settings_category_controller.js index 3c5aac58054..60b46223445 100644 --- a/app/assets/javascripts/admin/controllers/admin_site_settings_category_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_site_settings_category_controller.js @@ -16,6 +16,16 @@ Discourse.AdminSiteSettingsCategoryController = Ember.ObjectController.extend({ } }.property('controllers.adminSiteSettings.content', 'categoryNameKey'), + emptyContentHandler: function() { + if (this.get('filteredContent').length < 1) { + if ( this.get('controllers.adminSiteSettings.filtered') ) { + this.transitionToRoute('adminSiteSettingsCategory', 'all_results'); + } else { + this.transitionToRoute('adminSiteSettings'); + } + } + }.observes('filteredContent'), + actions: { /** diff --git a/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js b/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js index 3aaac85dc81..758bddb98e5 100644 --- a/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js @@ -9,6 +9,7 @@ Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, { filter: null, onlyOverridden: false, + filtered: Ember.computed.notEmpty('filter'), /** The list of settings based on the current filters @@ -32,7 +33,7 @@ Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.P var self = this, matches, - matchesGroupedByCategory = Em.A(); + matchesGroupedByCategory = Em.A([{nameKey: 'all_results', name: I18n.t('admin.site_settings.categories.all_results'), siteSettings: []}]); _.each(this.get('allSiteSettings'), function(settingsCategory) { matches = settingsCategory.siteSettings.filter(function(item) { @@ -47,6 +48,7 @@ Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.P } }); if (matches.length > 0) { + matchesGroupedByCategory[0].siteSettings.pushObjects(matches); matchesGroupedByCategory.pushObject({ nameKey: settingsCategory.nameKey, name: settingsCategory.name, diff --git a/app/assets/javascripts/admin/routes/admin_site_settings_category_route.js b/app/assets/javascripts/admin/routes/admin_site_settings_category_route.js index 9e463c80547..b07967e970b 100644 --- a/app/assets/javascripts/admin/routes/admin_site_settings_category_route.js +++ b/app/assets/javascripts/admin/routes/admin_site_settings_category_route.js @@ -8,9 +8,12 @@ **/ Discourse.AdminSiteSettingsCategoryRoute = Discourse.Route.extend({ model: function(params) { + // The model depends on user input, so let the controller do the work: this.controllerFor('adminSiteSettingsCategory').set('categoryNameKey', params.category_id); - return this.modelFor('adminSiteSettings').find(function(category) { - return category.nameKey === params.category_id; + return Em.Object.create({ + nameKey: params.category_id, + name: I18n.t('admin.site_settings.categories.' + params.category_id), + siteSettings: this.controllerFor('adminSiteSettingsCategory').get('filteredContent') }); } }); diff --git a/app/assets/javascripts/admin/templates/site_settings.js.handlebars b/app/assets/javascripts/admin/templates/site_settings.js.handlebars index f977f126a6d..29927e55cdc 100644 --- a/app/assets/javascripts/admin/templates/site_settings.js.handlebars +++ b/app/assets/javascripts/admin/templates/site_settings.js.handlebars @@ -16,6 +16,9 @@
  • {{#link-to 'adminSiteSettingsCategory' category.nameKey class=category.nameKey}} {{category.name}} + {{#if filtered}} + ({{category.siteSettings.length}}) + {{/if}} {{/link-to}}
  • diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index d9f0195e110..97aab706fab 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1418,6 +1418,7 @@ en: reset: 'reset to default' none: 'none' categories: + all_results: 'All Results' required: 'Required' basic: 'Basic Setup' users: 'Users'