some search/sort changes

v1.18.x
barisusakli 9 years ago
parent 7568e88800
commit ab6c84471b

@ -31,6 +31,9 @@ define('forum/users', ['translator'], function(translator) {
};
function loadMoreUsers() {
if ($('#search-user').val()) {
return;
}
var set = '';
var activeSection = getActiveSection();
if (activeSection === 'sort-posts') {
@ -114,7 +117,7 @@ define('forum/users', ['translator'], function(translator) {
query: username,
page: page,
searchBy: 'username',
sortBy: $('.search select').val(),
sortBy: $('.search select').val() || getSortBy(),
onlineOnly: $('.search .online-only').is(':checked')
}, function(err, data) {
if (err) {
@ -125,8 +128,25 @@ define('forum/users', ['translator'], function(translator) {
});
}
function getSortBy() {
var sortBy;
var activeSection = getActiveSection();
if (activeSection === 'sort-posts') {
sortBy = 'postcount';
} else if (activeSection === 'sort-reputation') {
sortBy = 'reputation';
} else if (activeSection === 'users') {
sortBy = 'joindate';
}
return sortBy;
}
function loadPage(page) {
socket.emit('user.loadSearchPage', {page: page, onlineOnly: $('.search .online-only').is(':checked')}, function(err, data) {
socket.emit('user.loadSearchPage', {
page: page,
sortBy: getSortBy(),
onlineOnly: $('.search .online-only').is(':checked')
}, function(err, data) {
if (err) {
return app.alertError(err.message);
}
@ -143,10 +163,11 @@ define('forum/users', ['translator'], function(translator) {
templates.parse('users', 'users', data, function(html) {
translator.translate(html, function(translated) {
translated = $(translated)
$('#users-container').html(translated);
translated.find('span.timeago').timeago();
});
});
}
function onUserStatusChange(data) {

@ -8,6 +8,7 @@ var meta = require('../../meta');
var pagination = require('../../pagination');
module.exports = function(SocketUser) {
SocketUser.search = function(socket, data, callback) {
if (!data) {
return callback(new Error('[[error:invalid-data]]'));
@ -27,6 +28,7 @@ module.exports = function(SocketUser) {
return callback(err);
}
result.pagination = pagination.create(data.page, result.pageCount);
result['route_users:' + data.sortBy] = true;
callback(null, result);
});
};
@ -44,6 +46,7 @@ module.exports = function(SocketUser) {
pagination: pagination.create(data.page, pageCount),
pageCount: pageCount
};
userData['route_users:' + data.sortBy] = true;
callback(null, userData);
}
@ -69,7 +72,7 @@ module.exports = function(SocketUser) {
}
}, done);
} else {
controllers.getUsersAndCount('users:joindate', socket.uid, start, stop, done);
controllers.getUsersAndCount('users:' + data.sortBy, socket.uid, start, stop, done);
}
};

@ -116,7 +116,7 @@ var async = require('async'),
user.administrator = results.isAdmin[index];
user.banned = parseInt(user.banned, 10) === 1;
user['email:confirmed'] = parseInt(user['email:confirmed'], 10) === 1;
user.lastonlineISO = utils.toISOString(user.lastonline);
user.lastonlineISO = utils.toISOString(user.lastonline) || user.joindateISO;
}
});
plugins.fireHook('filter:userlist.get', {users: results.userData, uid: uid}, next);

@ -108,7 +108,7 @@ module.exports = function(User) {
}
function sortUsers(userData, sortBy) {
if (sortBy === 'joindate' || sortBy === 'postcount') {
if (sortBy === 'joindate' || sortBy === 'postcount' || sortBy === 'reputation') {
userData.sort(function(u1, u2) {
return u2[sortBy] - u1[sortBy];
});

Loading…
Cancel
Save