diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-15 14:06:21 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-15 14:06:21 +0200 |
commit | 63a385d2b84467552cbc197b2548d7d03f0ba6e6 (patch) | |
tree | 2f7dd9007a0f1340978caa5764a26db43eb77dab /apps/files/js | |
parent | 66058fd2ae36e56be9109dc858c69c96fa4ec5d5 (diff) | |
parent | 576f7244e6b3b4d5568bebbe17966eb6490210f2 (diff) | |
download | nextcloud-server-63a385d2b84467552cbc197b2548d7d03f0ba6e6.tar.gz nextcloud-server-63a385d2b84467552cbc197b2548d7d03f0ba6e6.zip |
Merge pull request #23933 from owncloud/remember-file-sorting
remember file sort order
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/app.js | 6 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 22 |
2 files changed, 22 insertions, 6 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js index ff505d417f1..4ed805d2681 100644 --- a/apps/files/js/app.js +++ b/apps/files/js/app.js @@ -72,7 +72,11 @@ fileActions: fileActions, allowLegacyActions: true, scrollTo: urlParams.scrollto, - filesClient: OC.Files.getClient() + filesClient: OC.Files.getClient(), + sorting: { + mode: $('#defaultFileSorting').val(), + direction: $('#defaultFileSortingDirection').val() + } } ); this.files.initialize(); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c8f818701a9..7de64f8ade3 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -239,7 +239,11 @@ this.fileSummary = this._createSummary(); - this.setSort('name', 'asc'); + if (options.sorting) { + this.setSort(options.sorting.mode, options.sorting.direction, false, false); + } else { + this.setSort('name', 'asc', false, false); + } var breadcrumbOptions = { onClick: _.bind(this._onClickBreadCrumb, this), @@ -695,14 +699,14 @@ sort = $target.attr('data-sort'); if (sort) { if (this._sort === sort) { - this.setSort(sort, (this._sortDirection === 'desc')?'asc':'desc', true); + this.setSort(sort, (this._sortDirection === 'desc')?'asc':'desc', true, true); } else { if ( sort === 'name' ) { //default sorting of name is opposite to size and mtime - this.setSort(sort, 'asc', true); + this.setSort(sort, 'asc', true, true); } else { - this.setSort(sort, 'desc', true); + this.setSort(sort, 'desc', true, true); } } } @@ -1370,8 +1374,9 @@ * @param sort sort attribute name * @param direction sort direction, one of "asc" or "desc" * @param update true to update the list, false otherwise (default) + * @param persist true to save changes in the database (default) */ - setSort: function(sort, direction, update) { + setSort: function(sort, direction, update, persist) { var comparator = FileList.Comparators[sort] || FileList.Comparators.name; this._sort = sort; this._sortDirection = (direction === 'desc')?'desc':'asc'; @@ -1402,6 +1407,13 @@ this.reload(); } } + + if (persist) { + $.post(OC.generateUrl('/apps/files/api/v1/sorting'), { + mode: sort, + direction: direction + }); + } }, /** |