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-02-22 15:41:12 -05:00
|
|
|
@property filteredContent
|
|
|
|
**/
|
2013-05-29 13:33:54 -04:00
|
|
|
filteredContent: function() {
|
2013-03-01 12:45:25 -05:00
|
|
|
|
|
|
|
// If we have no content, don't bother filtering anything
|
2013-02-22 15:41:12 -05:00
|
|
|
if (!this.present('content')) return null;
|
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-03-01 12:45:25 -05:00
|
|
|
var adminSettingsController = this;
|
2013-02-22 15:41:12 -05:00
|
|
|
return this.get('content').filter(function(item, index, enumerable) {
|
2013-03-01 12:45:25 -05:00
|
|
|
if (adminSettingsController.get('onlyOverridden') && !item.get('overridden')) return false;
|
2013-02-22 15:41:12 -05:00
|
|
|
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;
|
2013-02-20 13:15:50 -05:00
|
|
|
}
|
2013-02-21 12:58:21 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
return true;
|
|
|
|
});
|
2013-05-29 13:33:54 -04:00
|
|
|
}.property('filter', 'content.@each', 'onlyOverridden'),
|
2013-02-21 14:42:48 -05:00
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
actions: {
|
2013-10-29 17:03:28 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Changes the currently active filter
|
|
|
|
|
|
|
|
@method changeFilter
|
|
|
|
**/
|
|
|
|
changeFilter: function() {
|
|
|
|
this.set('filter', this.get('newFilter'));
|
|
|
|
},
|
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
/**
|
|
|
|
Reset a setting to its default value
|
2013-02-21 12:54:40 -05:00
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
@method resetDefault
|
|
|
|
@param {Discourse.SiteSetting} setting The setting we want to revert
|
|
|
|
**/
|
|
|
|
resetDefault: function(setting) {
|
|
|
|
setting.set('value', setting.get('default'));
|
|
|
|
setting.save();
|
|
|
|
},
|
2013-02-21 14:42:48 -05:00
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
/**
|
|
|
|
Save changes to a site setting
|
2013-02-21 12:54:40 -05:00
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
@method save
|
|
|
|
@param {Discourse.SiteSetting} setting The setting we've changed
|
|
|
|
**/
|
|
|
|
save: function(setting) {
|
|
|
|
setting.save();
|
|
|
|
},
|
2013-02-21 14:42:48 -05:00
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
/**
|
|
|
|
Cancel changes to a site setting
|
2013-02-20 13:15:50 -05:00
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
@method cancel
|
|
|
|
@param {Discourse.SiteSetting} setting The setting we've changed but want to revert
|
|
|
|
**/
|
|
|
|
cancel: function(setting) {
|
|
|
|
setting.resetValue();
|
|
|
|
}
|
2013-02-22 15:41:12 -05:00
|
|
|
}
|
2013-03-01 12:45:25 -05:00
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
});
|