Skip to content

Commit

Permalink
Make Astronomy and Physics the default databases for new searches
Browse files Browse the repository at this point in the history
This only applies if:

1. User is NOT logged in, and so has not updated their preferences
2. User is logged in but has not set their default database (or is still the default of none selected).
  • Loading branch information
thostetler committed Jan 11, 2024
1 parent cb58d6f commit 8cbc24b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/js/widgets/preferences/views/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ define([
name: 'General',
value: false,
},
{
name: 'Earth Science',
value: false,
},
],
},
hideSidebars: {
Expand Down
11 changes: 9 additions & 2 deletions src/js/widgets/search_bar/search_bar_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ define([
select2,
oldMatcher
) {

/**
* The default databases to filter by if the user has not set any in their preferences
* @type {string[]}
*/
const DEFAULT_DATABASES = ['Astronomy', 'Physics'];

var SearchBarModel = Backbone.Model.extend({
defaults: function() {
return {
Expand Down Expand Up @@ -635,8 +642,8 @@ define([
: this.defaultDatabases;
},

applyDefaultFilters: function(apiQuery) {
var dbfilters = this.defaultDatabases || [];
applyDefaultFilters: function (apiQuery) {
const dbfilters = Array.isArray(this.defaultDatabases) && this.defaultDatabases.length > 0 ? this.defaultDatabases : DEFAULT_DATABASES;
if (dbfilters.length > 0) {
var fqString = '{!type=aqp v=$fq_database}';

Expand Down

0 comments on commit 8cbc24b

Please sign in to comment.