More documentation to Admin Controllers
This commit is contained in:
parent
c1b5803486
commit
dd6d98f48f
6 changed files with 123 additions and 2 deletions
app/assets/javascripts/admin
|
@ -10,20 +10,41 @@
|
||||||
**/
|
**/
|
||||||
window.Discourse.AdminCustomizeController = Ember.Controller.extend({
|
window.Discourse.AdminCustomizeController = Ember.Controller.extend({
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create a new customization style
|
||||||
|
|
||||||
|
@method newCustomization
|
||||||
|
**/
|
||||||
newCustomization: function() {
|
newCustomization: function() {
|
||||||
var item = Discourse.SiteCustomization.create({name: 'New Style'});
|
var item = Discourse.SiteCustomization.create({name: 'New Style'});
|
||||||
this.get('content').pushObject(item);
|
this.get('content').pushObject(item);
|
||||||
this.set('content.selectedItem', item);
|
this.set('content.selectedItem', item);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Select a given style
|
||||||
|
|
||||||
|
@method selectStyle
|
||||||
|
@param {Discourse.SiteCustomization} style The style we are selecting
|
||||||
|
**/
|
||||||
selectStyle: function(style) {
|
selectStyle: function(style) {
|
||||||
this.set('content.selectedItem', style);
|
this.set('content.selectedItem', style);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Save the current customization
|
||||||
|
|
||||||
|
@method save
|
||||||
|
**/
|
||||||
save: function() {
|
save: function() {
|
||||||
this.get('content.selectedItem').save();
|
this.get('content.selectedItem').save();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destroy the current customization
|
||||||
|
|
||||||
|
@method destroy
|
||||||
|
**/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
var _this = this;
|
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) {
|
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, {
|
window.Discourse.AdminEmailLogsController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Is the "send test email" button disabled?
|
||||||
|
|
||||||
|
@property sendTestEmailDisabled
|
||||||
|
**/
|
||||||
sendTestEmailDisabled: (function() {
|
sendTestEmailDisabled: (function() {
|
||||||
return this.blank('testEmailAddress');
|
return this.blank('testEmailAddress');
|
||||||
}).property('testEmailAddress'),
|
}).property('testEmailAddress'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sends a test email to the currently entered email address
|
||||||
|
|
||||||
|
@method sendTestEmail
|
||||||
|
**/
|
||||||
sendTestEmail: function() {
|
sendTestEmail: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
_this.set('sentTestEmail', false);
|
_this.set('sentTestEmail', false);
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
**/
|
**/
|
||||||
window.Discourse.AdminFlagsController = Ember.Controller.extend({
|
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) {
|
clearFlags: function(item) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
item.clearFlags().then((function() {
|
item.clearFlags().then((function() {
|
||||||
|
@ -19,6 +25,12 @@
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Deletes a post
|
||||||
|
|
||||||
|
@method deletePost
|
||||||
|
@param {Discourse.FlaggedPost} item The post to delete
|
||||||
|
**/
|
||||||
deletePost: function(item) {
|
deletePost: function(item) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
item.deletePost().then((function() {
|
item.deletePost().then((function() {
|
||||||
|
@ -28,10 +40,20 @@
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Are we viewing the 'old' view?
|
||||||
|
|
||||||
|
@property adminOldFlagsView
|
||||||
|
**/
|
||||||
adminOldFlagsView: (function() {
|
adminOldFlagsView: (function() {
|
||||||
return this.query === 'old';
|
return this.query === 'old';
|
||||||
}).property('query'),
|
}).property('query'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
Are we viewing the 'active' view?
|
||||||
|
|
||||||
|
@property adminActiveFlagsView
|
||||||
|
**/
|
||||||
adminActiveFlagsView: (function() {
|
adminActiveFlagsView: (function() {
|
||||||
return this.query === 'active';
|
return this.query === 'active';
|
||||||
}).property('query')
|
}).property('query')
|
||||||
|
|
|
@ -12,6 +12,11 @@
|
||||||
filter: null,
|
filter: null,
|
||||||
onlyOverridden: false,
|
onlyOverridden: false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
The list of settings based on the current filters
|
||||||
|
|
||||||
|
@property filteredContent
|
||||||
|
**/
|
||||||
filteredContent: (function() {
|
filteredContent: (function() {
|
||||||
var filter,
|
var filter,
|
||||||
_this = this;
|
_this = this;
|
||||||
|
@ -33,15 +38,33 @@
|
||||||
});
|
});
|
||||||
}).property('filter', 'content.@each', 'onlyOverridden'),
|
}).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) {
|
resetDefault: function(setting) {
|
||||||
setting.set('value', setting.get('default'));
|
setting.set('value', setting.get('default'));
|
||||||
setting.save();
|
setting.save();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Save changes to a site setting
|
||||||
|
|
||||||
|
@method save
|
||||||
|
@param {Discourse.SiteSetting} setting The setting we've changed
|
||||||
|
**/
|
||||||
save: function(setting) {
|
save: function(setting) {
|
||||||
setting.save();
|
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) {
|
cancel: function(setting) {
|
||||||
setting.resetValue();
|
setting.resetValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
selectAll: false,
|
selectAll: false,
|
||||||
content: null,
|
content: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
Triggered when the selectAll property is changed
|
||||||
|
|
||||||
|
@event selectAll
|
||||||
|
**/
|
||||||
selectAllChanged: (function() {
|
selectAllChanged: (function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.get('content').each(function(user) {
|
this.get('content').each(function(user) {
|
||||||
|
@ -21,42 +26,82 @@
|
||||||
});
|
});
|
||||||
}).observes('selectAll'),
|
}).observes('selectAll'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
Triggered when the username filter is changed
|
||||||
|
|
||||||
|
@event filterUsers
|
||||||
|
**/
|
||||||
filterUsers: Discourse.debounce(function() {
|
filterUsers: Discourse.debounce(function() {
|
||||||
this.refreshUsers();
|
this.refreshUsers();
|
||||||
}, 250).observes('username'),
|
}, 250).observes('username'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
Triggered when the order of the users list is changed
|
||||||
|
|
||||||
|
@event orderChanged
|
||||||
|
**/
|
||||||
orderChanged: (function() {
|
orderChanged: (function() {
|
||||||
this.refreshUsers();
|
this.refreshUsers();
|
||||||
}).observes('query'),
|
}).observes('query'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do we want to show the approval controls?
|
||||||
|
|
||||||
|
@property showApproval
|
||||||
|
**/
|
||||||
showApproval: (function() {
|
showApproval: (function() {
|
||||||
if (!Discourse.SiteSettings.must_approve_users) return false;
|
if (!Discourse.SiteSettings.must_approve_users) return false;
|
||||||
if (this.get('query') === 'new') return true;
|
if (this.get('query') === 'new') return true;
|
||||||
if (this.get('query') === 'pending') return true;
|
if (this.get('query') === 'pending') return true;
|
||||||
}).property('query'),
|
}).property('query'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
How many users are currently selected
|
||||||
|
|
||||||
|
@property selectedCount
|
||||||
|
**/
|
||||||
selectedCount: (function() {
|
selectedCount: (function() {
|
||||||
if (this.blank('content')) return 0;
|
if (this.blank('content')) return 0;
|
||||||
return this.get('content').filterProperty('selected').length;
|
return this.get('content').filterProperty('selected').length;
|
||||||
}).property('content.@each.selected'),
|
}).property('content.@each.selected'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do we have any selected users?
|
||||||
|
|
||||||
|
@property hasSelection
|
||||||
|
**/
|
||||||
hasSelection: (function() {
|
hasSelection: (function() {
|
||||||
return this.get('selectedCount') > 0;
|
return this.get('selectedCount') > 0;
|
||||||
}).property('selectedCount'),
|
}).property('selectedCount'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
Refresh the current list of users.
|
||||||
|
|
||||||
|
@method refreshUsers
|
||||||
|
**/
|
||||||
refreshUsers: function() {
|
refreshUsers: function() {
|
||||||
this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username')));
|
this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username')));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Show the list of users.
|
||||||
|
|
||||||
|
@method show
|
||||||
|
**/
|
||||||
show: function(term) {
|
show: function(term) {
|
||||||
if (this.get('query') === term) {
|
if (this.get('query') === term) {
|
||||||
this.refreshUsers();
|
this.refreshUsers();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('query', term);
|
this.set('query', term);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Approve all the currently selected users.
|
||||||
|
|
||||||
|
@method approveUsers
|
||||||
|
**/
|
||||||
approveUsers: function() {
|
approveUsers: function() {
|
||||||
Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected'));
|
Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
Our data model for interacting with site settings.
|
Our data model for interacting with site settings.
|
||||||
|
|
||||||
@class SiteCustomization
|
@class SiteSetting
|
||||||
@extends Discourse.Model
|
@extends Discourse.Model
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
|
|
Reference in a new issue