Filter on site settings across all categories
This commit is contained in:
@@ -15,31 +15,47 @@ Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.P
|
||||
|
||||
@property filteredContent
|
||||
**/
|
||||
filteredContent: function() {
|
||||
filterContent: function() {
|
||||
|
||||
// If we have no content, don't bother filtering anything
|
||||
if (!this.present('content')) return null;
|
||||
if (!this.present('allSiteSettings')) return;
|
||||
|
||||
var filter;
|
||||
if (this.get('filter')) {
|
||||
filter = this.get('filter').toLowerCase();
|
||||
}
|
||||
|
||||
var adminSettingsController = this;
|
||||
if ((filter === undefined || filter.length < 1) && !this.get('onlyOverridden')) {
|
||||
this.set('model', this.get('allSiteSettings'));
|
||||
return;
|
||||
}
|
||||
|
||||
var maxResults = Em.isNone(filter) ? this.get('content.length') : 20;
|
||||
return _.first(this.get('content').filter(function(item, index, enumerable) {
|
||||
if (adminSettingsController.get('onlyOverridden') && !item.get('overridden')) return false;
|
||||
if (filter) {
|
||||
if (item.get('setting').toLowerCase().indexOf(filter) > -1) return true;
|
||||
if (item.get('description').toLowerCase().indexOf(filter) > -1) return true;
|
||||
if (item.get('value').toLowerCase().indexOf(filter) > -1) return true;
|
||||
return false;
|
||||
var self = this,
|
||||
matches,
|
||||
matchesGroupedByCategory = Em.A();
|
||||
|
||||
_.each(this.get('allSiteSettings'), function(settingsCategory) {
|
||||
matches = settingsCategory.siteSettings.filter(function(item) {
|
||||
if (self.get('onlyOverridden') && !item.get('overridden')) return false;
|
||||
if (filter) {
|
||||
if (item.get('setting').toLowerCase().indexOf(filter) > -1) return true;
|
||||
if (item.get('description').toLowerCase().indexOf(filter) > -1) return true;
|
||||
if (item.get('value').toLowerCase().indexOf(filter) > -1) return true;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (matches.length > 0) {
|
||||
matchesGroupedByCategory.pushObject({
|
||||
nameKey: settingsCategory.nameKey,
|
||||
name: settingsCategory.name,
|
||||
siteSettings: matches});
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}), maxResults);
|
||||
}.property('filter', 'content.@each', 'onlyOverridden'),
|
||||
this.set('model', matchesGroupedByCategory);
|
||||
}.observes('filter', 'onlyOverridden'),
|
||||
|
||||
actions: {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user