mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
Show Private Messages pill as a topic list rather than individual messages.
This commit is contained in:
parent
2ce59d2585
commit
c0b051c9f6
10 changed files with 149 additions and 66 deletions
|
@ -21,5 +21,8 @@ Discourse.UserActivityController = Discourse.ObjectController.extend({
|
|||
archetypeId: 'private_message',
|
||||
draftKey: 'new_private_message'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
privateMessagesActive: Em.computed.equal('pmView', 'index'),
|
||||
privateMessagesSentActive: Em.computed.equal('pmView', 'sent')
|
||||
});
|
||||
|
|
|
@ -159,13 +159,6 @@ Discourse.UserActivityStreamRoute = Discourse.Route.extend({
|
|||
});
|
||||
});
|
||||
|
||||
Discourse.UserPrivateMessagesIndexRoute = Discourse.UserActivityStreamRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.messages_received
|
||||
});
|
||||
Discourse.UserPrivateMessagesSentRoute = Discourse.UserActivityStreamRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.messages_sent
|
||||
});
|
||||
|
||||
Discourse.UserTopicListRoute = Discourse.Route.extend({
|
||||
|
||||
renderTemplate: function() {
|
||||
|
@ -178,12 +171,41 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({
|
|||
}
|
||||
});
|
||||
|
||||
Discourse.UserPrivateMessagesIndexRoute = Discourse.UserTopicListRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.messages_received,
|
||||
|
||||
model: function() {
|
||||
return Discourse.TopicList.find('topics/private-messages/' + this.modelFor('user').get('username_lower'));
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
this._super(controller, model);
|
||||
controller.set('hideCategories', true);
|
||||
this.controllerFor('userActivity').set('pmView', 'index');
|
||||
}
|
||||
|
||||
});
|
||||
Discourse.UserPrivateMessagesSentRoute = Discourse.UserTopicListRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.messages_sent,
|
||||
|
||||
model: function() {
|
||||
return Discourse.TopicList.find('topics/private-messages-sent/' + this.modelFor('user').get('username_lower'));
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
this._super(controller, model);
|
||||
controller.set('hideCategories', true);
|
||||
this.controllerFor('userActivity').set('pmView', 'sent');
|
||||
}
|
||||
});
|
||||
|
||||
Discourse.UserActivityTopicsRoute = Discourse.UserTopicListRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.topics,
|
||||
|
||||
model: function() {
|
||||
return Discourse.TopicList.find('topics/created-by/' + this.modelFor('user').get('username_lower'));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Discourse.UserActivityFavoritesRoute = Discourse.UserTopicListRoute.extend({
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<table id="topic-list">
|
||||
{{#if view.topics}}
|
||||
<table id="topic-list">
|
||||
<tr>
|
||||
<th>
|
||||
{{i18n topic.title}}
|
||||
</th>
|
||||
{{#unless controller.hideCategories}}
|
||||
<th>{{i18n category_title}}</th>
|
||||
{{/unless}}
|
||||
<th class='num posts'>{{i18n posts}}</th>
|
||||
<th class='num likes'>{{i18n likes}}</th>
|
||||
<th class='num views'>{{i18n views}}</th>
|
||||
|
@ -24,9 +27,11 @@
|
|||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||
{{/if}}
|
||||
</td>
|
||||
{{#unless controller.hideCategories}}
|
||||
<td class='category'>
|
||||
{{categoryLink category}}
|
||||
</td>
|
||||
{{/unless}}
|
||||
<td class='num posts'><a href="{{unbound lastUnreadUrl}}" class='badge-posts'>{{number posts_count numberKey="posts_long"}}</a></td>
|
||||
|
||||
<td class='num likes'>
|
||||
|
@ -52,4 +57,9 @@
|
|||
</tr>
|
||||
{{/groupedEach}}
|
||||
|
||||
</table>
|
||||
</table>
|
||||
{{else}}
|
||||
<div class='alert alert-info'>
|
||||
{{i18n choose_topic.none_found}}
|
||||
</div>
|
||||
{{/if}}
|
|
@ -15,9 +15,13 @@
|
|||
|
||||
<ul class='action-list nav-stacked side-nav'>
|
||||
{{#if privateMessageView}}
|
||||
{{#each stat in statsPmsOnly}}
|
||||
{{activityFilter content=stat user=model}}
|
||||
{{/each}}
|
||||
<li {{bindAttr class=":noGlyph privateMessagesActive:active"}}>
|
||||
{{#linkTo 'userPrivateMessages.index' model}}{{i18n user.private_messages}}{{/linkTo}}
|
||||
</li>
|
||||
<li {{bindAttr class=":noGlyph privateMessagesSentActive:active"}}>
|
||||
{{#linkTo 'userPrivateMessages.sent' model}}{{i18n user.private_messages_sent}}{{/linkTo}}
|
||||
</li>
|
||||
|
||||
{{else}}
|
||||
{{activityFilter count=statsCountNonPM user=model}}
|
||||
{{#each stat in statsExcludingPms}}
|
||||
|
|
|
@ -40,8 +40,7 @@ Discourse.ActivityFilterView = Discourse.View.extend({
|
|||
}.property('content.action_type'),
|
||||
|
||||
url: function() {
|
||||
var section = this.get('content.isPM') ? "/private-messages" : "/activity";
|
||||
return "/users/" + this.get('user.username_lower') + section + this.get('typeKey');
|
||||
return "/users/" + this.get('user.username_lower') + "/activity" + this.get('typeKey');
|
||||
}.property('typeKey', 'user.username_lower'),
|
||||
|
||||
description: function() {
|
||||
|
|
|
@ -40,6 +40,22 @@ class ListController < ApplicationController
|
|||
respond(list)
|
||||
end
|
||||
|
||||
def private_messages
|
||||
list_opts = build_topic_list_options
|
||||
list = TopicQuery.new(current_user, list_opts).list_private_messages(fetch_user_from_params)
|
||||
list.more_topics_url = url_for(topics_private_messages_path(list_opts.merge(format: 'json', page: next_page)))
|
||||
|
||||
respond(list)
|
||||
end
|
||||
|
||||
def private_messages_sent
|
||||
list_opts = build_topic_list_options
|
||||
list = TopicQuery.new(current_user, list_opts).list_private_messages_sent(fetch_user_from_params)
|
||||
list.more_topics_url = url_for(topics_private_messages_sent_path(list_opts.merge(format: 'json', page: next_page)))
|
||||
|
||||
respond(list)
|
||||
end
|
||||
|
||||
def category
|
||||
query = TopicQuery.new(current_user, page: params[:page])
|
||||
|
||||
|
|
|
@ -188,6 +188,7 @@ en:
|
|||
download_archive: "download archive of my posts"
|
||||
private_message: "Private Message"
|
||||
private_messages: "Messages"
|
||||
private_messages_sent: "Sent Messages"
|
||||
activity_stream: "Activity"
|
||||
preferences: "Preferences"
|
||||
bio: "About me"
|
||||
|
|
|
@ -216,6 +216,8 @@ Discourse::Application.routes.draw do
|
|||
post 'topics/timings'
|
||||
get 'topics/similar_to'
|
||||
get 'topics/created-by/:username' => 'list#topics_by', as: 'topics_by', constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get 'topics/private-messages/:username' => 'list#private_messages', as: 'topics_private_messages', constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get 'topics/private-messages-sent/:username' => 'list#private_messages_sent', as: 'topics_private_messages_sent', constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
|
||||
# Topic routes
|
||||
get 't/:slug/:topic_id/wordpress' => 'topics#wordpress', constraints: {topic_id: /\d+/}
|
||||
|
|
|
@ -135,6 +135,17 @@ class TopicQuery
|
|||
end
|
||||
end
|
||||
|
||||
def list_private_messages(user)
|
||||
list = private_messages_for(user)
|
||||
TopicList.new(:private_messages, user, list)
|
||||
end
|
||||
|
||||
def list_private_messages_sent(user)
|
||||
list = private_messages_for(user)
|
||||
list = list.where(user_id: user.id)
|
||||
TopicList.new(:private_messages, user, list)
|
||||
end
|
||||
|
||||
|
||||
def list_uncategorized
|
||||
create_list(:uncategorized, unordered: true) do |list|
|
||||
|
@ -190,6 +201,22 @@ class TopicQuery
|
|||
TopicList.new(filter, @user, topics)
|
||||
end
|
||||
|
||||
def private_messages_for(user)
|
||||
options = @options
|
||||
options.reverse_merge!(per_page: SiteSetting.topics_per_page)
|
||||
|
||||
# Start with a list of all topics
|
||||
result = Topic.where(id: TopicAllowedUser.where(user_id: user.id).pluck(:topic_id))
|
||||
result = result.joins("LEFT OUTER JOIN topic_users AS tu ON (topics.id = tu.topic_id AND tu.user_id = #{user.id.to_i})")
|
||||
result = result.order(TopicQuery.order_nocategory_basic_bumped)
|
||||
result = result.private_messages
|
||||
|
||||
result = result.limit(options[:per_page]) unless options[:limit] == false
|
||||
result = result.visible if options[:visible] || @user.nil? || @user.regular?
|
||||
result = result.offset(options[:page].to_i * options[:per_page]) if options[:page]
|
||||
result
|
||||
end
|
||||
|
||||
# Create results based on a bunch of default options
|
||||
def default_results(options={})
|
||||
options.reverse_merge!(@options)
|
||||
|
|
Loading…
Reference in a new issue