mirror of
https://github.com/discourse/discourse.git
synced 2024-12-16 06:15:59 +08:00
fe588cc7f8
* DEV: Fix the function prototype observers deprecation DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.observes('foo') to observer('foo', function() {}). [deprecation id: function-prototype-extensions.observes] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-observes for more details. * DEV: Fix the function prototype event listeners deprecation DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.on('foo') to on('foo', function() {}). [deprecation id: function-prototype-extensions.on] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-on for more details. * DEV: Simplify `default as` imports Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
81 lines
1.8 KiB
JavaScript
81 lines
1.8 KiB
JavaScript
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
|
import Controller from "@ember/controller";
|
|
import discourseDebounce from "discourse/lib/debounce";
|
|
import { i18n } from "discourse/lib/computed";
|
|
import AdminUser from "admin/models/admin-user";
|
|
import CanCheckEmails from "discourse/mixins/can-check-emails";
|
|
|
|
export default Controller.extend(CanCheckEmails, {
|
|
model: null,
|
|
query: null,
|
|
order: null,
|
|
ascending: null,
|
|
showEmails: false,
|
|
refreshing: false,
|
|
listFilter: null,
|
|
selectAll: false,
|
|
searchHint: i18n("search_hint"),
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
|
|
this._page = 1;
|
|
this._results = [];
|
|
this._canLoadMore = true;
|
|
},
|
|
|
|
@discourseComputed("query")
|
|
title(query) {
|
|
return I18n.t("admin.users.titles." + query);
|
|
},
|
|
|
|
@observes("listFilter")
|
|
_filterUsers: discourseDebounce(function() {
|
|
this.resetFilters();
|
|
}, 250),
|
|
|
|
resetFilters() {
|
|
this._page = 1;
|
|
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,
|
|
page: this._page
|
|
})
|
|
.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.resetFilters();
|
|
}
|
|
}
|
|
});
|