Sort favorite files first Issue #1802
Signed-off-by: Ryan Welch <ryantwr@gmail.com>
This commit is contained in:
parent
9965a95e3b
commit
3e96f33995
|
@ -1500,13 +1500,15 @@
|
||||||
var comparator = FileList.Comparators[sort] || FileList.Comparators.name;
|
var comparator = FileList.Comparators[sort] || FileList.Comparators.name;
|
||||||
this._sort = sort;
|
this._sort = sort;
|
||||||
this._sortDirection = (direction === 'desc')?'desc':'asc';
|
this._sortDirection = (direction === 'desc')?'desc':'asc';
|
||||||
this._sortComparator = comparator;
|
|
||||||
|
|
||||||
if (direction === 'desc') {
|
|
||||||
this._sortComparator = function(fileInfo1, fileInfo2) {
|
this._sortComparator = function(fileInfo1, fileInfo2) {
|
||||||
return -comparator(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);
|
||||||
|
};
|
||||||
|
|
||||||
this.$el.find('thead th .sort-indicator')
|
this.$el.find('thead th .sort-indicator')
|
||||||
.removeClass(this.SORT_INDICATOR_ASC_CLASS)
|
.removeClass(this.SORT_INDICATOR_ASC_CLASS)
|
||||||
.removeClass(this.SORT_INDICATOR_DESC_CLASS)
|
.removeClass(this.SORT_INDICATOR_DESC_CLASS)
|
||||||
|
|
|
@ -287,6 +287,13 @@
|
||||||
data.hasPreview = true;
|
data.hasPreview = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isFavorite = props['{' + Client.NS_OWNCLOUD + '}favorite'];
|
||||||
|
if (!_.isUndefined(isFavorite)) {
|
||||||
|
data.isFavorite = isFavorite === '1';
|
||||||
|
} else {
|
||||||
|
data.isFavorite = false;
|
||||||
|
}
|
||||||
|
|
||||||
var contentType = props['{' + Client.NS_DAV + '}getcontenttype'];
|
var contentType = props['{' + Client.NS_DAV + '}getcontenttype'];
|
||||||
if (!_.isUndefined(contentType)) {
|
if (!_.isUndefined(contentType)) {
|
||||||
data.mimetype = contentType;
|
data.mimetype = contentType;
|
||||||
|
|
|
@ -132,7 +132,12 @@
|
||||||
/**
|
/**
|
||||||
* @type boolean
|
* @type boolean
|
||||||
*/
|
*/
|
||||||
hasPreview: true
|
hasPreview: true,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type boolean
|
||||||
|
*/
|
||||||
|
isFavorite: false
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!OC.Files) {
|
if (!OC.Files) {
|
||||||
|
|
Loading…
Reference in New Issue