Merge pull request #3009 from gdpelican/feature/new-private-message

New Private Message button for user topics
This commit is contained in:
Régis Hanol 2014-12-03 12:17:45 +01:00
commit 8ab32396a7
6 changed files with 21 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import ObjectController from 'discourse/controllers/object';
// Lists of topics on a user's page.
export default ObjectController.extend({
export default ObjectController.extend(Discourse.HasCurrentUser, {
needs: ["application"],
hideCategory: false,
showParticipants: false,

View File

@ -15,11 +15,11 @@ export default Discourse.Route.extend({
Discourse.logout();
},
composePrivateMessage: function() {
var user = this.modelFor('user');
composePrivateMessage: function(user) {
var recipient = user ? user.username : '';
return this.controllerFor('composer').open({
action: Discourse.Composer.PRIVATE_MESSAGE,
usernames: user.get('username'),
usernames: recipient,
archetypeId: 'private_message',
draftKey: 'new_private_message'
});

View File

@ -1,3 +1,9 @@
{{#if currentUser.can_send_private_messages}}
<div class="clearfix">
<a class='btn btn-primary pull-right new-private-message' {{action "composePrivateMessage"}}>{{fa-icon "envelope"}}{{i18n user.new_private_message}}</a>
</div>
{{/if}}
{{basic-topic-list topicList=model
hideCategory=hideCategory
showParticipants=showParticipants

View File

@ -73,3 +73,6 @@
}
}
.new-private-message {
margin-bottom: 15px;
}

View File

@ -45,6 +45,7 @@ class UserSerializer < BasicUserSerializer
:can_edit_email,
:can_edit_name,
:stats,
:can_send_private_messages,
:can_send_private_message_to_user,
:bio_excerpt,
:trust_level,
@ -179,6 +180,12 @@ class UserSerializer < BasicUserSerializer
UserAction.stats(object.id, scope)
end
# Needed because 'send_private_message_to_user' will always return false
# when the current user is being serialized
def can_send_private_messages
scope.can_send_private_message?(Discourse.system_user)
end
def can_send_private_message_to_user
scope.can_send_private_message?(object)
end

View File

@ -293,6 +293,7 @@ en:
mute: "Mute"
edit: "Edit Preferences"
download_archive: "download archive of my posts"
new_private_message: "New Private Message"
private_message: "Private Message"
private_messages: "Messages"
activity_stream: "Activity"