mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
Show Private Messages pill as a topic list rather than individual messages.
This commit is contained in:
@ -21,5 +21,8 @@ Discourse.UserActivityController = Discourse.ObjectController.extend({
|
|||||||
archetypeId: 'private_message',
|
archetypeId: 'private_message',
|
||||||
draftKey: 'new_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({
|
Discourse.UserTopicListRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
renderTemplate: function() {
|
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({
|
Discourse.UserActivityTopicsRoute = Discourse.UserTopicListRoute.extend({
|
||||||
userActionType: Discourse.UserAction.TYPES.topics,
|
userActionType: Discourse.UserAction.TYPES.topics,
|
||||||
|
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.TopicList.find('topics/created-by/' + this.modelFor('user').get('username_lower'));
|
return Discourse.TopicList.find('topics/created-by/' + this.modelFor('user').get('username_lower'));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.UserActivityFavoritesRoute = Discourse.UserTopicListRoute.extend({
|
Discourse.UserActivityFavoritesRoute = Discourse.UserTopicListRoute.extend({
|
||||||
|
@ -1,55 +1,65 @@
|
|||||||
<table id="topic-list">
|
{{#if view.topics}}
|
||||||
<tr>
|
<table id="topic-list">
|
||||||
<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}}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class='main-link'>
|
<th>
|
||||||
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
{{i18n topic.title}}
|
||||||
{{#if unread}}
|
</th>
|
||||||
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unbound unread}}</a>
|
{{#unless controller.hideCategories}}
|
||||||
{{/if}}
|
<th>{{i18n category_title}}</th>
|
||||||
{{#if new_posts}}
|
{{/unless}}
|
||||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{unbound new_posts}}</a>
|
<th class='num posts'>{{i18n posts}}</th>
|
||||||
{{/if}}
|
<th class='num likes'>{{i18n likes}}</th>
|
||||||
{{#if unseen}}
|
<th class='num views'>{{i18n views}}</th>
|
||||||
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
<th class='num activity' colspan='2'>{{i18n activity}}</th>
|
||||||
{{/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}}
|
|
||||||
</tr>
|
</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'>
|
<ul class='action-list nav-stacked side-nav'>
|
||||||
{{#if privateMessageView}}
|
{{#if privateMessageView}}
|
||||||
{{#each stat in statsPmsOnly}}
|
<li {{bindAttr class=":noGlyph privateMessagesActive:active"}}>
|
||||||
{{activityFilter content=stat user=model}}
|
{{#linkTo 'userPrivateMessages.index' model}}{{i18n user.private_messages}}{{/linkTo}}
|
||||||
{{/each}}
|
</li>
|
||||||
|
<li {{bindAttr class=":noGlyph privateMessagesSentActive:active"}}>
|
||||||
|
{{#linkTo 'userPrivateMessages.sent' model}}{{i18n user.private_messages_sent}}{{/linkTo}}
|
||||||
|
</li>
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
{{activityFilter count=statsCountNonPM user=model}}
|
{{activityFilter count=statsCountNonPM user=model}}
|
||||||
{{#each stat in statsExcludingPms}}
|
{{#each stat in statsExcludingPms}}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
no
|
|
@ -40,8 +40,7 @@ Discourse.ActivityFilterView = Discourse.View.extend({
|
|||||||
}.property('content.action_type'),
|
}.property('content.action_type'),
|
||||||
|
|
||||||
url: function() {
|
url: function() {
|
||||||
var section = this.get('content.isPM') ? "/private-messages" : "/activity";
|
return "/users/" + this.get('user.username_lower') + "/activity" + this.get('typeKey');
|
||||||
return "/users/" + this.get('user.username_lower') + section + this.get('typeKey');
|
|
||||||
}.property('typeKey', 'user.username_lower'),
|
}.property('typeKey', 'user.username_lower'),
|
||||||
|
|
||||||
description: function() {
|
description: function() {
|
||||||
|
@ -40,6 +40,22 @@ class ListController < ApplicationController
|
|||||||
respond(list)
|
respond(list)
|
||||||
end
|
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
|
def category
|
||||||
query = TopicQuery.new(current_user, page: params[:page])
|
query = TopicQuery.new(current_user, page: params[:page])
|
||||||
|
|
||||||
|
@ -188,6 +188,7 @@ en:
|
|||||||
download_archive: "download archive of my posts"
|
download_archive: "download archive of my posts"
|
||||||
private_message: "Private Message"
|
private_message: "Private Message"
|
||||||
private_messages: "Messages"
|
private_messages: "Messages"
|
||||||
|
private_messages_sent: "Sent Messages"
|
||||||
activity_stream: "Activity"
|
activity_stream: "Activity"
|
||||||
preferences: "Preferences"
|
preferences: "Preferences"
|
||||||
bio: "About me"
|
bio: "About me"
|
||||||
|
@ -216,6 +216,8 @@ Discourse::Application.routes.draw do
|
|||||||
post 'topics/timings'
|
post 'topics/timings'
|
||||||
get 'topics/similar_to'
|
get 'topics/similar_to'
|
||||||
get 'topics/created-by/:username' => 'list#topics_by', as: 'topics_by', constraints: {username: USERNAME_ROUTE_FORMAT}
|
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
|
# Topic routes
|
||||||
get 't/:slug/:topic_id/wordpress' => 'topics#wordpress', constraints: {topic_id: /\d+/}
|
get 't/:slug/:topic_id/wordpress' => 'topics#wordpress', constraints: {topic_id: /\d+/}
|
||||||
|
@ -135,6 +135,17 @@ class TopicQuery
|
|||||||
end
|
end
|
||||||
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
|
def list_uncategorized
|
||||||
create_list(:uncategorized, unordered: true) do |list|
|
create_list(:uncategorized, unordered: true) do |list|
|
||||||
@ -190,6 +201,22 @@ class TopicQuery
|
|||||||
TopicList.new(filter, @user, topics)
|
TopicList.new(filter, @user, topics)
|
||||||
end
|
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
|
# Create results based on a bunch of default options
|
||||||
def default_results(options={})
|
def default_results(options={})
|
||||||
options.reverse_merge!(@options)
|
options.reverse_merge!(@options)
|
||||||
|
Reference in New Issue
Block a user