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'),
|
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.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() {
|
this.resource('preferences', { path: '/preferences' }, function() {
|
||||||
|
|
|
@ -171,33 +171,26 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.UserPrivateMessagesIndexRoute = Discourse.UserTopicListRoute.extend({
|
function createPMRoute(viewName, path, type) {
|
||||||
userActionType: Discourse.UserAction.TYPES.messages_received,
|
return Discourse.UserTopicListRoute.extend({
|
||||||
|
userActionType: Discourse.UserAction.TYPES.messages_received,
|
||||||
|
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.TopicList.find('topics/private-messages/' + this.modelFor('user').get('username_lower'));
|
return Discourse.TopicList.find('topics/' + path + '/' + this.modelFor('user').get('username_lower'));
|
||||||
},
|
},
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
setupController: function(controller, model) {
|
||||||
this._super(controller, model);
|
this._super(controller, model);
|
||||||
controller.set('hideCategories', true);
|
controller.set('hideCategories', true);
|
||||||
this.controllerFor('userActivity').set('pmView', 'index');
|
this.controllerFor('userActivity').set('pmView', viewName);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
Discourse.UserPrivateMessagesIndexRoute = createPMRoute('index', 'private-messages');
|
||||||
Discourse.UserPrivateMessagesSentRoute = Discourse.UserTopicListRoute.extend({
|
Discourse.UserPrivateMessagesMineRoute = createPMRoute('mine', 'private-messages-sent');
|
||||||
userActionType: Discourse.UserAction.TYPES.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({
|
Discourse.UserActivityTopicsRoute = Discourse.UserTopicListRoute.extend({
|
||||||
userActionType: Discourse.UserAction.TYPES.topics,
|
userActionType: Discourse.UserAction.TYPES.topics,
|
||||||
|
@ -205,7 +198,6 @@ Discourse.UserActivityTopicsRoute = Discourse.UserTopicListRoute.extend({
|
||||||
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({
|
||||||
|
|
|
@ -16,10 +16,13 @@
|
||||||
<ul class='action-list nav-stacked side-nav'>
|
<ul class='action-list nav-stacked side-nav'>
|
||||||
{{#if privateMessageView}}
|
{{#if privateMessageView}}
|
||||||
<li {{bindAttr class=":noGlyph privateMessagesActive:active"}}>
|
<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>
|
||||||
<li {{bindAttr class=":noGlyph privateMessagesSentActive:active"}}>
|
<li {{bindAttr class=":noGlyph privateMessagesMineActive:active"}}>
|
||||||
{{#linkTo 'userPrivateMessages.sent' model}}{{i18n user.private_messages_sent}}{{/linkTo}}
|
{{#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>
|
</li>
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
|
@ -53,6 +53,14 @@ class ListController < ApplicationController
|
||||||
respond(list)
|
respond(list)
|
||||||
end
|
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
|
def category
|
||||||
query = TopicQuery.new(current_user, page: params[:page])
|
query = TopicQuery.new(current_user, page: params[:page])
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,6 @@ 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"
|
||||||
|
@ -202,6 +201,11 @@ en:
|
||||||
moderator: "{{user}} is a moderator"
|
moderator: "{{user}} is a moderator"
|
||||||
admin: "{{user}} is an admin"
|
admin: "{{user}} is an admin"
|
||||||
|
|
||||||
|
messages:
|
||||||
|
all: "All"
|
||||||
|
mine: "Mine"
|
||||||
|
unread: "Unread"
|
||||||
|
|
||||||
change_password:
|
change_password:
|
||||||
success: "(email sent)"
|
success: "(email sent)"
|
||||||
in_progress: "(sending email)"
|
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/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/: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-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
|
# 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+/}
|
||||||
|
|
|
@ -146,6 +146,11 @@ class TopicQuery
|
||||||
TopicList.new(:private_messages, user, list)
|
TopicList.new(:private_messages, user, list)
|
||||||
end
|
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
|
def list_uncategorized
|
||||||
create_list(:uncategorized, unordered: true) do |list|
|
create_list(:uncategorized, unordered: true) do |list|
|
||||||
|
|
Loading…
Reference in New Issue