NEW: Add user name and title to group posts.

This commit is contained in:
Robin Ward 2014-02-12 14:23:10 -05:00
parent 669247977b
commit a929eda8ba
3 changed files with 42 additions and 3 deletions

View File

@ -0,0 +1,21 @@
Discourse.GroupPostController = Em.ObjectController.extend({
byName: function() {
var result = "",
longName = this.get('user_long_name'),
title = this.get('user_title');
if (!Em.isEmpty(longName)) {
result += longName;
}
if (!Em.isEmpty(title)) {
if (result.length > 0) {
result += ", ";
}
result += title;
}
return result;
}.property()
});

View File

@ -1,5 +1,5 @@
<div class='user-stream'>
{{#groupedEach model}}
{{#each model itemController="groupPost"}}
<div class='item'>
<div class='clearfix info'>
{{#link-to 'user' user class="avatar-link"}}<div class='avatar-wrapper'>{{avatar user imageSize="large" extraClasses="actor" ignoreTitle="true"}}</div>{{/link-to}}
@ -7,10 +7,15 @@
<span class="title">
<a href="{{unbound url}}">{{unbound title}}</a>
</span>
{{#if byName}}
<span class="title">
{{unbound byName}}
</span>
{{/if}}
</div>
<p class='excerpt'>
{{{unbound cooked}}}
</p>
</div>
{{/groupedEach}}
{{/each}}
</div>

View File

@ -3,7 +3,9 @@ class GroupPostSerializer < ApplicationSerializer
:cooked,
:created_at,
:title,
:url
:url,
:user_title,
:user_long_name
has_one :user, serializer: BasicUserSerializer, embed: :objects
@ -11,5 +13,16 @@ class GroupPostSerializer < ApplicationSerializer
object.topic.title
end
def user_long_name
object.user.try(:name)
end
def user_title
object.user.try(:title)
end
def include_user_long_name?
SiteSetting.enable_names?
end
end