diff options
author | Joas Schilling <coding@schilljs.com> | 2016-10-27 12:26:02 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2016-11-07 14:56:31 +0100 |
commit | dc5c7d2b0420dadbee31d2f2f42bdeb46d92f6a1 (patch) | |
tree | 98cefe997f56df7665067e96c3d483cebec23133 /core/js | |
parent | 1857e50259e3cedffd9d9c24ce2a47bf08ebf782 (diff) | |
download | nextcloud-server-dc5c7d2b0420dadbee31d2f2f42bdeb46d92f6a1.tar.gz nextcloud-server-dc5c7d2b0420dadbee31d2f2f42bdeb46d92f6a1.zip |
First list tags the user used lately
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/systemtags/systemtagsinputfield.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/core/js/systemtags/systemtagsinputfield.js b/core/js/systemtags/systemtagsinputfield.js index 2eb8d0a44cb..3ca76f9fa21 100644 --- a/core/js/systemtags/systemtagsinputfield.js +++ b/core/js/systemtags/systemtagsinputfield.js @@ -57,6 +57,8 @@ _newTag: null, + _lastUsedTags: [], + className: 'systemTagsInputFieldContainer', template: function(data) { @@ -97,6 +99,8 @@ _.defer(self._refreshSelection); }); + _.defer(_.bind(this._getLastUsedTags, this)); + _.bindAll( this, '_refreshSelection', @@ -108,6 +112,17 @@ ); }, + _getLastUsedTags: function() { + var self = this; + $.ajax({ + type: 'GET', + url: OC.generateUrl('/apps/systemtags/lastused'), + success: function (response) { + self._lastUsedTags = response; + } + }); + }, + /** * Refreshes the selection, triggering a call to * select2's initSelection @@ -241,6 +256,7 @@ } this._newTag = null; this.trigger('select', tag); + this._lastUsedTags.unshift(tag.id); }, /** @@ -400,6 +416,20 @@ var aSelected = selectedItems.indexOf(a.id) >= 0; var bSelected = selectedItems.indexOf(b.id) >= 0; if (aSelected === bSelected) { + var aLastUsed = self._lastUsedTags.indexOf(a.id); + var bLastUsed = self._lastUsedTags.indexOf(b.id); + + if (aLastUsed !== bLastUsed) { + if (bLastUsed === -1) { + return -1; + } + if (aLastUsed === -1) { + return 1; + } + return aLastUsed < bLastUsed ? -1 : 1; + } + + // Both not found return OC.Util.naturalSortCompare(a.name, b.name); } if (aSelected && !bSelected) { |