mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FEATURE: split up group PMS on user page
This commit is contained in:
parent
fe8c74d0b6
commit
8cf4d52cb6
11 changed files with 63 additions and 20 deletions
|
@ -67,7 +67,19 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
|||
privateMessagesActive: Em.computed.equal('pmView', 'index'),
|
||||
privateMessagesMineActive: Em.computed.equal('pmView', 'mine'),
|
||||
privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread'),
|
||||
privateMessagesGroupsActive: Em.computed.equal('pmView', 'groups'),
|
||||
|
||||
@computed('model.private_messages_stats.groups', 'groupFilter', 'pmView')
|
||||
groupPMStats(stats,filter,pmView) {
|
||||
if (stats) {
|
||||
return stats.map(g => {
|
||||
return {
|
||||
name: g.name,
|
||||
count: g.count,
|
||||
active: (g.name === filter && pmView === 'groups')
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
expandProfile() {
|
||||
|
|
|
@ -16,7 +16,6 @@ const User = RestModel.extend({
|
|||
hasPMs: Em.computed.gt("private_messages_stats.all", 0),
|
||||
hasStartedPMs: Em.computed.gt("private_messages_stats.mine", 0),
|
||||
hasUnreadPMs: Em.computed.gt("private_messages_stats.unread", 0),
|
||||
hasGroupsPMs: Em.computed.gt("private_messages_stats.groups", 0),
|
||||
hasPosted: Em.computed.gt("post_count", 0),
|
||||
hasNotPosted: Em.computed.not("hasPosted"),
|
||||
canBeDeleted: Em.computed.and("can_be_deleted", "hasNotPosted"),
|
||||
|
|
|
@ -71,7 +71,7 @@ export default function() {
|
|||
this.resource('userPrivateMessages', { path: '/messages' }, function() {
|
||||
this.route('mine');
|
||||
this.route('unread');
|
||||
this.route('groups');
|
||||
this.route('group', { path: 'group/:name'});
|
||||
});
|
||||
|
||||
this.resource('preferences', function() {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import createPMRoute from "discourse/routes/build-user-topic-list-route";
|
||||
|
||||
export default createPMRoute('groups', 'private-messages-groups').extend({
|
||||
model(params) {
|
||||
return this.store.findFiltered("topicList", { filter: "topics/private-messages-group/" + this.modelFor("user").get("username_lower") + "/" + params.name });
|
||||
},
|
||||
|
||||
setupController(controller,model) {
|
||||
this._super.apply(this, arguments);
|
||||
const filter = _.last(model.get("filter").split('/'));
|
||||
this.controllerFor("user").set("groupFilter", filter);
|
||||
}
|
||||
});
|
|
@ -1,3 +0,0 @@
|
|||
import createPMRoute from "discourse/routes/build-user-topic-list-route";
|
||||
|
||||
export default createPMRoute('groups', 'private-messages-groups');
|
|
@ -197,12 +197,15 @@
|
|||
{{#if model.hasUnreadPMs}}<span class='badge-notification unread-private-messages'>{{model.private_messages_stats.unread}}</span>{{/if}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li {{bind-attr class=":noGlyph privateMessagesGroupsActive:active"}}>
|
||||
{{#link-to 'userPrivateMessages.groups' model}}
|
||||
{{i18n 'user.messages.groups'}}
|
||||
{{#if model.hasGroupsPMs}}<span class='count'>({{model.private_messages_stats.groups}})</span>{{/if}}
|
||||
{{#each groupPMStats as |group|}}
|
||||
<li class="{{if group.active "active"}}">
|
||||
{{#link-to 'userPrivateMessages.group' group.name}}
|
||||
<i class='glyph fa fa-group'></i>
|
||||
{{group.name}}
|
||||
<span class='count'>({{group.count}})</span>
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue