addDetailView: function(detailView) {
this._detailFileInfoViews.push(detailView);
this._dirty = true;
+ },
+
+ /**
+ * Returns an array with the added DetailFileInfoViews.
+ *
+ * @return Array<OCA.Files.DetailFileInfoView> an array with the added
+ * DetailFileInfoViews.
+ */
+ getDetailViews: function() {
+ return [].concat(this._detailFileInfoViews);
}
});
if (this.breadcrumb) {
this.breadcrumb.addDetailView(detailView);
}
+ },
+
+ /**
+ * Returns the registered detail views.
+ *
+ * @return null|Array<OCA.Files.DetailFileInfoView> an array with the
+ * registered DetailFileInfoViews, or null if the details view
+ * is not enabled.
+ */
+ getRegisteredDetailViews: function() {
+ if (this._detailsView) {
+ return this._detailsView.getDetailViews();
+ }
+
+ return null;
}
};
expect(detailsView.$el.find('.tabsContainer').length).toEqual(1);
});
describe('file info detail view', function() {
+ it('returns registered view', function() {
+ var testView = new OCA.Files.DetailFileInfoView();
+ var testView2 = new OCA.Files.DetailFileInfoView();
+ detailsView.addDetailView(testView);
+ detailsView.addDetailView(testView2);
+
+ detailViews = detailsView.getDetailViews();
+
+ expect(detailViews).toContain(testView);
+ expect(detailViews).toContain(testView2);
+
+ // Modify array and check that registered detail views are not
+ // modified
+ detailViews.pop();
+ detailViews.pop();
+
+ detailViews = detailsView.getDetailViews();
+
+ expect(detailViews).toContain(testView);
+ expect(detailViews).toContain(testView2);
+ });
it('renders registered view', function() {
var testView = new OCA.Files.DetailFileInfoView();
var testView2 = new OCA.Files.DetailFileInfoView();
beforeEach(function() {
addTabStub = sinon.stub(OCA.Files.DetailsView.prototype, 'addTabView');
addDetailStub = sinon.stub(OCA.Files.DetailsView.prototype, 'addDetailView');
+ getDetailsStub = sinon.stub(OCA.Files.DetailsView.prototype, 'getDetailViews');
});
afterEach(function() {
addTabStub.restore();
addDetailStub.restore();
+ getDetailsStub.restore();
});
it('forward the registered views to the underlying DetailsView', function() {
fileList.destroy();
// twice because the filelist already registers one by default
expect(addDetailStub.calledTwice).toEqual(true);
});
+ it('forward getting the registered views to the underlying DetailsView', function() {
+ fileList.destroy();
+ fileList = new OCA.Files.FileList($('#app-content-files'), {
+ detailsViewEnabled: true
+ });
+ var expectedRegisteredDetailsView = [];
+ getDetailsStub.returns(expectedRegisteredDetailsView);
+
+ var registeredDetailViews = fileList.getRegisteredDetailViews();
+
+ expect(getDetailsStub.calledOnce).toEqual(true);
+ expect(registeredDetailViews).toEqual(expectedRegisteredDetailsView);
+ });
it('does not error when registering panels when not details view configured', function() {
fileList.destroy();
fileList = new OCA.Files.FileList($('#app-content-files'), {
expect(addTabStub.notCalled).toEqual(true);
expect(addDetailStub.notCalled).toEqual(true);
});
+ it('returns null when getting the registered views when not details view configured', function() {
+ fileList.destroy();
+ fileList = new OCA.Files.FileList($('#app-content-files'), {
+ detailsViewEnabled: false
+ });
+
+ var registeredDetailViews = fileList.getRegisteredDetailViews();
+
+ expect(getDetailsStub.notCalled).toEqual(true);
+ expect(registeredDetailViews).toBeNull();
+ });
});
it('triggers file action when clicking on row if no details view configured', function() {
fileList.destroy();