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';
|
import ObjectController from 'discourse/controllers/object';
|
||||||
|
|
||||||
// Lists of topics on a user's page.
|
// Lists of topics on a user's page.
|
||||||
export default ObjectController.extend({
|
export default ObjectController.extend(Discourse.HasCurrentUser, {
|
||||||
needs: ["application"],
|
needs: ["application"],
|
||||||
hideCategory: false,
|
hideCategory: false,
|
||||||
showParticipants: false,
|
showParticipants: false,
|
||||||
|
|
|
@ -15,11 +15,11 @@ export default Discourse.Route.extend({
|
||||||
Discourse.logout();
|
Discourse.logout();
|
||||||
},
|
},
|
||||||
|
|
||||||
composePrivateMessage: function() {
|
composePrivateMessage: function(user) {
|
||||||
var user = this.modelFor('user');
|
var recipient = user ? user.username : '';
|
||||||
return this.controllerFor('composer').open({
|
return this.controllerFor('composer').open({
|
||||||
action: Discourse.Composer.PRIVATE_MESSAGE,
|
action: Discourse.Composer.PRIVATE_MESSAGE,
|
||||||
usernames: user.get('username'),
|
usernames: recipient,
|
||||||
archetypeId: 'private_message',
|
archetypeId: 'private_message',
|
||||||
draftKey: 'new_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
|
{{basic-topic-list topicList=model
|
||||||
hideCategory=hideCategory
|
hideCategory=hideCategory
|
||||||
showParticipants=showParticipants
|
showParticipants=showParticipants
|
||||||
|
|
|
@ -73,3 +73,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-private-message {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ class UserSerializer < BasicUserSerializer
|
||||||
:can_edit_email,
|
:can_edit_email,
|
||||||
:can_edit_name,
|
:can_edit_name,
|
||||||
:stats,
|
:stats,
|
||||||
|
:can_send_private_messages,
|
||||||
:can_send_private_message_to_user,
|
:can_send_private_message_to_user,
|
||||||
:bio_excerpt,
|
:bio_excerpt,
|
||||||
:trust_level,
|
:trust_level,
|
||||||
|
@ -178,6 +179,12 @@ class UserSerializer < BasicUserSerializer
|
||||||
UserAction.stats(object.id, scope)
|
UserAction.stats(object.id, scope)
|
||||||
end
|
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
|
def can_send_private_message_to_user
|
||||||
scope.can_send_private_message?(object)
|
scope.can_send_private_message?(object)
|
||||||
end
|
end
|
||||||
|
|
|
@ -293,6 +293,7 @@ en:
|
||||||
mute: "Mute"
|
mute: "Mute"
|
||||||
edit: "Edit Preferences"
|
edit: "Edit Preferences"
|
||||||
download_archive: "download archive of my posts"
|
download_archive: "download archive of my posts"
|
||||||
|
new_private_message: "New Private Message"
|
||||||
private_message: "Private Message"
|
private_message: "Private Message"
|
||||||
private_messages: "Messages"
|
private_messages: "Messages"
|
||||||
activity_stream: "Activity"
|
activity_stream: "Activity"
|
||||||
|
|
Loading…
Reference in New Issue