diff --git a/src/discovery.config.js b/src/discovery.config.js index 7b451f173..b7ad018d7 100644 --- a/src/discovery.config.js +++ b/src/discovery.config.js @@ -134,7 +134,7 @@ require.config({ ShowAssociated: 'es6!js/widgets/associated/widget.jsx', ShowRecommender: 'js/widgets/recommender/widget', ShowMetrics: 'js/wraps/paper_metrics', - ShowPaperExport: 'js/wraps/paper_export', + ShowPaperexport: 'js/wraps/paper_export', ShowLibraryAdd: 'js/wraps/abstract_page_library_add/widget', IndividualLibraryWidget: 'js/widgets/library_individual/widget', diff --git a/src/js/apps/discovery/navigator.js b/src/js/apps/discovery/navigator.js index f8469e24a..6c09ccd83 100644 --- a/src/js/apps/discovery/navigator.js +++ b/src/js/apps/discovery/navigator.js @@ -91,6 +91,7 @@ function ( return app.getWidget('LandingPage').then(function (widget) { widget.setActive('SearchWidget'); that.route = ''; + that.title = ''; defer.resolve(); }); } @@ -103,22 +104,25 @@ function ( // another function that sets a route var that = this; var defer = $.Deferred(); - self.get('index-page').execute().then(function() { + var exec = _.bind(self.get('index-page').execute, this); + exec().then(function() { that.route = ''; + that.title = ''; defer.resolve(); - }) + }); return defer.promise(); }); this.set('404', function () { var defer = $.Deferred(); + var that = this; app.getObject('MasterPageManager').show('ErrorPage').then(function() { + that.route = '404'; defer.resolve(); }); return defer.promise(); }); - this.set('ClassicSearchForm', function () { var defer = $.Deferred(); var that = this; @@ -127,7 +131,7 @@ function ( that.route = '#classic-form'; that.title = 'Classic Form'; defer.resolve(); - }) + }); return defer.promise(); }); @@ -146,6 +150,7 @@ function ( this.set('LibraryImport', function (page, data) { var that = this; var defer = $.Deferred(); + var that = this; if (redirectIfNotSignedIn()) { defer.resolve(); return defer.promise(); @@ -166,7 +171,6 @@ function ( return defer.promise(); }); - function settingsPreferencesView(widgetName, defaultView, title) { return function (page, data) { var defer = $.Deferred(); @@ -223,71 +227,65 @@ function ( publishPageChange('libraries-page'); }); defer.resolve(); - }) + }); return defer.promise(); }); this.set('LibraryAdminView', function (widget) { var defer = $.Deferred(); + var that = this; // this is NOT navigable from outside, so library already has data // only setting a nav event to hide previous widgets - app.getWidget('IndividualLibraryWidget').done(function (widget) { - widget.setSubView({ subView: 'admin' }); - app.getObject('MasterPageManager').show('LibrariesPage', - ['IndividualLibraryWidget', 'UserNavbarWidget']).then(function() { - publishPageChange('libraries-page'); - defer.resolve(); - }) + app.getObject('MasterPageManager').show('LibrariesPage', + ['IndividualLibraryWidget', 'UserNavbarWidget']).then(function() { + app.getWidget('IndividualLibraryWidget').done(function (widget) { + widget.setSubView({ subView: 'admin' }); + }); + publishPageChange('libraries-page'); + defer.resolve(); }); + return defer.promise(); }); this.set('IndividualLibraryWidget', function (widget, data) { var defer = $.Deferred(); + var that = this; + + if (redirectIfNotSignedIn()) { + return defer.resolve().promise(); + } // where view is an object in the form // {subView: subView, id: id, publicView : false} data.publicView = data.publicView ? data.publicView : false; - - var that = this; this.route = data.publicView ? '#/public-libraries/' + data.id : '#user/libraries/' + data.id; - app.getObject('LibraryController').getLibraryMetadata(data.id).done(function (metadata) { - data.editRecords = _.contains(['write', 'admin', 'owner'], metadata.permission) && !data.publicView; - that.title = data.publicView ? 'Public' : 'Private' + ' Library | ' + metadata.name; - // inform library list widget about the data - app.getWidget('LibraryListWidget').done(function (widget) { - widget.setData(data); - - if (data.publicView) { - app.getWidget('IndividualLibraryWidget').done(function (widget) { - widget.setSubView(data); - // then, show library page manager - app.getObject('MasterPageManager').show('PublicLibrariesPage', - ['IndividualLibraryWidget', 'LibraryListWidget']).then(function() { - defer.resolve(); - }); - }); - } - // make sure user is signed in - else if (!redirectIfNotSignedIn()) { - app.getWidget('IndividualLibraryWidget').done(function (widget) { - widget.setSubView(data); - app.getObject('MasterPageManager').show('LibrariesPage', - ['IndividualLibraryWidget', 'LibraryListWidget', 'UserNavbarWidget']).then(function() { - publishPageChange('libraries-page'); - defer.resolve(); - }); - }); - } - else { + var pub = data.publicView; + + app.getObject('MasterPageManager').show( + pub ? 'PublicLibrariesPage' : 'LibrariesPage', + pub ? + ['IndividualLibraryWidget', 'LibraryListWidget'] + : ['IndividualLibraryWidget', 'LibraryListWidget', 'UserNavbarWidget'] + ).then(function () { + + app.getObject('LibraryController').getLibraryMetadata(data.id).done(function (metadata) { + data.editRecords = _.contains(['write', 'admin', 'owner'], metadata.permission) && !data.publicView; + that.title = data.publicView ? 'Public' : 'Private' + ' Library | ' + metadata.name; + + app.getWidget('LibraryListWidget', 'IndividualLibraryWidget').then(function (w) { + w['LibraryListWidget'].setData(data); + w['IndividualLibraryWidget'].setSubView(data); + if (pub) publishPageChange('libraries-page'); + defer.resolve(); - } + }); }); }); - return defer.promise(); + return defer.promise(); }); // for external widgets shown by library @@ -379,9 +377,12 @@ function ( this.set('home-page', function () { var defer = $.Deferred(); + var that = this; app.getObject('MasterPageManager').show('HomePage', []).then(function() { publishPageChange('home-page'); + that.title = ''; + that.route = ''; defer.resolve(); }) return defer.promise(); @@ -847,7 +848,7 @@ function ( var q = app.getObject('AppStorage').getCurrentQuery(); if (!q && options.q) { q = options.q; - } else { + } else if (!q && !options.q) { return defer.resolve().promise(); } publishFeedback({ code: ApiFeedback.CODES.MAKE_SPACE }); @@ -979,18 +980,12 @@ function ( that.title = doc.title && doc.title[0]; } - // we can grab the current title from storage and just add our prefix from there - var title = that.title || app.getObject('AppStorage').getDocumentTitle(); - var prefix = 'Abstract'; - if (title && title.indexOf(prefix) === -1) { - that.title = prefix + ' | ' + title; - } - that.route = data.href; defer.resolve(); }); return defer.promise(); }); + this.set('ShowCitations', function (id, data) { var defer = $.Deferred(), that = this; @@ -1012,6 +1007,7 @@ function ( }); return defer.promise(); }); + this.set('ShowReferences', function (id, data) { var defer = $.Deferred(), that = this; @@ -1032,6 +1028,7 @@ function ( }); return defer.promise(); }); + this.set('ShowCoreads', function (id, data) { var defer = $.Deferred(), that = this; @@ -1052,6 +1049,7 @@ function ( }); return defer.promise(); }); + this.set('ShowSimilar', function (id, data) { var defer = $.Deferred(), that = this; @@ -1072,6 +1070,7 @@ function ( }); return defer.promise(); }); + this.set('ShowTableofcontents', function (id, data) { var defer = $.Deferred(), that = this; @@ -1092,6 +1091,7 @@ function ( }); return defer.promise(); }); + this.set('ShowMetrics', function (id, data) { var defer = $.Deferred(), that = this; @@ -1112,26 +1112,30 @@ function ( }) return defer.promise(); }); - this.set('ShowPaperExport', function (id, data) { + + this.set('ShowPaperexport', function (id, data) { var defer = $.Deferred(), that = this; - showDetail([id].concat(detailsPageAlwaysVisible), id).then(function (w) { - if (data.bibcode) { - self.getPubSub().publish(self.getPubSub().DISPLAY_DOCUMENTS, new ApiQuery({ q: 'bibcode:' + data.bibcode })); - } - w.setActive(id); - // we can grab the current title from storage and just add our prefix from there - var title = app.getObject('AppStorage').getDocumentTitle(); - var prefix = 'Export Citation'; - if (title && title.indexOf(prefix) === -1) { - that.title = prefix + ' | ' + title; - } - that.route = data.href; - defer.resolve(); - }); + // the default subView should be `default` + var format = data.subView || 'default'; + app.getObject('MasterPageManager').show('DetailsPage', + [id].concat(detailsPageAlwaysVisible)).done(function() { + app.getWidget('DetailsPage').done(function (w) { + if (data.bibcode) { + self.getPubSub().publish(self.getPubSub().DISPLAY_DOCUMENTS, new ApiQuery({ q: 'bibcode:' + data.bibcode })); + + // guarantees the bibcode is set on the widget + w.widgets[id].ingestBroadcastedPayload(_.pick(data, 'bibcode')); + w.setActive(id, format); + } + that.route = data.href; + defer.resolve(); + }); + }); return defer.promise(); }); + this.set('ShowGraphics', function (id, data) { var defer = $.Deferred(), that = this; @@ -1145,6 +1149,7 @@ function ( }); return defer.promise(); }); + this.set('show-author-affiliation-tool', function (id, options) { var defer = $.Deferred(), that = this; @@ -1163,7 +1168,7 @@ function ( that.route = '#search/' + queryUpdater.clean(q).url(); defer.resolve(); }); - }) + }); return defer.promise(); }); } diff --git a/src/js/components/navigator.js b/src/js/components/navigator.js index 8d0360aac..d8a253d61 100644 --- a/src/js/components/navigator.js +++ b/src/js/components/navigator.js @@ -124,7 +124,7 @@ function ( if (_.isUndefined(title) || title === false) return; var currTitle = this.storage.getDocumentTitle(); var setDocTitle = _.bind(function (t) { - document.title = t + TITLE_SEP + APP_TITLE; + document.title = t === '' ? APP_TITLE : t + TITLE_SEP + APP_TITLE; this.storage.setDocumentTitle(t); }, this); diff --git a/src/js/widgets/library_individual/views/library_header.js b/src/js/widgets/library_individual/views/library_header.js index 142f211ed..9e07fe177 100644 --- a/src/js/widgets/library_individual/views/library_header.js +++ b/src/js/widgets/library_individual/views/library_header.js @@ -80,7 +80,7 @@ define([ var data = this.model.toJSON(); data.date_last_modified = this.formatDate(data.date_last_modified); data.date_created = this.formatDate(data.date_created); - if (this.model.get('num_documents') >= 2000) { + if (this.model.get('num_documents') >= 200) { // careful, must be lower than server GET limits (incl all other headers that we are sending) // show a warning when user exports library that it might take a while data.largeLibrary = true; } diff --git a/src/js/widgets/library_list/widget.js b/src/js/widgets/library_list/widget.js index 27b801d72..85dedd1e5 100644 --- a/src/js/widgets/library_list/widget.js +++ b/src/js/widgets/library_list/widget.js @@ -175,6 +175,7 @@ define([ 'libraryID': data.id, 'editRecords': data.editRecords }); + this.dispatchRequest(); }, initialize: function (options) { @@ -228,7 +229,7 @@ define([ }, onShow: function () { - this.dispatchRequest(); + }, composeRequest: function (apiQuery) { diff --git a/src/js/wraps/abstract_page_manager/abstract-page-layout.html b/src/js/wraps/abstract_page_manager/abstract-page-layout.html index 65f325cd6..9cfedcfe3 100644 --- a/src/js/wraps/abstract_page_manager/abstract-page-layout.html +++ b/src/js/wraps/abstract_page_manager/abstract-page-layout.html @@ -28,7 +28,7 @@
-
+
diff --git a/src/js/wraps/abstract_page_manager/abstract_page_manager.js b/src/js/wraps/abstract_page_manager/abstract_page_manager.js index 457be971a..cde30194b 100644 --- a/src/js/wraps/abstract_page_manager/abstract_page_manager.js +++ b/src/js/wraps/abstract_page_manager/abstract_page_manager.js @@ -122,9 +122,9 @@ define([ category: 'view', order: 7 }, - ShowPaperExport__default: { + ShowPaperexport__default: { title: 'Export', - path: 'export', + path: 'paperexport', category: 'export', alwaysThere: 'true', order: 8 diff --git a/test/mocha/js/page_managers/toc_manager_test.spec.js b/test/mocha/js/page_managers/toc_manager_test.spec.js index 9788e0948..0972ce714 100644 --- a/test/mocha/js/page_managers/toc_manager_test.spec.js +++ b/test/mocha/js/page_managers/toc_manager_test.spec.js @@ -49,7 +49,7 @@ define([ TOCWidget: 'js/page_managers/toc_widget', ShowAbstract: 'js/widgets/abstract/widget', ShowReferences: 'js/wraps/references', - ShowPaperExport: 'js/wraps/paper_export', + ShowPaperexport: 'js/wraps/paper_export', PageManager: 'js/page_managers/controller' } @@ -217,7 +217,7 @@ define([ bibcode: 'foo' }); - expect(pageManager.widgets.tocWidget.collection.get("ShowPaperExport__default").get("category")).to.eql("export"); + expect(pageManager.widgets.tocWidget.collection.get("ShowPaperexport__default").get("category")).to.eql("export"); var spy = sinon.spy(); var pubsub = app.getService('PubSub').getHardenedInstance(); @@ -226,19 +226,19 @@ define([ pageManager.widgets.tocWidget.resetActiveStates(); - view.$("a[data-widget-id=ShowPaperExport__default]").click(); + view.$("a[data-widget-id=ShowPaperexport__default]").click(); - expect(spy.args[1][0]).to.eql("ShowPaperExport"); - expect(spy.args[1][1]["idAttribute"]).to.eql("ShowPaperExport"); - expect(spy.args[1][1]["href"]).to.eql("abs/foo/export"); + expect(spy.args[1][0]).to.eql("ShowPaperexport"); + expect(spy.args[1][1]["idAttribute"]).to.eql("ShowPaperexport"); + expect(spy.args[1][1]["href"]).to.eql("abs/foo/paperexport"); - pageManager.widgets.ShowPaperExport.setSubView = sinon.spy(); + pageManager.widgets.ShowPaperexport.setSubView = sinon.spy(); //should both set the toc nav collection properly, and tell the export widget which view to show - pageManager.setActive("ShowPaperExport", "default"); + pageManager.setActive("ShowPaperexport", "default"); - expect(pageManager.widgets.ShowPaperExport.setSubView.calledWith("default")).to.eql(true); - expect(pageManager.widgets.tocWidget.collection.get("ShowPaperExport__default").get("isSelected")).to.eql(true); + expect(pageManager.widgets.ShowPaperexport.setSubView.calledWith("default")).to.eql(true); + expect(pageManager.widgets.tocWidget.collection.get("ShowPaperexport__default").get("isSelected")).to.eql(true); done(); })