diff --git a/app/assets/javascripts/discourse/controllers/user-invited-show.js.es6 b/app/assets/javascripts/discourse/controllers/user-invited-show.js.es6 index 781d9be9ab8..f03d7d0d8f2 100644 --- a/app/assets/javascripts/discourse/controllers/user-invited-show.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-invited-show.js.es6 @@ -7,6 +7,7 @@ export default Ember.Controller.extend({ model: null, filter: null, totalInvites: null, + invitesCount: null, canLoadMore: true, invitesLoading: false, @@ -58,6 +59,22 @@ export default Ember.Controller.extend({ return this.get('totalInvites') > 9; }.property('totalInvites'), + pendingLabel: function() { + if (this.get('invitesCount.total') > 50) { + return I18n.t('user.invited.pending_tab_with_count', {count: this.get('invitesCount.pending')}); + } else { + return I18n.t('user.invited.pending_tab'); + } + }.property('invitesCount'), + + redeemedLabel: function() { + if (this.get('invitesCount.total') > 50) { + return I18n.t('user.invited.redeemed_tab_with_count', {count: this.get('invitesCount.redeemed')}); + } else { + return I18n.t('user.invited.redeemed_tab'); + } + }.property('invitesCount'), + actions: { rescind(invite) { diff --git a/app/assets/javascripts/discourse/models/invite.js.es6 b/app/assets/javascripts/discourse/models/invite.js.es6 index 8f9bcd0bdea..49a116bda60 100644 --- a/app/assets/javascripts/discourse/models/invite.js.es6 +++ b/app/assets/javascripts/discourse/models/invite.js.es6 @@ -43,6 +43,11 @@ Invite.reopenClass({ return Em.Object.create(result); }); + }, + + findInvitedCount(user) { + if (!user) { return Em.RSVP.resolve(); } + return Discourse.ajax("/users/" + user.get('username_lower') + "/invited_count.json").then(result => Em.Object.create(result.counts)); } }); diff --git a/app/assets/javascripts/discourse/routes/user-invited-show.js.es6 b/app/assets/javascripts/discourse/routes/user-invited-show.js.es6 index 48e6d415cb5..c9465fa7d14 100644 --- a/app/assets/javascripts/discourse/routes/user-invited-show.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-invited-show.js.es6 @@ -4,8 +4,12 @@ import showModal from "discourse/lib/show-modal"; export default Discourse.Route.extend({ model(params) { - this.inviteFilter = params.filter; - return Invite.findInvitedBy(this.modelFor("user"), params.filter); + const self = this; + Invite.findInvitedCount(self.modelFor("user")).then(function (result) { + self.set('invitesCount', result); + }); + self.inviteFilter = params.filter; + return Invite.findInvitedBy(self.modelFor("user"), params.filter); }, afterModel(model) { @@ -20,7 +24,8 @@ export default Discourse.Route.extend({ user: this.controllerFor("user").get("model"), filter: this.inviteFilter, searchTerm: "", - totalInvites: model.invites.length + totalInvites: model.invites.length, + invitesCount: this.get('invitesCount') }); }, diff --git a/app/assets/javascripts/discourse/templates/components/nav-item.hbs b/app/assets/javascripts/discourse/templates/components/nav-item.hbs index ec8e0a1e758..96c49a6fc3d 100644 --- a/app/assets/javascripts/discourse/templates/components/nav-item.hbs +++ b/app/assets/javascripts/discourse/templates/components/nav-item.hbs @@ -1,5 +1,9 @@ {{#if routeParam}} - {{#link-to route routeParam}}{{i18n label}}{{/link-to}} + {{#if i18nLabel}} + {{#link-to route routeParam}}{{i18nLabel}}{{/link-to}} + {{else}} + {{#link-to route routeParam}}{{i18n label}}{{/link-to}} + {{/if}} {{else}} {{#if route}} {{#link-to route}}{{i18n label}}{{/link-to}} diff --git a/app/assets/javascripts/discourse/templates/user-invited-show.hbs b/app/assets/javascripts/discourse/templates/user-invited-show.hbs index a13bb5860c5..29c37bcb992 100644 --- a/app/assets/javascripts/discourse/templates/user-invited-show.hbs +++ b/app/assets/javascripts/discourse/templates/user-invited-show.hbs @@ -6,8 +6,8 @@