discourse/app/assets/javascripts/admin/controllers/admin_site_settings_control...

74 lines
1.9 KiB
JavaScript
Raw Normal View History

/**
This controller supports the interface for SiteSettings.
@class AdminSiteSettingsController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, {
filter: null,
onlyOverridden: false,
/**
The list of settings based on the current filters
2013-02-21 12:54:40 -05:00
@property filteredContent
**/
2013-05-29 13:33:54 -04:00
filteredContent: function() {
// If we have no content, don't bother filtering anything
if (!this.present('content')) return null;
var filter;
if (this.get('filter')) {
filter = this.get('filter').toLowerCase();
}
var adminSettingsController = this;
return 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;
}
return true;
});
2013-05-29 13:33:54 -04:00
}.property('filter', 'content.@each', 'onlyOverridden'),
/**
Reset a setting to its default value
2013-02-21 12:54:40 -05:00
@method resetDefault
@param {Discourse.SiteSetting} setting The setting we want to revert
**/
resetDefault: function(setting) {
setting.set('value', setting.get('default'));
setting.save();
},
/**
Save changes to a site setting
2013-02-21 12:54:40 -05:00
@method save
@param {Discourse.SiteSetting} setting The setting we've changed
**/
save: function(setting) {
setting.save();
},
/**
Cancel changes to a site setting
@method cancel
@param {Discourse.SiteSetting} setting The setting we've changed but want to revert
**/
cancel: function(setting) {
setting.resetValue();
}
});