Add an All Results tab when filtering the site settings

This commit is contained in:
Neil Lalonde 2013-11-15 16:43:56 -05:00
parent 97bc187735
commit d3c84b60c8
5 changed files with 22 additions and 3 deletions

View File

@ -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: {
/**

View File

@ -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,

View File

@ -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')
});
}
});

View File

@ -16,6 +16,9 @@
<li {{bindAttr class="category.nameKey"}}>
{{#link-to 'adminSiteSettingsCategory' category.nameKey class=category.nameKey}}
{{category.name}}
{{#if filtered}}
<span class="count">({{category.siteSettings.length}})</span>
{{/if}}
<span class='icon-chevron-right'></span>
{{/link-to}}
</li>

View File

@ -1418,6 +1418,7 @@ en:
reset: 'reset to default'
none: 'none'
categories:
all_results: 'All Results'
required: 'Required'
basic: 'Basic Setup'
users: 'Users'