diff --git a/src/js/components/app_storage.js b/src/js/components/app_storage.js
index a76209789..14aba9f49 100644
--- a/src/js/components/app_storage.js
+++ b/src/js/components/app_storage.js
@@ -21,10 +21,12 @@ define([
activate: function(beehive) {
this.setBeeHive(beehive);
- _.bindAll(this, "onPaperSelection");
+ _.bindAll(this, "onPaperSelection", "onBulkPaperSelection");
var pubsub = beehive.getService('PubSub');
this.key = pubsub.getPubSubKey();
pubsub.subscribe(this.key, pubsub.PAPER_SELECTION, this.onPaperSelection);
+ pubsub.subscribe(this.key, pubsub.BULK_PAPER_SELECTION, this.onBulkPaperSelection);
+
this.pubsub = pubsub;
},
@@ -144,6 +146,10 @@ define([
}
},
+ onBulkPaperSelection : function(bibs){
+ this.addSelectedPapers(bibs);
+ },
+
//this is used by the auth and user settings widgets
setConfig : function(conf){
this.set("dynamicConfig", conf);
diff --git a/src/js/components/pubsub_events.js b/src/js/components/pubsub_events.js
index 6fdcc179f..4cec94c27 100644
--- a/src/js/components/pubsub_events.js
+++ b/src/js/components/pubsub_events.js
@@ -152,6 +152,9 @@ define([], function() {
* Is triggered when user selects/deselects records
*/
PAPER_SELECTION: "[User]-Paper-Selection",
+
+ //instead of toggling, adds all papers
+ BULK_PAPER_SELECTION: "[User]-Bulk-Paper-Selection",
/*
* is triggered by app storage itself when list of selected papers changes
* */
diff --git a/src/js/widgets/list_of_things/widget.js b/src/js/widgets/list_of_things/widget.js
index 5264be7a3..06676e56a 100644
--- a/src/js/widgets/list_of_things/widget.js
+++ b/src/js/widgets/list_of_things/widget.js
@@ -146,7 +146,6 @@ define([
getPaginationInfo: function(apiResponse, docs) {
var q = apiResponse.getApiQuery();
-
// this information is important for calcullation of pages
var numFound = apiResponse.get("response.numFound");
var perPage = this.model.get('perPage') || (q.has("rows") ? q.get('rows')[0] : 10);
diff --git a/src/js/widgets/query_info/query_info_template.html b/src/js/widgets/query_info/query_info_template.html
index d539dc1ab..5aa85101d 100644
--- a/src/js/widgets/query_info/query_info_template.html
+++ b/src/js/widgets/query_info/query_info_template.html
@@ -1,12 +1,14 @@
-
{{numFound}} search results
+
{{numFound}} search results
{{selected}} currently selected
{{#compare selected 0 operator=">"}}
-
+
{{/compare}}
+
+
{{#if fq}}
Active Filters:
diff --git a/src/js/widgets/query_info/query_info_widget.js b/src/js/widgets/query_info/query_info_widget.js
index c34a3ebd2..085174ee3 100644
--- a/src/js/widgets/query_info/query_info_widget.js
+++ b/src/js/widgets/query_info/query_info_widget.js
@@ -51,6 +51,9 @@ define(['marionette',
},
"click .clear-selected" : function(){
this.trigger("clear-selected");
+ },
+ "click .page-bulk-add" : function(){
+ this.trigger("page-bulk-add");
}
}
})
@@ -63,6 +66,7 @@ define(['marionette',
this.model = new QueryModel();
this.view = new QueryDisplayView({model : this.model});
this.view.on("clear-selected", this.clearSelected, this);
+ this.view.on("page-bulk-add", this.triggerBulkAdd, this);
BaseWidget.prototype.initialize.call(this, options)
},
@@ -85,6 +89,10 @@ define(['marionette',
this.beehive.getObject("AppStorage").clearSelectedPapers();
},
+ triggerBulkAdd : function(){
+ this.pubsub.publish(this.pubsub.CUSTOM_EVENT, "add-all-on-page");
+ },
+
processResponse: function(apiResponse) {
var q = apiResponse.getApiQuery();
var numFound = apiResponse.get("response.numFound");
diff --git a/src/js/widgets/results/widget.js b/src/js/widgets/results/widget.js
index 240cc0900..8497d443c 100644
--- a/src/js/widgets/results/widget.js
+++ b/src/js/widgets/results/widget.js
@@ -50,11 +50,12 @@ define([
activate: function (beehive) {
this.setBeeHive(beehive);
this.pubsub = beehive.Services.get('PubSub');
- _.bindAll(this, 'dispatchRequest', 'processResponse', 'onUserAnnouncement', 'onStoragePaperUpdate');
+ _.bindAll(this, 'dispatchRequest', 'processResponse', 'onUserAnnouncement', 'onStoragePaperUpdate', 'onCustomEvent');
this.pubsub.subscribe(this.pubsub.INVITING_REQUEST, this.dispatchRequest);
this.pubsub.subscribe(this.pubsub.DELIVERING_RESPONSE, this.processResponse);
this.pubsub.subscribe(this.pubsub.USER_ANNOUNCEMENT, this.onUserAnnouncement);
- this.pubsub.subscribe(this.pubsub.STORAGE_PAPER_UPDATE, this.onStoragePaperUpdate)
+ this.pubsub.subscribe(this.pubsub.STORAGE_PAPER_UPDATE, this.onStoragePaperUpdate);
+ this.pubsub.subscribe(this.pubsub.CUSTOM_EVENT, this.onCustomEvent);
},
onUserAnnouncement: function(key, val){
@@ -70,6 +71,13 @@ define([
}
},
+ onCustomEvent : function(event){
+ if (event == "add-all-on-page"){
+ var bibs = this.collection.pluck("bibcode");
+ this.pubsub.publish(this.pubsub.BULK_PAPER_SELECTION, bibs);
+ }
+ },
+
dispatchRequest: function(apiQuery) {
this.reset();
ListOfThingsWidget.prototype.dispatchRequest.call(this, apiQuery);
diff --git a/src/styles/less/ads-less/results-page-widgets.less b/src/styles/less/ads-less/results-page-widgets.less
index cd756a96e..014895740 100644
--- a/src/styles/less/ads-less/results-page-widgets.less
+++ b/src/styles/less/ads-less/results-page-widgets.less
@@ -71,4 +71,7 @@
font-size: @font-size-base;
font-weight: 300;
}
+ .clear-selected {
+ position: absolute;
+ }
}
\ No newline at end of file
diff --git a/test/mocha/js/components/app_storage.spec.js b/test/mocha/js/components/app_storage.spec.js
index d8e0f03bd..21b778cbb 100644
--- a/test/mocha/js/components/app_storage.spec.js
+++ b/test/mocha/js/components/app_storage.spec.js
@@ -77,6 +77,10 @@ define([
s.activate(minsub.beehive);
minsub.publish(minsub.PAPER_SELECTION, 'foo');
expect(s.getSelectedPapers()).to.eql(['foo'])
+
+ //should be able to re-add foo in bulk selection and not have it toggled off
+ minsub.publish(minsub.BULK_PAPER_SELECTION, ['foo', 'boo', 'goo']);
+ expect(s.getSelectedPapers()).to.eql(['foo', 'boo', 'goo']);
});
});
diff --git a/test/mocha/js/widgets/query_info_widget.spec.js b/test/mocha/js/widgets/query_info_widget.spec.js
index dc6f307d9..f8f316a3b 100644
--- a/test/mocha/js/widgets/query_info_widget.spec.js
+++ b/test/mocha/js/widgets/query_info_widget.spec.js
@@ -74,11 +74,11 @@ define([
$("#test").append(w.render().el);
- expect($(".currently-selected").text().trim()).to.eql('0 currently selected');
+ expect($(".currently-selected").text().trim()).to.eql('0 currently selected\n \n select all on this page');
minsub.publish(minsub.STORAGE_PAPER_UPDATE, 10);
- expect($(".currently-selected").text().trim()).to.eql('10 currently selected\n \n x clear');
+ expect($(".currently-selected").text().trim()).to.eql('10 currently selected\n \n x clear all\n \n select all on this page');
expect(s.clearSelectedPapers.callCount).to.eql(0);