Add new private message button on topics list
That'll teach me to wildly refactor things.
This commit is contained in:
parent
cb0e7a5724
commit
cc76087f59
|
@ -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,
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -73,3 +73,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.new-private-message {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
@ -178,6 +179,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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue