More documentation to Admin Controllers
This commit is contained in:
parent
c1b5803486
commit
dd6d98f48f
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
Our data model for interacting with site settings.
|
||||
|
||||
@class SiteCustomization
|
||||
@class SiteSetting
|
||||
@extends Discourse.Model
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
|
|
Loading…
Reference in New Issue