discourse/app/assets/javascripts/admin/controllers/admin-site-settings-category.js.es6
2014-11-26 18:01:45 -05:00

50 lines
1.2 KiB
JavaScript

export default Ember.ObjectController.extend({
categoryNameKey: null,
needs: ['adminSiteSettings'],
filteredContent: function() {
if (!this.get('categoryNameKey')) { return []; }
var category = this.get('controllers.adminSiteSettings.content').findProperty('nameKey', this.get('categoryNameKey'));
if (category) {
return category.siteSettings;
} else {
return [];
}
}.property('controllers.adminSiteSettings.content', 'categoryNameKey'),
actions: {
/**
Reset a setting to its default value
@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
@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();
}
}
});