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);
});
});
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();
$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'];
$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()) {
* @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;
}