Fix tabs order in files sidebar
This commit is contained in:
parent
9a010cc8ce
commit
5e4a52d3c2
|
@ -132,6 +132,14 @@
|
||||||
closeLabel: t('files', 'Close')
|
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) {
|
if (this._tabViews.length > 1) {
|
||||||
// only render headers if there is more than one available
|
// only render headers if there is more than one available
|
||||||
templateVars.tabHeaders = _.map(this._tabViews, function(tabView, i) {
|
templateVars.tabHeaders = _.map(this._tabViews, function(tabView, i) {
|
||||||
|
|
|
@ -29,11 +29,15 @@
|
||||||
|
|
||||||
_template: null,
|
_template: null,
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function(options) {
|
||||||
|
options = options || {};
|
||||||
if (!this.id) {
|
if (!this.id) {
|
||||||
this.id = 'detailTabView' + DetailTabView._TAB_COUNT;
|
this.id = 'detailTabView' + DetailTabView._TAB_COUNT;
|
||||||
DetailTabView._TAB_COUNT++;
|
DetailTabView._TAB_COUNT++;
|
||||||
}
|
}
|
||||||
|
if (options.order) {
|
||||||
|
this.order = options.order || 0;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -153,5 +153,20 @@ describe('OCA.Files.DetailsView tests', function() {
|
||||||
|
|
||||||
expect(detailsView.$el.find('.tabHeader').length).toEqual(0);
|
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']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var shareTab = new OCA.Sharing.ShareTabView('shareTabView');
|
var shareTab = new OCA.Sharing.ShareTabView('shareTabView', {order: -20});
|
||||||
// detect changes and change the matching list entry
|
// detect changes and change the matching list entry
|
||||||
shareTab.on('sharesChanged', function(shareModel) {
|
shareTab.on('sharesChanged', function(shareModel) {
|
||||||
var fileInfoModel = shareModel.fileInfoModel;
|
var fileInfoModel = shareModel.fileInfoModel;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileList.registerTabView(new OCA.Versions.VersionsTabView('versionsTabView'));
|
fileList.registerTabView(new OCA.Versions.VersionsTabView('versionsTabView', {order: -10}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
OCA.Files.DetailTabView.prototype.initialize.apply(this, arguments);
|
||||||
this.collection = new OCA.Versions.VersionCollection();
|
this.collection = new OCA.Versions.VersionCollection();
|
||||||
this.collection.on('request', this._onRequest, this);
|
this.collection.on('request', this._onRequest, this);
|
||||||
this.collection.on('sync', this._onEndRequest, this);
|
this.collection.on('sync', this._onEndRequest, this);
|
||||||
|
|
Loading…
Reference in New Issue