discourse/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

(function() {
/**
This controller supports the interface for SiteSettings.
@class AdminSiteSettingsController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
window.Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, {
filter: null,
onlyOverridden: false,
2013-02-21 12:54:40 -05:00
filteredContent: (function() {
var filter,
_this = this;
if (!this.present('content')) return null;
if (this.get('filter')) {
filter = this.get('filter').toLowerCase();
}
return this.get('content').filter(function(item, index, enumerable) {
if (_this.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;
});
}).property('filter', 'content.@each', 'onlyOverridden'),
2013-02-21 12:54:40 -05:00
resetDefault: function(setting) {
setting.set('value', setting.get('default'));
setting.save();
},
2013-02-21 12:54:40 -05:00
save: function(setting) {
setting.save();
},
2013-02-21 12:54:40 -05:00
cancel: function(setting) {
setting.resetValue();
}
2013-02-21 12:54:40 -05:00
});
}).call(this);