summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2016-10-25 08:22:33 +0200
committerGitHub <noreply@github.com>2016-10-25 08:22:33 +0200
commit60fa82d92fe6ac911a8b45350c74dd0bde4490f8 (patch)
treed392ff247dc700c11da855254822aa5b4c5923c8 /apps
parent44e9f5d5a17337458c74f285c7b53a92df7e76da (diff)
parent3e96f33995c522106b645908b4537b25536b8a7d (diff)
downloadnextcloud-server-60fa82d92fe6ac911a8b45350c74dd0bde4490f8.tar.gz
nextcloud-server-60fa82d92fe6ac911a8b45350c74dd0bde4490f8.zip
Merge pull request #1860 from ryanwr/feature-sort-favorite
Sort favorite files first
Diffstat (limited to 'apps')
-rw-r--r--apps/files/js/filelist.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 159d008e6e6..53ad8eafeef 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1500,13 +1500,15 @@
var comparator = FileList.Comparators[sort] || FileList.Comparators.name;
this._sort = sort;
this._sortDirection = (direction === 'desc')?'desc':'asc';
- this._sortComparator = comparator;
+ this._sortComparator = function(fileInfo1, fileInfo2) {
+ if(fileInfo1.isFavorite && !fileInfo2.isFavorite) {
+ return -1;
+ } else if(!fileInfo1.isFavorite && fileInfo2.isFavorite) {
+ return 1;
+ }
+ return direction === 'asc' ? comparator(fileInfo1, fileInfo2) : -comparator(fileInfo1, fileInfo2);
+ };
- if (direction === 'desc') {
- this._sortComparator = function(fileInfo1, fileInfo2) {
- return -comparator(fileInfo1, fileInfo2);
- };
- }
this.$el.find('thead th .sort-indicator')
.removeClass(this.SORT_INDICATOR_ASC_CLASS)
.removeClass(this.SORT_INDICATOR_DESC_CLASS)