Add "Unread" filter to messages tab. Rename the other two views.
This commit is contained in:
parent
232f5bd743
commit
46efbac40e
|
@ -24,5 +24,6 @@ Discourse.UserActivityController = Discourse.ObjectController.extend({
|
|||
},
|
||||
|
||||
privateMessagesActive: Em.computed.equal('pmView', 'index'),
|
||||
privateMessagesSentActive: Em.computed.equal('pmView', 'sent')
|
||||
privateMessagesMineActive: Em.computed.equal('pmView', 'mine'),
|
||||
privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread')
|
||||
});
|
||||
|
|
|
@ -50,7 +50,8 @@ Discourse.Route.buildRoutes(function() {
|
|||
});
|
||||
|
||||
this.resource('userPrivateMessages', { path: '/private-messages' }, function() {
|
||||
this.route('sent', {path: '/messages-sent'});
|
||||
this.route('mine', {path: '/mine'});
|
||||
this.route('unread', {path: '/unread'});
|
||||
});
|
||||
|
||||
this.resource('preferences', { path: '/preferences' }, function() {
|
||||
|
|
|
@ -171,33 +171,26 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({
|
|||
}
|
||||
});
|
||||
|
||||
Discourse.UserPrivateMessagesIndexRoute = Discourse.UserTopicListRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.messages_received,
|
||||
function createPMRoute(viewName, path, type) {
|
||||
return Discourse.UserTopicListRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.messages_received,
|
||||
|
||||
model: function() {
|
||||
return Discourse.TopicList.find('topics/private-messages/' + this.modelFor('user').get('username_lower'));
|
||||
},
|
||||
model: function() {
|
||||
return Discourse.TopicList.find('topics/' + path + '/' + this.modelFor('user').get('username_lower'));
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
this._super(controller, model);
|
||||
controller.set('hideCategories', true);
|
||||
this.controllerFor('userActivity').set('pmView', 'index');
|
||||
}
|
||||
setupController: function(controller, model) {
|
||||
this._super(controller, model);
|
||||
controller.set('hideCategories', true);
|
||||
this.controllerFor('userActivity').set('pmView', viewName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
Discourse.UserPrivateMessagesSentRoute = Discourse.UserTopicListRoute.extend({
|
||||
userActionType: Discourse.UserAction.TYPES.messages_sent,
|
||||
Discourse.UserPrivateMessagesIndexRoute = createPMRoute('index', 'private-messages');
|
||||
Discourse.UserPrivateMessagesMineRoute = createPMRoute('mine', 'private-messages-sent');
|
||||
Discourse.UserPrivateMessagesUnreadRoute = createPMRoute('unread', 'private-messages-unread');
|
||||
|
||||
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,
|
||||
|
@ -205,7 +198,6 @@ Discourse.UserActivityTopicsRoute = Discourse.UserTopicListRoute.extend({
|
|||
model: function() {
|
||||
return Discourse.TopicList.find('topics/created-by/' + this.modelFor('user').get('username_lower'));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Discourse.UserActivityFavoritesRoute = Discourse.UserTopicListRoute.extend({
|
||||
|
|
|
@ -16,10 +16,13 @@
|
|||
<ul class='action-list nav-stacked side-nav'>
|
||||
{{#if privateMessageView}}
|
||||
<li {{bindAttr class=":noGlyph privateMessagesActive:active"}}>
|
||||
{{#linkTo 'userPrivateMessages.index' model}}{{i18n user.private_messages}}{{/linkTo}}
|
||||
{{#linkTo 'userPrivateMessages.index' model}}{{i18n user.messages.all}}{{/linkTo}}
|
||||
</li>
|
||||
<li {{bindAttr class=":noGlyph privateMessagesSentActive:active"}}>
|
||||
{{#linkTo 'userPrivateMessages.sent' model}}{{i18n user.private_messages_sent}}{{/linkTo}}
|
||||
<li {{bindAttr class=":noGlyph privateMessagesMineActive:active"}}>
|
||||
{{#linkTo 'userPrivateMessages.mine' model}}{{i18n user.messages.mine}}{{/linkTo}}
|
||||
</li>
|
||||
<li {{bindAttr class=":noGlyph privateMessagesUnreadActive:active"}}>
|
||||
{{#linkTo 'userPrivateMessages.unread' model}}{{i18n user.messages.unread}}{{/linkTo}}
|
||||
</li>
|
||||
|
||||
{{else}}
|
||||
|
|
|
@ -53,6 +53,14 @@ class ListController < ApplicationController
|
|||
respond(list)
|
||||
end
|
||||
|
||||
def private_messages_unread
|
||||
list_opts = build_topic_list_options
|
||||
list = TopicQuery.new(current_user, list_opts).list_private_messages_unread(fetch_user_from_params)
|
||||
list.more_topics_url = url_for(topics_private_messages_unread_path(list_opts.merge(format: 'json', page: next_page)))
|
||||
|
||||
respond(list)
|
||||
end
|
||||
|
||||
def category
|
||||
query = TopicQuery.new(current_user, page: params[:page])
|
||||
|
||||
|
|
|
@ -188,7 +188,6 @@ 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"
|
||||
|
@ -202,6 +201,11 @@ en:
|
|||
moderator: "{{user}} is a moderator"
|
||||
admin: "{{user}} is an admin"
|
||||
|
||||
messages:
|
||||
all: "All"
|
||||
mine: "Mine"
|
||||
unread: "Unread"
|
||||
|
||||
change_password:
|
||||
success: "(email sent)"
|
||||
in_progress: "(sending email)"
|
||||
|
|
|
@ -216,6 +216,7 @@ Discourse::Application.routes.draw do
|
|||
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}
|
||||
get 'topics/private-messages-unread/:username' => 'list#private_messages_unread', as: 'topics_private_messages_unread', constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
|
||||
# Topic routes
|
||||
get 't/:slug/:topic_id/wordpress' => 'topics#wordpress', constraints: {topic_id: /\d+/}
|
||||
|
|
|
@ -146,6 +146,11 @@ class TopicQuery
|
|||
TopicList.new(:private_messages, user, list)
|
||||
end
|
||||
|
||||
def list_private_messages_unread(user)
|
||||
list = private_messages_for(user)
|
||||
list = TopicQuery.unread_filter(list)
|
||||
TopicList.new(:private_messages, user, list)
|
||||
end
|
||||
|
||||
def list_uncategorized
|
||||
create_list(:uncategorized, unordered: true) do |list|
|
||||
|
|
Loading…
Reference in New Issue