2013-02-23 04:41:12 +08:00
|
|
|
/**
|
|
|
|
This controller supports the interface for SiteSettings.
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2013-03-02 01:45:25 +08:00
|
|
|
@class AdminSiteSettingsController
|
2013-02-23 04:41:12 +08:00
|
|
|
@extends Ember.ArrayController
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
2013-03-02 01:45:25 +08:00
|
|
|
**/
|
2014-07-23 11:20:45 +08:00
|
|
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
2013-02-23 04:41:12 +08:00
|
|
|
filter: null,
|
|
|
|
onlyOverridden: false,
|
2013-11-16 05:43:56 +08:00
|
|
|
filtered: Ember.computed.notEmpty('filter'),
|
2013-02-22 01:58:21 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
/**
|
|
|
|
The list of settings based on the current filters
|
2013-02-22 01:54:40 +08:00
|
|
|
|
2013-11-15 05:50:34 +08:00
|
|
|
@property filterContent
|
2013-02-23 04:41:12 +08:00
|
|
|
**/
|
2013-11-16 05:46:19 +08:00
|
|
|
filterContent: Discourse.debounce(function() {
|
2013-03-02 01:45:25 +08:00
|
|
|
|
|
|
|
// If we have no content, don't bother filtering anything
|
2013-11-15 01:37:41 +08:00
|
|
|
if (!this.present('allSiteSettings')) return;
|
2013-03-02 01:45:25 +08:00
|
|
|
|
|
|
|
var filter;
|
2013-02-23 04:41:12 +08:00
|
|
|
if (this.get('filter')) {
|
|
|
|
filter = this.get('filter').toLowerCase();
|
|
|
|
}
|
2013-02-22 03:42:48 +08:00
|
|
|
|
2013-11-15 01:37:41 +08:00
|
|
|
if ((filter === undefined || filter.length < 1) && !this.get('onlyOverridden')) {
|
|
|
|
this.set('model', this.get('allSiteSettings'));
|
|
|
|
return;
|
|
|
|
}
|
2013-11-02 04:32:12 +08:00
|
|
|
|
2013-11-15 01:37:41 +08:00
|
|
|
var self = this,
|
|
|
|
matches,
|
2013-11-16 05:43:56 +08:00
|
|
|
matchesGroupedByCategory = Em.A([{nameKey: 'all_results', name: I18n.t('admin.site_settings.categories.all_results'), siteSettings: []}]);
|
2013-11-15 01:37:41 +08:00
|
|
|
|
|
|
|
_.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;
|
2014-04-07 23:14:12 +08:00
|
|
|
if (item.get('setting').toLowerCase().replace(/_/g, ' ').indexOf(filter) > -1) return true;
|
2013-11-15 01:37:41 +08:00
|
|
|
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) {
|
2013-11-16 05:43:56 +08:00
|
|
|
matchesGroupedByCategory[0].siteSettings.pushObjects(matches);
|
2013-11-15 01:37:41 +08:00
|
|
|
matchesGroupedByCategory.pushObject({
|
|
|
|
nameKey: settingsCategory.nameKey,
|
|
|
|
name: settingsCategory.name,
|
|
|
|
siteSettings: matches});
|
2013-02-21 02:15:50 +08:00
|
|
|
}
|
2013-11-15 01:37:41 +08:00
|
|
|
});
|
2013-02-22 01:58:21 +08:00
|
|
|
|
2013-11-15 01:37:41 +08:00
|
|
|
this.set('model', matchesGroupedByCategory);
|
2013-12-21 00:06:07 +08:00
|
|
|
}, 250).observes('filter', 'onlyOverridden'),
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
clearFilter: function() {
|
|
|
|
this.set('filter', '');
|
|
|
|
this.set('onlyOverridden', false);
|
|
|
|
}
|
|
|
|
}
|
2013-03-02 01:45:25 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|