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'), }.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: { actions: {
/** /**

View File

@ -9,6 +9,7 @@
Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, { Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, {
filter: null, filter: null,
onlyOverridden: false, onlyOverridden: false,
filtered: Ember.computed.notEmpty('filter'),
/** /**
The list of settings based on the current filters The list of settings based on the current filters
@ -32,7 +33,7 @@ Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.P
var self = this, var self = this,
matches, 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) { _.each(this.get('allSiteSettings'), function(settingsCategory) {
matches = settingsCategory.siteSettings.filter(function(item) { matches = settingsCategory.siteSettings.filter(function(item) {
@ -47,6 +48,7 @@ Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.P
} }
}); });
if (matches.length > 0) { if (matches.length > 0) {
matchesGroupedByCategory[0].siteSettings.pushObjects(matches);
matchesGroupedByCategory.pushObject({ matchesGroupedByCategory.pushObject({
nameKey: settingsCategory.nameKey, nameKey: settingsCategory.nameKey,
name: settingsCategory.name, name: settingsCategory.name,

View File

@ -8,9 +8,12 @@
**/ **/
Discourse.AdminSiteSettingsCategoryRoute = Discourse.Route.extend({ Discourse.AdminSiteSettingsCategoryRoute = Discourse.Route.extend({
model: function(params) { model: function(params) {
// The model depends on user input, so let the controller do the work:
this.controllerFor('adminSiteSettingsCategory').set('categoryNameKey', params.category_id); this.controllerFor('adminSiteSettingsCategory').set('categoryNameKey', params.category_id);
return this.modelFor('adminSiteSettings').find(function(category) { return Em.Object.create({
return category.nameKey === params.category_id; 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"}}> <li {{bindAttr class="category.nameKey"}}>
{{#link-to 'adminSiteSettingsCategory' category.nameKey class=category.nameKey}} {{#link-to 'adminSiteSettingsCategory' category.nameKey class=category.nameKey}}
{{category.name}} {{category.name}}
{{#if filtered}}
<span class="count">({{category.siteSettings.length}})</span>
{{/if}}
<span class='icon-chevron-right'></span> <span class='icon-chevron-right'></span>
{{/link-to}} {{/link-to}}
</li> </li>

View File

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