2018-06-15 23:03:24 +08:00
|
|
|
import debounce from "discourse/lib/debounce";
|
|
|
|
import { i18n } from "discourse/lib/computed";
|
|
|
|
import AdminUser from "admin/models/admin-user";
|
2018-12-19 17:24:57 +08:00
|
|
|
import CanCheckEmails from "discourse/mixins/can-check-emails";
|
2019-04-26 18:16:21 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
2015-08-08 03:08:27 +08:00
|
|
|
|
2018-12-19 17:24:57 +08:00
|
|
|
export default Ember.Controller.extend(CanCheckEmails, {
|
2019-02-26 17:43:24 +08:00
|
|
|
model: null,
|
2014-11-27 02:05:49 +08:00
|
|
|
query: null,
|
2017-04-05 16:27:34 +08:00
|
|
|
order: null,
|
2017-02-20 21:42:33 +08:00
|
|
|
ascending: null,
|
2014-11-27 02:05:49 +08:00
|
|
|
showEmails: false,
|
|
|
|
refreshing: false,
|
|
|
|
listFilter: null,
|
|
|
|
selectAll: false,
|
2018-06-15 23:03:24 +08:00
|
|
|
searchHint: i18n("search_hint"),
|
2014-11-27 02:05:49 +08:00
|
|
|
|
2019-04-26 18:16:21 +08:00
|
|
|
@computed("query")
|
|
|
|
title(query) {
|
|
|
|
return I18n.t("admin.users.titles." + query);
|
|
|
|
},
|
2014-11-27 02:05:49 +08:00
|
|
|
|
2015-08-11 05:11:27 +08:00
|
|
|
_filterUsers: debounce(function() {
|
2014-11-27 02:05:49 +08:00
|
|
|
this._refreshUsers();
|
2018-06-15 23:03:24 +08:00
|
|
|
}, 250).observes("listFilter"),
|
2017-02-20 21:42:33 +08:00
|
|
|
|
2019-02-26 17:43:24 +08:00
|
|
|
_refreshUsers() {
|
2018-06-15 23:03:24 +08:00
|
|
|
this.set("refreshing", true);
|
2014-11-27 02:05:49 +08:00
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
AdminUser.findAll(this.query, {
|
|
|
|
filter: this.listFilter,
|
|
|
|
show_emails: this.showEmails,
|
|
|
|
order: this.order,
|
|
|
|
ascending: this.ascending
|
2018-06-15 23:03:24 +08:00
|
|
|
})
|
2019-02-26 17:43:24 +08:00
|
|
|
.then(result => this.set("model", result))
|
|
|
|
.finally(() => this.set("refreshing", false));
|
2014-11-27 02:05:49 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2019-01-04 01:03:01 +08:00
|
|
|
toggleEmailVisibility() {
|
2019-03-21 17:16:58 +08:00
|
|
|
this.toggleProperty("showEmails");
|
2019-02-26 17:43:24 +08:00
|
|
|
this._refreshUsers();
|
2014-11-27 02:05:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|