Only show filter button if the user has more than 2 posts
This commit is contained in:
parent
bccb37b6f3
commit
8e6ae0e278
|
@ -10,8 +10,10 @@ Discourse.PosterExpansionController = Discourse.ObjectController.extend({
|
||||||
needs: ['topic'],
|
needs: ['topic'],
|
||||||
visible: false,
|
visible: false,
|
||||||
user: null,
|
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'),
|
showName: Discourse.computed.propertyNotEqual('user.name', 'user.username'),
|
||||||
|
|
||||||
show: function(post) {
|
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 we're showing the same user we showed last time, just keep it
|
||||||
if (post.get('username') === currentUsername) { return; }
|
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;
|
var self = this;
|
||||||
self.set('user', null);
|
self.set('user', null);
|
||||||
Discourse.User.findByUsername(post.get('username')).then(function (user) {
|
Discourse.User.findByUsername(post.get('username')).then(function (user) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
{{#link-to 'user' user class="btn"}}<i class='icon icon-user'></i>{{i18n user.show_profile}}{{/link-to}}
|
{{#link-to 'user' user class="btn"}}<i class='icon icon-user'></i>{{i18n user.show_profile}}{{/link-to}}
|
||||||
|
|
||||||
{{#if showFilter}}
|
{{#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}}
|
{{/if}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -574,7 +574,7 @@ en:
|
||||||
title: Topic Rank Details
|
title: Topic Rank Details
|
||||||
|
|
||||||
topic:
|
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_in: 'Create {{categoryName}} Topic'
|
||||||
create: 'Create Topic'
|
create: 'Create Topic'
|
||||||
create_long: 'Create a new Topic'
|
create_long: 'Create a new Topic'
|
||||||
|
|
Loading…
Reference in New Issue