Work in Progress: Content Editing in Admin Section
This commit is contained in:
@@ -11,6 +11,7 @@ Discourse.PreferencesEmailController = Discourse.ObjectController.extend({
|
||||
saving: false,
|
||||
error: false,
|
||||
success: false,
|
||||
newEmail: null,
|
||||
|
||||
saveDisabled: (function() {
|
||||
if (this.get('saving')) return true;
|
||||
|
||||
@@ -73,8 +73,7 @@ Ember.Handlebars.registerBoundHelper('boundCategoryLink', function(category) {
|
||||
@for Handlebars
|
||||
**/
|
||||
Handlebars.registerHelper('titledLinkTo', function(name, object) {
|
||||
var options;
|
||||
options = [].slice.call(arguments, -1)[0];
|
||||
var options = [].slice.call(arguments, -1)[0];
|
||||
if (options.hash.titleKey) {
|
||||
options.hash.title = Em.String.i18n(options.hash.titleKey);
|
||||
}
|
||||
|
||||
@@ -345,12 +345,12 @@ Discourse.User = Discourse.Model.extend({
|
||||
}).property('stats.@each'),
|
||||
|
||||
/**
|
||||
Number of items this user has sent.
|
||||
Number of items this user has sent.
|
||||
|
||||
@property sentItemsCount
|
||||
@type {Integer}
|
||||
**/
|
||||
sentItemsCount: (function() {
|
||||
sentItemsCount: function() {
|
||||
var r;
|
||||
r = 0;
|
||||
this.get('stats').each(function(s) {
|
||||
@@ -360,7 +360,42 @@ Discourse.User = Discourse.Model.extend({
|
||||
}
|
||||
});
|
||||
return r;
|
||||
}).property('stats.@each')
|
||||
}.property('stats.@each'),
|
||||
|
||||
/**
|
||||
Load extra details for the user
|
||||
|
||||
@method loadDetails
|
||||
**/
|
||||
loadDetails: function() {
|
||||
|
||||
// Check the preload store first
|
||||
var user = this;
|
||||
var username = this.get('username');
|
||||
PreloadStore.getAndRemove("user_" + username, function() {
|
||||
return Discourse.ajax({ url: Discourse.getURL("/users/") + username + '.json' });
|
||||
}).then(function (json) {
|
||||
// Create a user from the resulting JSON
|
||||
json.user.stats = Discourse.User.groupStats(json.user.stats.map(function(s) {
|
||||
var stat = Em.Object.create(s);
|
||||
stat.set('isPM', stat.get('action_type') === Discourse.UserAction.NEW_PRIVATE_MESSAGE ||
|
||||
stat.get('action_type') === Discourse.UserAction.GOT_PRIVATE_MESSAGE);
|
||||
return stat;
|
||||
}));
|
||||
|
||||
var count = 0;
|
||||
if (json.user.stream) {
|
||||
count = json.user.stream.length;
|
||||
json.user.stream = Discourse.UserAction.collapseStream(json.user.stream.map(function(ua) {
|
||||
return Discourse.UserAction.create(ua);
|
||||
}));
|
||||
}
|
||||
|
||||
user.setProperties(json.user);
|
||||
user.set('totalItems', count);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Discourse.User.reopenClass({
|
||||
@@ -427,42 +462,6 @@ Discourse.User.reopenClass({
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
Finds a user based on a username
|
||||
|
||||
@method find
|
||||
@param {String} username The username
|
||||
@returns a promise that will resolve to the user
|
||||
**/
|
||||
find: function(username) {
|
||||
|
||||
// Check the preload store first
|
||||
return PreloadStore.getAndRemove("user_" + username, function() {
|
||||
return Discourse.ajax({ url: Discourse.getURL("/users/") + username + '.json' });
|
||||
}).then(function (json) {
|
||||
|
||||
// Create a user from the resulting JSON
|
||||
json.user.stats = Discourse.User.groupStats(json.user.stats.map(function(s) {
|
||||
var stat = Em.Object.create(s);
|
||||
stat.set('isPM', stat.get('action_type') === Discourse.UserAction.NEW_PRIVATE_MESSAGE ||
|
||||
stat.get('action_type') === Discourse.UserAction.GOT_PRIVATE_MESSAGE);
|
||||
return stat;
|
||||
}));
|
||||
|
||||
var count = 0;
|
||||
if (json.user.stream) {
|
||||
count = json.user.stream.length;
|
||||
json.user.stream = Discourse.UserAction.collapseStream(json.user.stream.map(function(ua) {
|
||||
return Discourse.UserAction.create(ua);
|
||||
}));
|
||||
}
|
||||
|
||||
var user = Discourse.User.create(json.user);
|
||||
user.set('totalItems', count);
|
||||
return user;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
Creates a new account over POST
|
||||
|
||||
|
||||
@@ -12,6 +12,16 @@ Discourse.PreferencesEmailRoute = Discourse.RestrictedUserRoute.extend({
|
||||
this.render({ into: 'user', outlet: 'userOutlet' });
|
||||
},
|
||||
|
||||
// A bit odd, but if we leave to /preferences we need to re-render that outlet
|
||||
exit: function() {
|
||||
this._super();
|
||||
this.render('preferences', {
|
||||
into: 'user',
|
||||
outlet: 'userOutlet',
|
||||
controller: 'preferences'
|
||||
});
|
||||
},
|
||||
|
||||
setupController: function(controller) {
|
||||
controller.set('content', this.controllerFor('user').get('content'));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ Discourse.PreferencesRoute = Discourse.RestrictedUserRoute.extend({
|
||||
},
|
||||
|
||||
setupController: function(controller) {
|
||||
console.log('prefereces');
|
||||
controller.set('content', this.controllerFor('user').get('content'));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,16 @@ Discourse.PreferencesUsernameRoute = Discourse.RestrictedUserRoute.extend({
|
||||
return this.render({ into: 'user', outlet: 'userOutlet' });
|
||||
},
|
||||
|
||||
// A bit odd, but if we leave to /preferences we need to re-render that outlet
|
||||
exit: function() {
|
||||
this._super();
|
||||
this.render('preferences', {
|
||||
into: 'user',
|
||||
outlet: 'userOutlet',
|
||||
controller: 'preferences'
|
||||
});
|
||||
},
|
||||
|
||||
setupController: function(controller) {
|
||||
var user = this.controllerFor('user').get('content');
|
||||
controller.set('content', user);
|
||||
|
||||
@@ -8,10 +8,15 @@
|
||||
**/
|
||||
Discourse.UserRoute = Discourse.Route.extend({
|
||||
model: function(params) {
|
||||
return Discourse.User.find(params.username);
|
||||
return Discourse.User.create({username: params.username});
|
||||
},
|
||||
|
||||
serialize: function(params) {
|
||||
return { username: Em.get(params, 'username').toLowerCase() };
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
model.loadDetails();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<label>{{i18n user.new_topic_duration.label}}</label>
|
||||
{{view Discourse.ComboboxView valueAttribute="value" contentBinding="controller.considerNewTopicOptions" valueBinding="content.new_topic_duration_minutes"}}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="controls">
|
||||
<label>{{view Ember.Checkbox checkedBinding="content.external_links_in_new_tab"}}
|
||||
{{i18n user.external_links_in_new_tab}}</label>
|
||||
|
||||
Reference in New Issue
Block a user