2013-02-22 15:41:12 -05:00
|
|
|
/**
|
|
|
|
This controller supports the interface for SiteSettings.
|
2013-02-20 13:15:50 -05:00
|
|
|
|
2013-03-01 12:45:25 -05:00
|
|
|
@class AdminSiteSettingsController
|
2013-02-22 15:41:12 -05:00
|
|
|
@extends Ember.ArrayController
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
2013-03-01 12:45:25 -05:00
|
|
|
**/
|
2013-02-22 15:41:12 -05:00
|
|
|
Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, {
|
|
|
|
filter: null,
|
|
|
|
onlyOverridden: false,
|
2013-02-21 12:58:21 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
/**
|
|
|
|
The list of settings based on the current filters
|
2013-02-21 12:54:40 -05:00
|
|
|
|
2013-11-14 16:50:34 -05:00
|
|
|
@property filterContent
|
2013-02-22 15:41:12 -05:00
|
|
|
**/
|
2013-11-14 12:37:41 -05:00
|
|
|
filterContent: function() {
|
2013-03-01 12:45:25 -05:00
|
|
|
|
|
|
|
// If we have no content, don't bother filtering anything
|
2013-11-14 12:37:41 -05:00
|
|
|
if (!this.present('allSiteSettings')) return;
|
2013-03-01 12:45:25 -05:00
|
|
|
|
|
|
|
var filter;
|
2013-02-22 15:41:12 -05:00
|
|
|
if (this.get('filter')) {
|
|
|
|
filter = this.get('filter').toLowerCase();
|
|
|
|
}
|
2013-02-21 14:42:48 -05:00
|
|
|
|
2013-11-14 12:37:41 -05:00
|
|
|
if ((filter === undefined || filter.length < 1) && !this.get('onlyOverridden')) {
|
|
|
|
this.set('model', this.get('allSiteSettings'));
|
|
|
|
return;
|
|
|
|
}
|
2013-11-01 16:32:12 -04:00
|
|
|
|
2013-11-14 12:37:41 -05:00
|
|
|
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});
|
2013-02-20 13:15:50 -05:00
|
|
|
}
|
2013-11-14 12:37:41 -05:00
|
|
|
});
|
2013-02-21 12:58:21 -05:00
|
|
|
|
2013-11-14 12:37:41 -05:00
|
|
|
this.set('model', matchesGroupedByCategory);
|
2013-11-14 14:46:17 -05:00
|
|
|
}.observes('filter', 'onlyOverridden')
|
2013-03-01 12:45:25 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|