mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
DEV: introduces prettier for es6 files
This commit is contained in:
@ -1,12 +1,11 @@
|
||||
import debounce from 'discourse/lib/debounce';
|
||||
import { i18n } from 'discourse/lib/computed';
|
||||
import AdminUser from 'admin/models/admin-user';
|
||||
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
import debounce from "discourse/lib/debounce";
|
||||
import { i18n } from "discourse/lib/computed";
|
||||
import AdminUser from "admin/models/admin-user";
|
||||
import { observes } from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
query: null,
|
||||
queryParams: ['order', 'ascending'],
|
||||
queryParams: ["order", "ascending"],
|
||||
order: null,
|
||||
ascending: null,
|
||||
showEmails: false,
|
||||
@ -14,72 +13,88 @@ export default Ember.Controller.extend({
|
||||
listFilter: null,
|
||||
selectAll: false,
|
||||
|
||||
queryNew: Em.computed.equal('query', 'new'),
|
||||
queryPending: Em.computed.equal('query', 'pending'),
|
||||
queryHasApproval: Em.computed.or('queryNew', 'queryPending'),
|
||||
showApproval: Em.computed.and('siteSettings.must_approve_users', 'queryHasApproval'),
|
||||
searchHint: i18n('search_hint'),
|
||||
hasSelection: Em.computed.gt('selectedCount', 0),
|
||||
queryNew: Em.computed.equal("query", "new"),
|
||||
queryPending: Em.computed.equal("query", "pending"),
|
||||
queryHasApproval: Em.computed.or("queryNew", "queryPending"),
|
||||
showApproval: Em.computed.and(
|
||||
"siteSettings.must_approve_users",
|
||||
"queryHasApproval"
|
||||
),
|
||||
searchHint: i18n("search_hint"),
|
||||
hasSelection: Em.computed.gt("selectedCount", 0),
|
||||
|
||||
selectedCount: function() {
|
||||
var model = this.get('model');
|
||||
var model = this.get("model");
|
||||
if (!model || !model.length) return 0;
|
||||
return model.filterBy('selected').length;
|
||||
}.property('model.@each.selected'),
|
||||
return model.filterBy("selected").length;
|
||||
}.property("model.@each.selected"),
|
||||
|
||||
selectAllChanged: function() {
|
||||
var val = this.get('selectAll');
|
||||
this.get('model').forEach(function(user) {
|
||||
if (user.get('can_approve')) {
|
||||
user.set('selected', val);
|
||||
var val = this.get("selectAll");
|
||||
this.get("model").forEach(function(user) {
|
||||
if (user.get("can_approve")) {
|
||||
user.set("selected", val);
|
||||
}
|
||||
});
|
||||
}.observes('selectAll'),
|
||||
}.observes("selectAll"),
|
||||
|
||||
title: function() {
|
||||
return I18n.t('admin.users.titles.' + this.get('query'));
|
||||
}.property('query'),
|
||||
return I18n.t("admin.users.titles." + this.get("query"));
|
||||
}.property("query"),
|
||||
|
||||
_filterUsers: debounce(function() {
|
||||
this._refreshUsers();
|
||||
}, 250).observes('listFilter'),
|
||||
}, 250).observes("listFilter"),
|
||||
|
||||
|
||||
@observes('order', 'ascending')
|
||||
@observes("order", "ascending")
|
||||
_refreshUsers: function() {
|
||||
this.set('refreshing', true);
|
||||
this.set("refreshing", true);
|
||||
|
||||
AdminUser.findAll(this.get('query'), { filter: this.get('listFilter'), show_emails: this.get('showEmails'), order: this.get('order'), ascending: this.get('ascending') }).then( (result) => {
|
||||
this.set('model', result);
|
||||
}).finally( () => {
|
||||
this.set('refreshing', false);
|
||||
});
|
||||
AdminUser.findAll(this.get("query"), {
|
||||
filter: this.get("listFilter"),
|
||||
show_emails: this.get("showEmails"),
|
||||
order: this.get("order"),
|
||||
ascending: this.get("ascending")
|
||||
})
|
||||
.then(result => {
|
||||
this.set("model", result);
|
||||
})
|
||||
.finally(() => {
|
||||
this.set("refreshing", false);
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
approveUsers: function() {
|
||||
AdminUser.bulkApprove(this.get('model').filterBy('selected'));
|
||||
AdminUser.bulkApprove(this.get("model").filterBy("selected"));
|
||||
this._refreshUsers();
|
||||
},
|
||||
|
||||
rejectUsers: function() {
|
||||
var maxPostAge = this.siteSettings.delete_user_max_post_age;
|
||||
var controller = this;
|
||||
AdminUser.bulkReject(this.get('model').filterBy('selected')).then(function(result){
|
||||
var message = I18n.t("admin.users.reject_successful", {count: result.success});
|
||||
if (result.failed > 0) {
|
||||
message += ' ' + I18n.t("admin.users.reject_failures", {count: result.failed});
|
||||
message += ' ' + I18n.t("admin.user.delete_forbidden", {count: maxPostAge});
|
||||
AdminUser.bulkReject(this.get("model").filterBy("selected")).then(
|
||||
function(result) {
|
||||
var message = I18n.t("admin.users.reject_successful", {
|
||||
count: result.success
|
||||
});
|
||||
if (result.failed > 0) {
|
||||
message +=
|
||||
" " +
|
||||
I18n.t("admin.users.reject_failures", { count: result.failed });
|
||||
message +=
|
||||
" " +
|
||||
I18n.t("admin.user.delete_forbidden", { count: maxPostAge });
|
||||
}
|
||||
bootbox.alert(message);
|
||||
controller._refreshUsers();
|
||||
}
|
||||
bootbox.alert(message);
|
||||
controller._refreshUsers();
|
||||
});
|
||||
);
|
||||
},
|
||||
|
||||
showEmails: function() {
|
||||
this.set('showEmails', true);
|
||||
this.set("showEmails", true);
|
||||
this._refreshUsers(true);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user