summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-04-17 20:14:51 +0200
committerArthur Schiwon <blizzz@owncloud.com>2014-06-02 12:53:56 +0200
commit7b8935abdacfa25c55738b0395440c84bf86ffbb (patch)
tree2ccd90ba02a4269357d49c815504e2d46c0762e3
parent734dd7013eaa3291cb61a7490e173cdf068b4298 (diff)
downloadnextcloud-server-7b8935abdacfa25c55738b0395440c84bf86ffbb.tar.gz
nextcloud-server-7b8935abdacfa25c55738b0395440c84bf86ffbb.zip
show users whose username starts with the search pattern first
We may want to switch or extend it to display name. I leave it like this for now, continued work on this needs to have sortable columns in mind
-rw-r--r--settings/js/users/users.js41
1 files changed, 37 insertions, 4 deletions
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
index d1cab63eaab..092998c029f 100644
--- a/settings/js/users/users.js
+++ b/settings/js/users/users.js
@@ -145,12 +145,43 @@ var UserList = {
}
return aa.length - bb.length;
},
+ preSortSearchString: function(a, b) {
+ var pattern = filter.getPattern();
+ if(typeof pattern === 'undefined') {
+ return undefined;
+ }
+ pattern = pattern.toLowerCase();
+ var aMatches = false;
+ var bMatches = false;
+ if(typeof a === 'string' && a.toLowerCase().indexOf(pattern) === 0) {
+ aMatches = true;
+ }
+ if(typeof b === 'string' && b.toLowerCase().indexOf(pattern) === 0) {
+ bMatches = true;
+ }
+
+ if((aMatches && bMatches) || (!aMatches && !bMatches)) {
+ return undefined;
+ }
+
+ if(aMatches) {
+ return -1;
+ } else {
+ return 1;
+ }
+ },
doSort: function() {
var self = this;
var rows = $('tbody tr').get();
rows.sort(function(a, b) {
- return UserList.alphanum($(a).find('td.name').text(), $(b).find('td.name').text());
+ a = $(a).find('td.name').text();
+ b = $(b).find('td.name').text();
+ var firstSort = UserList.preSortSearchString(a, b);
+ if(typeof firstSort !== 'undefined') {
+ return firstSort;
+ }
+ return UserList.alphanum(a, b);
});
var items = [];
@@ -391,6 +422,10 @@ function setQuota (uid, quota, ready) {
$(document).ready(function () {
UserList.initDeleteHandling();
+ // Implements User Search
+ filter = new UserManagementFilter(
+ $('#usersearchform input'), UserList, GroupList);
+
UserList.doSort();
UserList.availableGroups = $('#content table').data('groups');
@@ -548,7 +583,5 @@ $(document).ready(function () {
}
);
});
- // Implements User Search
- filter = new UserManagementFilter(
- $('#usersearchform input'), UserList, GroupList);
+
});