mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: adds infite scroll on admin users list page (#7821)
This commit is contained in:
@ -15,32 +15,64 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||
selectAll: false,
|
||||
searchHint: i18n("search_hint"),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
this._page = 0;
|
||||
this._results = [];
|
||||
this._canLoadMore = true;
|
||||
},
|
||||
|
||||
@computed("query")
|
||||
title(query) {
|
||||
return I18n.t("admin.users.titles." + query);
|
||||
},
|
||||
|
||||
_filterUsers: debounce(function() {
|
||||
this._refreshUsers();
|
||||
this.resetFilters();
|
||||
}, 250).observes("listFilter"),
|
||||
|
||||
resetFilters() {
|
||||
this._page = 0;
|
||||
this._results = [];
|
||||
this._canLoadMore = true;
|
||||
this._refreshUsers();
|
||||
},
|
||||
|
||||
_refreshUsers() {
|
||||
if (!this._canLoadMore) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.set("refreshing", true);
|
||||
|
||||
AdminUser.findAll(this.query, {
|
||||
filter: this.listFilter,
|
||||
show_emails: this.showEmails,
|
||||
order: this.order,
|
||||
ascending: this.ascending
|
||||
ascending: this.ascending,
|
||||
page: this._page
|
||||
})
|
||||
.then(result => this.set("model", result))
|
||||
.then(result => {
|
||||
if (!result || result.length === 0) {
|
||||
this._canLoadMore = false;
|
||||
}
|
||||
|
||||
this._results = this._results.concat(result);
|
||||
this.set("model", this._results);
|
||||
})
|
||||
.finally(() => this.set("refreshing", false));
|
||||
},
|
||||
|
||||
actions: {
|
||||
loadMore() {
|
||||
this._page += 1;
|
||||
this._refreshUsers();
|
||||
},
|
||||
|
||||
toggleEmailVisibility() {
|
||||
this.toggleProperty("showEmails");
|
||||
this._refreshUsers();
|
||||
this.resetFilters();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user