Skip to content

Commit

Permalink
Merge pull request ngageoint#569 in WV/opensphere from ~ROTHM/opensph…
Browse files Browse the repository at this point in the history
…ere:THIN-12435 to master

* commit 'cc7866fd35d5d2bf82fd8962812ee539e3f19364':
  feat(search): attribute to track search providers that will send search terms to an external site
  • Loading branch information
rothmike committed Dec 10, 2018
2 parents f66f771 + cc7866f commit ccc4605
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
23 changes: 23 additions & 0 deletions src/os/search/abstractsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ os.search.AbstractSearch = function(id, name, opt_type, opt_priority, opt_defaul
*/
this.term = null;

/**
* Is the search provider external?
* @type {boolean}
* @private
*/
this.isExternal_ = false;

/**
* The logger used by the search provider.
* @type {goog.log.Logger}
Expand Down Expand Up @@ -186,6 +193,22 @@ os.search.AbstractSearch.prototype.autocomplete = goog.abstractMethod;
os.search.AbstractSearch.prototype.searchTerm = goog.abstractMethod;


/**
* @inheritDoc
*/
os.search.AbstractSearch.prototype.isExternal = function() {
return this.isExternal_;
};


/**
* @inheritDoc
*/
os.search.AbstractSearch.prototype.setExternal = function(external) {
this.isExternal_ = external;
};


/**
* DEPRECATED
* @param {string} term
Expand Down
2 changes: 2 additions & 0 deletions src/os/search/abstractsearchmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ goog.provide('os.search.AbstractSearchManager');

goog.require('goog.events.Event');
goog.require('goog.events.EventTarget');
goog.require('os.user.settings.FavoriteManager');



Expand Down Expand Up @@ -242,6 +243,7 @@ os.search.AbstractSearchManager.prototype.getTotal = goog.abstractMethod;

/**
* Retrieve the identifying names of all the registered searches.
* @param {boolean=} opt_excludeExternal
* @return {!Array<!os.search.ISearch>}
*/
os.search.AbstractSearchManager.prototype.getRegisteredSearches = goog.abstractMethod;
Expand Down
14 changes: 14 additions & 0 deletions src/os/search/isearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,17 @@ os.search.ISearch.prototype.supportsSearchTerm;
* @return {boolean}
*/
os.search.ISearch.prototype.shouldNormalize;


/**
* Whether the search is sent to external search providers.
* @return {boolean} [description]
*/
os.search.ISearch.prototype.isExternal;


/**
* Set if the search is external
* @param {boolean} external
*/
os.search.ISearch.prototype.setExternal;
17 changes: 6 additions & 11 deletions src/os/search/searchmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ os.search.ProviderResults;
* Responsible for executing search terms against the registered searches
* @extends {os.search.AbstractSearchManager}
* @param {string=} opt_id
* @param {boolean=} opt_isFederated
* @constructor
*/
os.search.SearchManager = function(opt_id, opt_isFederated) {
os.search.SearchManager = function(opt_id) {
os.search.SearchManager.base(this, 'constructor', opt_id);

/**
Expand Down Expand Up @@ -76,12 +75,6 @@ os.search.SearchManager = function(opt_id, opt_isFederated) {
* @private
*/
this.total_ = 0;

/**
* @type {boolean}
* @private
*/
this.isFederated_ = !!opt_isFederated;
};
goog.inherits(os.search.SearchManager, os.search.AbstractSearchManager);
goog.addSingletonGetter(os.search.SearchManager);
Expand Down Expand Up @@ -145,8 +138,10 @@ os.search.SearchManager.prototype.registerSearch = function(search) {
/**
* @inheritDoc
*/
os.search.SearchManager.prototype.getRegisteredSearches = function() {
return goog.object.getValues(this.registeredSearches_);
os.search.SearchManager.prototype.getRegisteredSearches = function(opt_excludeExternal) {
return goog.object.getValues(this.registeredSearches_).filter(function(search) {
return (!opt_excludeExternal || !search.isExternal());
});
};


Expand Down Expand Up @@ -421,7 +416,7 @@ os.search.SearchManager.prototype.getTotal = function() {
* @export
*/
os.search.SearchManager.prototype.isFederated = function() {
return this.isFederated_;
return !this.getRegisteredSearches(true).length;
};


Expand Down

0 comments on commit ccc4605

Please sign in to comment.