mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -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,55 +1,65 @@
|
|||
<table id="topic-list">
|
||||
<tr>
|
||||
<th>
|
||||
{{i18n topic.title}}
|
||||
</th>
|
||||
<th>{{i18n category_title}}</th>
|
||||
<th class='num posts'>{{i18n posts}}</th>
|
||||
<th class='num likes'>{{i18n likes}}</th>
|
||||
<th class='num views'>{{i18n views}}</th>
|
||||
<th class='num activity' colspan='2'>{{i18n activity}}</th>
|
||||
</tr>
|
||||
|
||||
{{#groupedEach view.topics}}
|
||||
{{#if view.topics}}
|
||||
<table id="topic-list">
|
||||
<tr>
|
||||
<td class='main-link'>
|
||||
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
||||
{{#if unread}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unbound unread}}</a>
|
||||
{{/if}}
|
||||
{{#if new_posts}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{unbound new_posts}}</a>
|
||||
{{/if}}
|
||||
{{#if unseen}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class='category'>
|
||||
{{categoryLink category}}
|
||||
</td>
|
||||
<td class='num posts'><a href="{{unbound lastUnreadUrl}}" class='badge-posts'>{{number posts_count numberKey="posts_long"}}</a></td>
|
||||
|
||||
<td class='num likes'>
|
||||
{{#if like_count}}
|
||||
<a href='{{unbound url}}{{#if has_best_of}}?filter=best_of{{/if}}'>{{unbound like_count}} <i class='icon-heart'></i></a>
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td {{bindAttr class=":num :views viewsHeat"}}>{{number views numberKey="views_long"}}</td>
|
||||
{{#if bumped}}
|
||||
<td class='num activity'>
|
||||
<a href="{{unbound url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{unboundDate created_at}}}' >{{unboundAge created_at}}</a>
|
||||
</td>
|
||||
<td class='num activity last'>
|
||||
<a href="{{unbound lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate bumped_at}}}'>{{unboundAge bumped_at}}</a>
|
||||
</td>
|
||||
{{else}}
|
||||
<td class='num activity'>
|
||||
<a href="{{unbound url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{unboundAge created_at}}</a>
|
||||
</td>
|
||||
<td class="activity"></td>
|
||||
{{/if}}
|
||||
<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>
|
||||
<th class='num activity' colspan='2'>{{i18n activity}}</th>
|
||||
</tr>
|
||||
{{/groupedEach}}
|
||||
|
||||
</table>
|
||||
{{#groupedEach view.topics}}
|
||||
<tr>
|
||||
<td class='main-link'>
|
||||
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
||||
{{#if unread}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unbound unread}}</a>
|
||||
{{/if}}
|
||||
{{#if new_posts}}
|
||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{unbound new_posts}}</a>
|
||||
{{/if}}
|
||||
{{#if unseen}}
|
||||
<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'>
|
||||
{{#if like_count}}
|
||||
<a href='{{unbound url}}{{#if has_best_of}}?filter=best_of{{/if}}'>{{unbound like_count}} <i class='icon-heart'></i></a>
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td {{bindAttr class=":num :views viewsHeat"}}>{{number views numberKey="views_long"}}</td>
|
||||
{{#if bumped}}
|
||||
<td class='num activity'>
|
||||
<a href="{{unbound url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{unboundDate created_at}}}' >{{unboundAge created_at}}</a>
|
||||
</td>
|
||||
<td class='num activity last'>
|
||||
<a href="{{unbound lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate bumped_at}}}'>{{unboundAge bumped_at}}</a>
|
||||
</td>
|
||||
{{else}}
|
||||
<td class='num activity'>
|
||||
<a href="{{unbound url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{unboundAge created_at}}</a>
|
||||
</td>
|
||||
<td class="activity"></td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/groupedEach}}
|
||||
|
||||
</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