FIX: notifications & messages were missing from user profile

This commit is contained in:
Régis Hanol 2015-09-24 19:04:29 +02:00
parent 4236317f69
commit 62b493281e

View File

@ -8,9 +8,10 @@ export default Ember.Controller.extend(CanCheckEmails, {
userActionType: null, userActionType: null,
needs: ['user-notifications', 'user-topics-list'], needs: ['user-notifications', 'user-topics-list'],
viewingSelf: function() { @computed("content.username")
return this.get('content.username') === Discourse.User.currentProp('username'); viewingSelf(username) {
}.property('content.username'), return username === Discourse.User.currentProp('username');
},
@computed('indexStream', 'viewingSelf', 'forceExpand') @computed('indexStream', 'viewingSelf', 'forceExpand')
collapsedInfo(indexStream, viewingSelf, forceExpand){ collapsedInfo(indexStream, viewingSelf, forceExpand){
@ -19,35 +20,38 @@ export default Ember.Controller.extend(CanCheckEmails, {
linkWebsite: Em.computed.not('model.isBasic'), linkWebsite: Em.computed.not('model.isBasic'),
removeNoFollow: function() { @computed("model.trust_level")
return this.get('model.trust_level') > 2 && !this.siteSettings.tl3_links_no_follow; removeNoFollow(trustLevel) {
}.property('model.trust_level'), return trustLevel > 2 && !this.siteSettings.tl3_links_no_follow;
},
@computed('viewSelf', 'currentUser.admin') @computed('viewingSelf', 'currentUser.admin')
canSeePrivateMessages(viewingSelf, isAdmin) { canSeePrivateMessages(viewingSelf, isAdmin) {
return this.siteSettings.enable_private_messages && (viewingSelf || isAdmin); return this.siteSettings.enable_private_messages && (viewingSelf || isAdmin);
}, },
canSeeNotificationHistory: Em.computed.alias('canSeePrivateMessages'), canSeeNotificationHistory: Em.computed.alias('canSeePrivateMessages'),
showBadges: function() { @computed("content.badge_count")
return Discourse.SiteSettings.enable_badges && (this.get('content.badge_count') > 0); showBadges(badgeCount) {
}.property('content.badge_count'), return Discourse.SiteSettings.enable_badges && badgeCount > 0;
},
privateMessageView: function() { @computed("userActionType")
return (this.get('userActionType') === Discourse.UserAction.TYPES.messages_sent) || privateMessageView(userActionType) {
(this.get('userActionType') === Discourse.UserAction.TYPES.messages_received); return (userActionType === Discourse.UserAction.TYPES.messages_sent) ||
}.property('userActionType'), (userActionType === Discourse.UserAction.TYPES.messages_received);
},
canInviteToForum: function() { @computed()
canInviteToForum() {
return Discourse.User.currentProp('can_invite_to_forum'); return Discourse.User.currentProp('can_invite_to_forum');
}.property(), },
canDeleteUser: function() { canDeleteUser: Ember.computed.and("model.can_be_deleted", "model.can_delete_all_posts"),
return this.get('model.can_be_deleted') && this.get('model.can_delete_all_posts');
}.property('model.can_be_deleted', 'model.can_delete_all_posts'),
publicUserFields: function() { @computed('model.user_fields.@each.value')
publicUserFields() {
const siteUserFields = this.site.get('user_fields'); const siteUserFields = this.site.get('user_fields');
if (!Ember.isEmpty(siteUserFields)) { if (!Ember.isEmpty(siteUserFields)) {
const userFields = this.get('model.user_fields'); const userFields = this.get('model.user_fields');
@ -56,23 +60,23 @@ export default Ember.Controller.extend(CanCheckEmails, {
return Ember.isEmpty(value) ? null : Ember.Object.create({ value, field }); return Ember.isEmpty(value) ? null : Ember.Object.create({ value, field });
}).compact(); }).compact();
} }
}.property('model.user_fields.@each.value'), },
privateMessagesActive: Em.computed.equal('pmView', 'index'), privateMessagesActive: Em.computed.equal('pmView', 'index'),
privateMessagesMineActive: Em.computed.equal('pmView', 'mine'), privateMessagesMineActive: Em.computed.equal('pmView', 'mine'),
privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread'), privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread'),
actions: { actions: {
expandProfile: function() { expandProfile() {
this.set('forceExpand', true); this.set('forceExpand', true);
}, },
adminDelete: function() {
Discourse.AdminUser.find(this.get('model.username').toLowerCase()).then(function(user){ adminDelete() {
user.destroy({deletePosts: true}); Discourse.AdminUser.find(this.get('model.username').toLowerCase())
}); .then(user => user.destroy({deletePosts: true}));
}, },
exportUserArchive: function() { exportUserArchive() {
bootbox.confirm( bootbox.confirm(
I18n.t("admin.export_csv.user_archive_confirm"), I18n.t("admin.export_csv.user_archive_confirm"),
I18n.t("no_value"), I18n.t("no_value"),