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