From dd6d98f48fbf3fd64023f47d7cff2f8d8391f73c Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 21 Feb 2013 14:42:48 -0500 Subject: [PATCH] More documentation to Admin Controllers --- .../controllers/admin_customize_controller.js | 21 +++++++++ .../admin_email_logs_controller.js | 10 ++++ .../controllers/admin_flags_controller.js | 22 +++++++++ .../admin_site_settings_controller.js | 23 +++++++++ .../admin_users_list_controller.js | 47 ++++++++++++++++++- .../javascripts/admin/models/site_setting.js | 2 +- 6 files changed, 123 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin_customize_controller.js b/app/assets/javascripts/admin/controllers/admin_customize_controller.js index ea758d099f0..dfa0fb9054b 100644 --- a/app/assets/javascripts/admin/controllers/admin_customize_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_customize_controller.js @@ -10,20 +10,41 @@ **/ window.Discourse.AdminCustomizeController = Ember.Controller.extend({ + /** + Create a new customization style + + @method newCustomization + **/ newCustomization: function() { var item = Discourse.SiteCustomization.create({name: 'New Style'}); this.get('content').pushObject(item); this.set('content.selectedItem', item); }, + /** + Select a given style + + @method selectStyle + @param {Discourse.SiteCustomization} style The style we are selecting + **/ selectStyle: function(style) { this.set('content.selectedItem', style); }, + /** + Save the current customization + + @method save + **/ save: function() { this.get('content.selectedItem').save(); }, + /** + Destroy the current customization + + @method destroy + **/ destroy: function() { var _this = this; return bootbox.confirm(Em.String.i18n("admin.customize.delete_confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) { diff --git a/app/assets/javascripts/admin/controllers/admin_email_logs_controller.js b/app/assets/javascripts/admin/controllers/admin_email_logs_controller.js index 23a450aca46..fbe31fed562 100644 --- a/app/assets/javascripts/admin/controllers/admin_email_logs_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_email_logs_controller.js @@ -10,10 +10,20 @@ **/ window.Discourse.AdminEmailLogsController = Ember.ArrayController.extend(Discourse.Presence, { + /** + Is the "send test email" button disabled? + + @property sendTestEmailDisabled + **/ sendTestEmailDisabled: (function() { return this.blank('testEmailAddress'); }).property('testEmailAddress'), + /** + Sends a test email to the currently entered email address + + @method sendTestEmail + **/ sendTestEmail: function() { var _this = this; _this.set('sentTestEmail', false); diff --git a/app/assets/javascripts/admin/controllers/admin_flags_controller.js b/app/assets/javascripts/admin/controllers/admin_flags_controller.js index 5fec9adb22c..a3a6107ed3f 100644 --- a/app/assets/javascripts/admin/controllers/admin_flags_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_flags_controller.js @@ -10,6 +10,12 @@ **/ window.Discourse.AdminFlagsController = Ember.Controller.extend({ + /** + Clear all flags on a post + + @method clearFlags + @param {Discourse.FlaggedPost} item The post whose flags we want to clear + **/ clearFlags: function(item) { var _this = this; item.clearFlags().then((function() { @@ -19,6 +25,12 @@ })); }, + /** + Deletes a post + + @method deletePost + @param {Discourse.FlaggedPost} item The post to delete + **/ deletePost: function(item) { var _this = this; item.deletePost().then((function() { @@ -28,10 +40,20 @@ })); }, + /** + Are we viewing the 'old' view? + + @property adminOldFlagsView + **/ adminOldFlagsView: (function() { return this.query === 'old'; }).property('query'), + /** + Are we viewing the 'active' view? + + @property adminActiveFlagsView + **/ adminActiveFlagsView: (function() { return this.query === 'active'; }).property('query') diff --git a/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js b/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js index 7f2ef2e7dd0..da618df7895 100644 --- a/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_site_settings_controller.js @@ -12,6 +12,11 @@ filter: null, onlyOverridden: false, + /** + The list of settings based on the current filters + + @property filteredContent + **/ filteredContent: (function() { var filter, _this = this; @@ -33,15 +38,33 @@ }); }).property('filter', 'content.@each', 'onlyOverridden'), + /** + 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(); } diff --git a/app/assets/javascripts/admin/controllers/admin_users_list_controller.js b/app/assets/javascripts/admin/controllers/admin_users_list_controller.js index 08f345c0679..535602a60da 100644 --- a/app/assets/javascripts/admin/controllers/admin_users_list_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_users_list_controller.js @@ -14,6 +14,11 @@ selectAll: false, content: null, + /** + Triggered when the selectAll property is changed + + @event selectAll + **/ selectAllChanged: (function() { var _this = this; this.get('content').each(function(user) { @@ -21,42 +26,82 @@ }); }).observes('selectAll'), + /** + Triggered when the username filter is changed + + @event filterUsers + **/ filterUsers: Discourse.debounce(function() { this.refreshUsers(); }, 250).observes('username'), + /** + Triggered when the order of the users list is changed + + @event orderChanged + **/ orderChanged: (function() { this.refreshUsers(); }).observes('query'), + /** + Do we want to show the approval controls? + + @property showApproval + **/ showApproval: (function() { if (!Discourse.SiteSettings.must_approve_users) return false; if (this.get('query') === 'new') return true; if (this.get('query') === 'pending') return true; }).property('query'), + /** + How many users are currently selected + + @property selectedCount + **/ selectedCount: (function() { if (this.blank('content')) return 0; return this.get('content').filterProperty('selected').length; }).property('content.@each.selected'), + /** + Do we have any selected users? + + @property hasSelection + **/ hasSelection: (function() { return this.get('selectedCount') > 0; }).property('selectedCount'), + /** + Refresh the current list of users. + + @method refreshUsers + **/ refreshUsers: function() { this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username'))); }, + + /** + Show the list of users. + + @method show + **/ show: function(term) { if (this.get('query') === term) { this.refreshUsers(); return; } - this.set('query', term); }, + /** + Approve all the currently selected users. + + @method approveUsers + **/ approveUsers: function() { Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected')); } diff --git a/app/assets/javascripts/admin/models/site_setting.js b/app/assets/javascripts/admin/models/site_setting.js index 7f1bacf6822..7026043ab93 100644 --- a/app/assets/javascripts/admin/models/site_setting.js +++ b/app/assets/javascripts/admin/models/site_setting.js @@ -3,7 +3,7 @@ /** Our data model for interacting with site settings. - @class SiteCustomization + @class SiteSetting @extends Discourse.Model @namespace Discourse @module Discourse