fix sorting in the backend

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2017-03-22 17:11:09 -06:00
parent 31fa2f73d4
commit dbaebc53b0
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
4 changed files with 3 additions and 80 deletions

View File

@ -260,9 +260,6 @@
var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(lookup);
if (suggestions.length > 0) {
suggestions.sort(function (a, b) {
return OC.Util.naturalSortCompare(a.label, b.label);
});
$shareWithField
.autocomplete("option", "autoFocus", true);

View File

@ -490,80 +490,6 @@ describe('OC.Share.ShareDialogView', function() {
});
});
describe('autocompletion of users', function() {
it('is sorted naturally', function () {
dialog.render();
var response = sinon.stub();
dialog.autocompleteHandler({term: 'p'}, response);
var jsonData = JSON.stringify({
'ocs' : {
'meta' : {
'status' : 'success',
'statuscode' : 100,
'message' : null
},
'data' : {
'exact' : {
'users' : [],
'groups' : [],
'remotes': []
},
'users' : [{
"label": "Peter A.",
"value": {
"shareType": 0,
"shareWith": "Peter A."
}
},
{
"label": "Petra",
"value": {
"shareType": 0,
"shareWith": "Petra"
}
},
{
"label": "peter B.",
"value": {
"shareType": 0,
"shareWith": "peter B."
}
}],
'groups' : [],
'remotes': []
}
}
});
fakeServer.requests[0].respond(
200,
{'Content-Type': 'application/json'},
jsonData
);
expect(response.calledWithExactly([
{
"label": "Peter A.",
"value": {
"shareType": 0,
"shareWith": "Peter A."
}
},
{
"label": "peter B.",
"value": {
"shareType": 0,
"shareWith": "peter B."
}
},
{
"label": "Petra",
"value": {
"shareType": 0,
"shareWith": "Petra"
}
}
])).toEqual(true);
});
it('triggers autocomplete display and focus with data when ajax search succeeds', function () {
dialog.render();
var response = sinon.stub();

View File

@ -193,7 +193,7 @@ class Database extends Backend implements IUserBackend {
$displayNames = array();
$query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
. $searchLike .' ORDER BY `uid` ASC', $limit, $offset);
. $searchLike .' ORDER BY LOWER(`displayname`), LOWER(`uid`) ASC', $limit, $offset);
$result = $query->execute($parameters);
while ($row = $result->fetchRow()) {
$displayNames[$row['uid']] = $row['displayname'];
@ -279,7 +279,7 @@ class Database extends Backend implements IUserBackend {
$searchLike = ' WHERE LOWER(`uid`) LIKE LOWER(?)';
}
$query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY `uid` ASC', $limit, $offset);
$query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users`' . $searchLike . ' ORDER BY LOWER(`uid`) ASC', $limit, $offset);
$result = $query->execute($parameters);
$users = array();
while ($row = $result->fetchRow()) {

View File

@ -254,7 +254,7 @@ class Manager extends PublicEmitter implements IUserManager {
* @var \OC\User\User $a
* @var \OC\User\User $b
*/
return strcmp($a->getDisplayName(), $b->getDisplayName());
return strcmp(strtolower($a->getDisplayName()), strtolower($b->getDisplayName()));
});
return $users;
}