diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-09-28 12:30:12 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-28 12:30:12 +0200 |
commit | 5e4a52d3c259e77065dbb5f0766b0d08f2e1babb (patch) | |
tree | 56bc8507631b84c8796f4961d04b278f528f3bad /apps/files | |
parent | 9a010cc8ce281650038cd1444f63a02245eea523 (diff) | |
download | nextcloud-server-5e4a52d3c259e77065dbb5f0766b0d08f2e1babb.tar.gz nextcloud-server-5e4a52d3c259e77065dbb5f0766b0d08f2e1babb.zip |
Fix tabs order in files sidebar
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/detailsview.js | 8 | ||||
-rw-r--r-- | apps/files/js/detailtabview.js | 6 | ||||
-rw-r--r-- | apps/files/tests/js/detailsviewSpec.js | 15 |
3 files changed, 28 insertions, 1 deletions
diff --git a/apps/files/js/detailsview.js b/apps/files/js/detailsview.js index b01f9cea610..bad4be4ceef 100644 --- a/apps/files/js/detailsview.js +++ b/apps/files/js/detailsview.js @@ -132,6 +132,14 @@ closeLabel: t('files', 'Close') }; + this._tabViews = this._tabViews.sort(function(tabA, tabB) { + var orderA = tabA.order || 0; + var orderB = tabB.order || 0; + if (orderA === orderB) { + return OC.Util.naturalSortCompare(tabA.getLabel(), tabB.getLabel()); + } + return orderA - orderB; + }); if (this._tabViews.length > 1) { // only render headers if there is more than one available templateVars.tabHeaders = _.map(this._tabViews, function(tabView, i) { diff --git a/apps/files/js/detailtabview.js b/apps/files/js/detailtabview.js index 449047cf252..d885e47b15e 100644 --- a/apps/files/js/detailtabview.js +++ b/apps/files/js/detailtabview.js @@ -29,11 +29,15 @@ _template: null, - initialize: function() { + initialize: function(options) { + options = options || {}; if (!this.id) { this.id = 'detailTabView' + DetailTabView._TAB_COUNT; DetailTabView._TAB_COUNT++; } + if (options.order) { + this.order = options.order || 0; + } }, /** diff --git a/apps/files/tests/js/detailsviewSpec.js b/apps/files/tests/js/detailsviewSpec.js index 852f8b04293..f02e419434f 100644 --- a/apps/files/tests/js/detailsviewSpec.js +++ b/apps/files/tests/js/detailsviewSpec.js @@ -153,5 +153,20 @@ describe('OCA.Files.DetailsView tests', function() { expect(detailsView.$el.find('.tabHeader').length).toEqual(0); }); + it('sorts by order and then label', function() { + detailsView.remove(); + detailsView = new OCA.Files.DetailsView(); + detailsView.addTabView(new OCA.Files.DetailTabView({id: 'abc', order: 20})); + detailsView.addTabView(new OCA.Files.DetailTabView({id: 'def', order: 10})); + detailsView.addTabView(new OCA.Files.DetailTabView({id: 'jkl'})); + detailsView.addTabView(new OCA.Files.DetailTabView({id: 'ghi'})); + detailsView.render(); + + var tabs = detailsView.$el.find('.tabHeader').map(function() { + return $(this).attr('data-tabid'); + }).toArray(); + + expect(tabs).toEqual(['ghi', 'jkl', 'def', 'abc']); + }); }); }); |