users dialog: export selected emails only (if one or more users are selected)

This commit is contained in:
rolux 2015-01-22 14:37:17 +05:30
parent 5dc7564b4f
commit 47b181d8cf

View file

@ -525,14 +525,9 @@ pandora.ui.usersDialog = function() {
click: function() {
var $button = this;
$button.options({disabled: true});
pandora.api.findUsers({
query: {conditions: [], operator: '&'},
keys: ['email', 'username'],
range: [0, numberOfUsers],
sort: [{key: 'username', operator: '+'}]
}, function(result) {
getEmailAddresses(function(items) {
pandora.ui.exportDialog({
data: result.data.items.filter(function(item) {
data: items.filter(function(item) {
return item.email;
}).map(function(item) {
return Ox.encodeHTMLEntities(item.username)
@ -588,6 +583,25 @@ pandora.ui.usersDialog = function() {
that.superClose();
};
function getEmailAddresses(callback) {
pandora.api.findUsers({
query: {conditions: [
{key: 'level', value: 'guest', operator: '!='},
{key: 'level', value: 'robot', operator: '!='}
], operator: '&'},
keys: ['id', 'username', 'email'],
range: [0, 1000000],
sort: [{key: 'username', operator: '+'}]
}, function(result) {
var selected = $list.options('selected');
callback(result.data.items.filter(function(user) {
return !selected.length || Ox.contains(selected, user.id);
}).map(function(user) {
return {username: user.username, email: user.email};
}));
});
}
function getFormItemById(id) {
var ret;
Ox.forEach((