diff --git a/app/assets/javascripts/discourse/controllers/user-invited.js.es6 b/app/assets/javascripts/discourse/controllers/user-invited.js.es6
index 611266b4831..a37e929e7ac 100644
--- a/app/assets/javascripts/discourse/controllers/user-invited.js.es6
+++ b/app/assets/javascripts/discourse/controllers/user-invited.js.es6
@@ -10,6 +10,8 @@ export default Ember.ObjectController.extend({
user: null,
model: null,
totalInvites: null,
+ canLoadMore: true,
+ invitesLoading: false,
init: function() {
this._super();
@@ -30,13 +32,6 @@ export default Ember.ObjectController.extend({
});
}, 250).observes('searchTerm'),
- /**
- The maximum amount of invites that will be displayed in the view
-
- @property maxInvites
- **/
- maxInvites: Discourse.computed.setting('invites_shown'),
-
/**
Can the currently logged in user invite users to the site
@@ -64,15 +59,6 @@ export default Ember.ObjectController.extend({
return this.get('totalInvites') > 9;
}.property('totalInvites'),
- /**
- Were the results limited by our `maxInvites`
-
- @property truncated
- **/
- truncated: function() {
- return this.get('invites.length') === Discourse.SiteSettings.invites_shown;
- }.property('invites.length'),
-
actions: {
/**
@@ -84,6 +70,22 @@ export default Ember.ObjectController.extend({
rescind: function(invite) {
invite.rescind();
return false;
+ },
+
+ loadMore: function() {
+ var self = this;
+ var model = self.get('model');
+
+ if(self.get('canLoadMore')) {
+ self.set('invitesLoading', true);
+ Discourse.Invite.findInvitedBy(self.get('user'), self.get('searchTerm'), model.invites.length).then(function(invite_model) {
+ self.set('invitesLoading', false);
+ model.invites.pushObjects(invite_model.invites);
+ if(invite_model.invites.length === 0 || invite_model.invites.length < Discourse.SiteSettings.invites_per_page) {
+ self.set('canLoadMore', false);
+ }
+ });
+ }
}
}
diff --git a/app/assets/javascripts/discourse/models/invite.js b/app/assets/javascripts/discourse/models/invite.js
index a4211525659..3ed3ae5ab3d 100644
--- a/app/assets/javascripts/discourse/models/invite.js
+++ b/app/assets/javascripts/discourse/models/invite.js
@@ -29,11 +29,12 @@ Discourse.Invite.reopenClass({
return result;
},
- findInvitedBy: function(user, filter) {
+ findInvitedBy: function(user, filter, offset) {
if (!user) { return Em.RSVP.resolve(); }
var data = {};
if (!Em.isNone(filter)) { data.filter = filter; }
+ data.offset = offset || 0;
return Discourse.ajax("/users/" + user.get('username_lower') + "/invited.json", {data: data}).then(function (result) {
result.invites = result.invites.map(function (i) {
diff --git a/app/assets/javascripts/discourse/templates/user/invited.js.handlebars b/app/assets/javascripts/discourse/templates/user/invited.js.handlebars
index 19d2077add3..1cc1676d9e2 100644
--- a/app/assets/javascripts/discourse/templates/user/invited.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/user/invited.js.handlebars
@@ -17,7 +17,7 @@
{{/if}}
{{#if model.invites}}
-
+
{{i18n user.invited.user}} |
{{i18n user.invited.redeemed_at}} |
@@ -62,9 +62,8 @@
{{/each}}
-
- {{#if truncated}}
- {{i18n user.invited.truncated count=maxInvites}}
+ {{#if invitesLoading}}
+ {{i18n loading}}
{{/if}}
{{else}}
diff --git a/app/assets/javascripts/discourse/views/user-invited.js.es6 b/app/assets/javascripts/discourse/views/user-invited.js.es6
index dc4f8dc4017..55c4d94c857 100644
--- a/app/assets/javascripts/discourse/views/user-invited.js.es6
+++ b/app/assets/javascripts/discourse/views/user-invited.js.es6
@@ -1,3 +1,5 @@
-export default Ember.View.extend({
+export default Ember.View.extend(Discourse.LoadMore, {
+ classNames: ['paginated-topics-list'],
+ eyelineSelector: '.paginated-topics-list .invite-list tr',
templateName: 'user/invited'
});
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c624fd6fb60..abb5b212a76 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -94,11 +94,12 @@ class UsersController < ApplicationController
def invited
inviter = fetch_user_from_params
+ offset = params[:offset].to_i || 0
invites = if guardian.can_see_invite_details?(inviter)
- Invite.find_all_invites_from(inviter)
+ Invite.find_all_invites_from(inviter, offset)
else
- Invite.find_redeemed_invites_from(inviter)
+ Invite.find_redeemed_invites_from(inviter, offset)
end
invites = invites.filter_by(params[:filter])
diff --git a/app/models/invite.rb b/app/models/invite.rb
index dc1db2b1d5a..7cbcf7be0c2 100644
--- a/app/models/invite.rb
+++ b/app/models/invite.rb
@@ -126,18 +126,19 @@ class Invite < ActiveRecord::Base
group_ids
end
- def self.find_all_invites_from(inviter)
+ def self.find_all_invites_from(inviter, offset=0)
Invite.where(invited_by_id: inviter.id)
.includes(:user => :user_stat)
.order('CASE WHEN invites.user_id IS NOT NULL THEN 0 ELSE 1 END',
'user_stats.time_read DESC',
'invites.redeemed_at DESC')
- .limit(SiteSetting.invites_shown)
+ .limit(SiteSetting.invites_per_page)
+ .offset(offset)
.references('user_stats')
end
- def self.find_redeemed_invites_from(inviter)
- find_all_invites_from(inviter).where('invites.user_id IS NOT NULL')
+ def self.find_redeemed_invites_from(inviter, offset=0)
+ find_all_invites_from(inviter, offset).where('invites.user_id IS NOT NULL')
end
def self.filter_by(email_or_username)
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 1931912839f..2223334df2c 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -951,7 +951,7 @@ en:
enable_names: "Allow showing user full names. Disable to hide full names."
display_name_on_posts: "Show a user's full name on their posts in addition to their @username."
- invites_shown: "Maximum invites shown on the user page."
+ invites_per_page: "Default invites shown on the user page."
short_progress_text_threshold: "After the number of posts in a topic goes above this number, the progress bar will only show the current post number. If you change the progress bar's width, you may need to change this value."
default_code_lang: "Default programming language syntax highlighting applied to GitHub code blocks (lang-auto, ruby, python etc.)"
warn_reviving_old_topic_age: "When someone starts replying to a topic where the last reply is older than this many days, a warning will be displayed. Disable by setting to 0."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 47ae13043ca..aa66a28deef 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -257,9 +257,9 @@ users:
default: true
invite_expiry_days: 30
invite_passthrough_hours: 0
- invites_shown:
+ invites_per_page:
client: true
- default: 30
+ default: 40
delete_user_max_post_age:
client: true
default: 60