Only show filter button if the user has more than 2 posts

This commit is contained in:
Robin Ward 2013-10-08 15:44:36 -04:00
parent bccb37b6f3
commit 8e6ae0e278
3 changed files with 13 additions and 3 deletions

View File

@ -10,8 +10,10 @@ Discourse.PosterExpansionController = Discourse.ObjectController.extend({
needs: ['topic'],
visible: false,
user: null,
participant: null,
showFilter: Em.computed.alias('controllers.topic.postStream.hasNoFilters'),
enoughPostsForFiltering: Em.computed.gte('participant.post_count', 2),
showFilter: Em.computed.and('controllers.topic.postStream.hasNoFilters', 'enoughPostsForFiltering'),
showName: Discourse.computed.propertyNotEqual('user.name', 'user.username'),
show: function(post) {
@ -28,6 +30,14 @@ Discourse.PosterExpansionController = Discourse.ObjectController.extend({
// If we're showing the same user we showed last time, just keep it
if (post.get('username') === currentUsername) { return; }
this.set('participant', null);
// Retrieve their participants info
var participants = this.get('topic.details.participants');
if (participants) {
this.set('participant', participants.findBy('username', post.get('username')));
}
var self = this;
self.set('user', null);
Discourse.User.findByUsername(post.get('username')).then(function (user) {

View File

@ -19,7 +19,7 @@
{{#link-to 'user' user class="btn"}}<i class='icon icon-user'></i>{{i18n user.show_profile}}{{/link-to}}
{{#if showFilter}}
<button class='btn' {{action togglePosts user}}><i class='icon icon-filter'></i>{{i18n topic.filter_to username="username"}}</button>
<button class='btn' {{action togglePosts user}}><i class='icon icon-filter'></i>{{i18n topic.filter_to username="username" post_count="participant.post_count"}}</button>
{{/if}}
</div>

View File

@ -574,7 +574,7 @@ en:
title: Topic Rank Details
topic:
filter_to: "Show only posts by {{username}} in this topic"
filter_to: "Show only the {{post_count}} posts by {{username}} in this topic"
create_in: 'Create {{categoryName}} Topic'
create: 'Create Topic'
create_long: 'Create a new Topic'