FIX: Private message link on messages view did not work. Removed a lot of duplication.
This commit is contained in:
parent
7d4b089cd1
commit
257ddf5fc9
|
@ -1,3 +1,11 @@
|
||||||
|
/**
|
||||||
|
The base route for showing an activity stream.
|
||||||
|
|
||||||
|
@class UserActivityRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.UserActivityRoute = Discourse.Route.extend({
|
Discourse.UserActivityRoute = Discourse.Route.extend({
|
||||||
renderTemplate: function() {
|
renderTemplate: function() {
|
||||||
this.render('user_activity', {into: 'user', outlet: 'userOutlet' });
|
this.render('user_activity', {into: 'user', outlet: 'userOutlet' });
|
||||||
|
@ -5,19 +13,50 @@ Discourse.UserActivityRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
model: function() {
|
model: function() {
|
||||||
return this.modelFor('user');
|
return this.modelFor('user');
|
||||||
|
},
|
||||||
|
|
||||||
|
setupController: function(controller, user) {
|
||||||
|
this.controllerFor('userActivity').set('model', user);
|
||||||
|
|
||||||
|
var composerController = this.controllerFor('composer');
|
||||||
|
controller.set('model', user);
|
||||||
|
Discourse.Draft.get('new_private_message').then(function(data) {
|
||||||
|
if (data.draft) {
|
||||||
|
composerController.open({
|
||||||
|
draft: data.draft,
|
||||||
|
draftKey: 'new_private_message',
|
||||||
|
ignoreIfChanged: true,
|
||||||
|
draftSequence: data.draft_sequence
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
A route for showing a user's activity
|
||||||
|
|
||||||
|
@class UserIndexRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.UserActivityIndexRoute = Discourse.Route.extend({
|
Discourse.UserActivityIndexRoute = Discourse.Route.extend({
|
||||||
model: function() {
|
model: function() {
|
||||||
return this.modelFor('user').findStream();
|
return this.modelFor('user').findStream();
|
||||||
},
|
},
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
setupController: function(controller, model) {
|
||||||
this.controllerFor('userActivity').set('stream', model);
|
this.controllerFor('userActivity').setProperties({
|
||||||
|
model: this.modelFor('user'),
|
||||||
|
stream: model,
|
||||||
|
privateMessageView: this.get('privateMessageRoute')
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Build all the filter routes
|
||||||
Object.keys(Discourse.UserAction.TYPES).forEach(function (userAction) {
|
Object.keys(Discourse.UserAction.TYPES).forEach(function (userAction) {
|
||||||
Discourse["UserActivity" + userAction.classify() + "Route"] = Discourse.UserActivityIndexRoute.extend({
|
Discourse["UserActivity" + userAction.classify() + "Route"] = Discourse.UserActivityIndexRoute.extend({
|
||||||
model: function() {
|
model: function() {
|
||||||
|
@ -26,6 +65,15 @@ Object.keys(Discourse.UserAction.TYPES).forEach(function (userAction) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Show the user's default route
|
||||||
|
|
||||||
|
@class UserIndexRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.UserIndexRoute = Discourse.Route.extend({
|
Discourse.UserIndexRoute = Discourse.Route.extend({
|
||||||
renderTemplate: function() {
|
renderTemplate: function() {
|
||||||
this.render('user_activity', {into: 'user', outlet: 'userOutlet' });
|
this.render('user_activity', {into: 'user', outlet: 'userOutlet' });
|
||||||
|
@ -38,23 +86,65 @@ Discourse.UserIndexRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
setupController: function(controller, stream) {
|
setupController: function(controller, stream) {
|
||||||
var userActivity = this.controllerFor('userActivity');
|
var userActivity = this.controllerFor('userActivity');
|
||||||
|
|
||||||
userActivity.setProperties({
|
userActivity.setProperties({
|
||||||
stream: stream,
|
model: this.modelFor('user'),
|
||||||
model: this.modelFor('user')
|
stream: stream
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This controller supports all actions on a user's activity stream
|
Base route for showing private messages
|
||||||
|
|
||||||
@class UserActivityController
|
@class UserPrivateMessagesRoute
|
||||||
@extends Discourse.ObjectController
|
@extends Discourse.UserActivityRoute
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.UserActivityController = Discourse.Controller.extend({
|
Discourse.UserPrivateMessagesRoute = Discourse.UserActivityRoute.extend({});
|
||||||
|
|
||||||
|
/**
|
||||||
|
Default private messages route
|
||||||
|
|
||||||
|
@class UserPrivateMessagesIndexRoute
|
||||||
|
@extends Discourse.UserActivityIndexRoute
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.UserPrivateMessagesIndexRoute = Discourse.UserActivityIndexRoute.extend({
|
||||||
|
privateMessageRoute: true,
|
||||||
|
|
||||||
|
model: function() {
|
||||||
|
return this.modelFor('user').findStream(Discourse.UserAction.TYPES.messages_received);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
Private messages sent route
|
||||||
|
|
||||||
|
@class UserPrivateMessagesSentRoute
|
||||||
|
@extends Discourse.UserActivityIndexRoute
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.UserPrivateMessagesSentRoute = Discourse.UserActivityIndexRoute.extend({
|
||||||
|
privateMessageRoute: true,
|
||||||
|
|
||||||
|
model: function() {
|
||||||
|
return this.modelFor('user').findStream(Discourse.UserAction.TYPES.messages_sent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
This controller supports all actions on a user's activity stream
|
||||||
|
|
||||||
|
@class UserActivityController
|
||||||
|
@extends Discourse.Controller
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.UserActivityController = Discourse.ObjectController.extend({
|
||||||
needs: ['composer'],
|
needs: ['composer'],
|
||||||
|
|
||||||
kickOffPrivateMessage: (function() {
|
kickOffPrivateMessage: (function() {
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
/**
|
|
||||||
Base route for showing private messages
|
|
||||||
|
|
||||||
@class UserPrivateMessagesRoute
|
|
||||||
@extends Discourse.Route
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.UserPrivateMessagesRoute = Discourse.Route.extend({
|
|
||||||
renderTemplate: function() {
|
|
||||||
this.render('user_private_messages', {into: 'user', outlet: 'userOutlet' });
|
|
||||||
},
|
|
||||||
|
|
||||||
model: function() {
|
|
||||||
return this.modelFor('user');
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController: function(controller, user) {
|
|
||||||
var composerController = this.controllerFor('composer');
|
|
||||||
controller.set('model', user);
|
|
||||||
Discourse.Draft.get('new_private_message').then(function(data) {
|
|
||||||
if (data.draft) {
|
|
||||||
composerController.open({
|
|
||||||
draft: data.draft,
|
|
||||||
draftKey: 'new_private_message',
|
|
||||||
ignoreIfChanged: true,
|
|
||||||
draftSequence: data.draft_sequence
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
Default private messages route
|
|
||||||
|
|
||||||
@class UserPrivateMessagesIndexRoute
|
|
||||||
@extends Discourse.Route
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.UserPrivateMessagesIndexRoute = Discourse.Route.extend({
|
|
||||||
model: function() {
|
|
||||||
return this.modelFor('user').findStream(Discourse.UserAction.TYPES.messages_received);
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
|
||||||
this.controllerFor('userPrivateMessages').set('stream', model);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
Private messages sent route
|
|
||||||
|
|
||||||
@class UserPrivateMessagesSentRoute
|
|
||||||
@extends Discourse.Route
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.UserPrivateMessagesSentRoute = Discourse.UserPrivateMessagesIndexRoute.extend({
|
|
||||||
model: function() {
|
|
||||||
return this.modelFor('user').findStream(Discourse.UserAction.TYPES.messages_sent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
This controller handles actions related to a user's private messages.
|
|
||||||
|
|
||||||
@class UserPrivateMessagesController
|
|
||||||
@extends Discourse.ObjectController
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.UserPrivateMessagesController = Discourse.ObjectController.extend({
|
|
||||||
needs: ['composer'],
|
|
||||||
|
|
||||||
composePrivateMessage: function() {
|
|
||||||
this.get('controllers.composer').open({
|
|
||||||
action: Discourse.Composer.PRIVATE_MESSAGE,
|
|
||||||
archetypeId: 'private_message',
|
|
||||||
draftKey: 'new_private_message'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
|
@ -148,7 +148,7 @@ Discourse.Composer = Discourse.Model.extend({
|
||||||
|
|
||||||
hasMetaData: function() {
|
hasMetaData: function() {
|
||||||
var metaData = this.get('metaData');
|
var metaData = this.get('metaData');
|
||||||
return metaData ? Em.empty(Em.keys(this.get('metaData'))) : false;
|
return metaData ? Em.isEmpty(Em.keys(this.get('metaData'))) : false;
|
||||||
}.property('metaData'),
|
}.property('metaData'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,56 +1,61 @@
|
||||||
{{#with model}}
|
<div id='user-info'>
|
||||||
<div id='user-info'>
|
<nav class='buttons'>
|
||||||
<nav class='buttons'>
|
{{#if can_edit}}
|
||||||
{{#if can_edit}}
|
{{#linkTo "preferences" class="btn"}}{{i18n user.edit}}{{/linkTo}}
|
||||||
{{#linkTo "preferences" class="btn"}}{{i18n user.edit}}{{/linkTo}}
|
{{/if}}
|
||||||
{{/if}}
|
<br/>
|
||||||
<br/>
|
{{#if can_send_private_message_to_user}}
|
||||||
{{#if can_send_private_message_to_user}}
|
<button class='btn create' {{action composePrivateMessage}}>
|
||||||
<button class='btn create' {{action composePrivateMessage}}>
|
<i class='icon icon-envelope'></i>
|
||||||
<i class='icon icon-envelope'></i>
|
{{i18n user.private_message}}
|
||||||
{{i18n user.private_message}}
|
</button>
|
||||||
</button>
|
{{/if}}
|
||||||
{{/if}}
|
</nav>
|
||||||
</nav>
|
<div class='clearfix'></div>
|
||||||
<div class='clearfix'></div>
|
|
||||||
|
|
||||||
<ul class='action-list nav-stacked side-nav'>
|
<ul class='action-list nav-stacked side-nav'>
|
||||||
{{activityFilter count=statsCountNonPM user=this}}
|
{{#if privateMessageView}}
|
||||||
|
{{#each stat in statsPmsOnly}}
|
||||||
|
{{activityFilter content=stat user=model}}
|
||||||
|
{{/each}}
|
||||||
|
{{else}}
|
||||||
|
{{activityFilter count=statsCountNonPM user=model}}
|
||||||
{{#each stat in statsExcludingPms}}
|
{{#each stat in statsExcludingPms}}
|
||||||
{{activityFilter content=stat user=model}}
|
{{activityFilter content=stat user=model}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
|
||||||
<div class='show'>
|
|
||||||
<dl>
|
|
||||||
{{#if websiteName}}
|
|
||||||
<dt>{{i18n user.website}}:</dt><dd><a {{bindAttr href="website"}} target="_blank">{{websiteName}}</a></dd>
|
|
||||||
{{/if}}
|
|
||||||
{{#if created_at}}
|
|
||||||
<dt>{{i18n user.created}}:</dt><dd>{{date created_at}}</dd>
|
|
||||||
{{/if}}
|
|
||||||
{{#if last_posted_at}}
|
|
||||||
<dt>{{i18n user.last_posted}}:</dt><dd>{{date last_posted_at}}</dd>
|
|
||||||
{{/if}}
|
|
||||||
{{#if last_seen_at}}
|
|
||||||
<dt>{{i18n user.last_seen}}:</dt><dd>{{date last_seen_at}}</dd>
|
|
||||||
{{/if}}
|
|
||||||
{{#if invited_by}}
|
|
||||||
<dt>{{i18n user.invited_by}}:</dt><dd>{{#linkTo 'userActivity' invited_by}}{{invited_by.username}}{{/linkTo}}</dd>
|
|
||||||
{{/if}}
|
|
||||||
{{#if email}}
|
|
||||||
<dt>{{i18n user.email.title}}:</dt><dd {{bindAttr title="email"}}>{{email}}</dd>
|
|
||||||
{{/if}}
|
|
||||||
<dt>{{i18n user.trust_level}}:</dt><dd>{{trustLevel.name}}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{#if can_edit}}
|
|
||||||
<div style='margin-top: 10px'>
|
|
||||||
<button class='btn' data-not-implemented='true' disabled title="{{i18n not_implemented}}">{{i18n user.download_archive}}</button>
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class='show'>
|
||||||
|
<dl>
|
||||||
|
{{#if websiteName}}
|
||||||
|
<dt>{{i18n user.website}}:</dt><dd><a {{bindAttr href="website"}} target="_blank">{{websiteName}}</a></dd>
|
||||||
|
{{/if}}
|
||||||
|
{{#if created_at}}
|
||||||
|
<dt>{{i18n user.created}}:</dt><dd>{{date created_at}}</dd>
|
||||||
|
{{/if}}
|
||||||
|
{{#if last_posted_at}}
|
||||||
|
<dt>{{i18n user.last_posted}}:</dt><dd>{{date last_posted_at}}</dd>
|
||||||
|
{{/if}}
|
||||||
|
{{#if last_seen_at}}
|
||||||
|
<dt>{{i18n user.last_seen}}:</dt><dd>{{date last_seen_at}}</dd>
|
||||||
|
{{/if}}
|
||||||
|
{{#if invited_by}}
|
||||||
|
<dt>{{i18n user.invited_by}}:</dt><dd>{{#linkTo 'userActivity' invited_by}}{{invited_by.username}}{{/linkTo}}</dd>
|
||||||
|
{{/if}}
|
||||||
|
{{#if email}}
|
||||||
|
<dt>{{i18n user.email.title}}:</dt><dd {{bindAttr title="email"}}>{{email}}</dd>
|
||||||
|
{{/if}}
|
||||||
|
<dt>{{i18n user.trust_level}}:</dt><dd>{{trustLevel.name}}</dd>
|
||||||
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
{{/with}}
|
|
||||||
|
{{#if can_edit}}
|
||||||
|
<div style='margin-top: 10px'>
|
||||||
|
<button class='btn' data-not-implemented='true' disabled title="{{i18n not_implemented}}">{{i18n user.download_archive}}</button>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{{userStream stream=stream}}
|
{{userStream stream=stream}}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
<div id='user-info'>
|
|
||||||
{{#with model}}
|
|
||||||
<nav class='buttons'>
|
|
||||||
{{#if can_edit}}
|
|
||||||
{{#linkTo "preferences" class="btn"}}{{i18n user.edit}}{{/linkTo}}
|
|
||||||
{{/if}}
|
|
||||||
<br/>
|
|
||||||
{{#if can_send_private_message_to_user}}
|
|
||||||
<button class='btn create' {{action composePrivateMessage}}>
|
|
||||||
<i class='icon icon-plus'></i>
|
|
||||||
{{i18n user.private_message}}
|
|
||||||
</button>
|
|
||||||
{{/if}}
|
|
||||||
</nav>
|
|
||||||
<div class='clearfix'></div>
|
|
||||||
|
|
||||||
<ul class='action-list nav-stacked side-nav'>
|
|
||||||
{{#each stat in statsPmsOnly}}
|
|
||||||
{{activityFilter content=stat user=model}}
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
{{/with}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{userStream stream=stream}}
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
/**
|
|
||||||
This view handles rendering of a user's private messages
|
|
||||||
|
|
||||||
@class UserPrivateMessagesView
|
|
||||||
@extends Discourse.View
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.UserPrivateMessagesView = Discourse.View.extend({
|
|
||||||
templateName: 'user/private_messages',
|
|
||||||
|
|
||||||
selectCurrent: function(evt) {
|
|
||||||
var t;
|
|
||||||
t = $(evt.currentTarget);
|
|
||||||
t.closest('.action-list').find('li').removeClass('active');
|
|
||||||
return t.closest('li').addClass('active');
|
|
||||||
},
|
|
||||||
|
|
||||||
inbox: function(evt) {
|
|
||||||
this.selectCurrent(evt);
|
|
||||||
return this.set('controller.filter', Discourse.UserAction.TYPES.messages_received);
|
|
||||||
},
|
|
||||||
|
|
||||||
sentMessages: function(evt) {
|
|
||||||
this.selectCurrent(evt);
|
|
||||||
return this.set('controller.filter', Discourse.UserAction.TYPES.messages_sent);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue