From 457193657f6d0073261ccce0c475d2fa6925afba Mon Sep 17 00:00:00 2001 From: shale <sarah.hale@nasa.gov> Date: Tue, 14 Jul 2015 09:59:48 -0700 Subject: [PATCH] [Search] Added input ID parameter Added a parameter to the controller's search function so that the html side can clearly see/choose which input ID is being used as the search input. --- .../features/search/res/templates/search.html | 2 +- .../features/search/src/SearchController.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/platform/features/search/res/templates/search.html b/platform/features/search/res/templates/search.html index dd780aa3a2..19f6dd6bfa 100644 --- a/platform/features/search/res/templates/search.html +++ b/platform/features/search/res/templates/search.html @@ -31,7 +31,7 @@ value=""/> <span class="button"> <button type="button" - ng-click="controller.search()">Go</button> + ng-click="controller.search('searchinput')">Go</button> </span> </div> diff --git a/platform/features/search/src/SearchController.js b/platform/features/search/src/SearchController.js index 1446a40b61..6133ed87b8 100644 --- a/platform/features/search/src/SearchController.js +++ b/platform/features/search/src/SearchController.js @@ -77,8 +77,17 @@ define(function () { } // Use elasticsearch's search to search through all the objects - function searchElastic() { - var searchTerm = document.getElementById("searchinput").value; + function searchElastic(inputID) { + var searchTerm; + + // Get the user input + if (inputID) { + searchTerm = document.getElementById(inputID).value; + } else { + // Backward compatibility? + // TODO: May be unnecsisary + searchTerm = document.getElementById("searchinput").value; + } // Get the data... return $http({ @@ -131,8 +140,8 @@ define(function () { return { // Search the database using the user input of id "searchinput" - search: function () { - searchElastic().then( function (c) { + search: function (inputID) { + searchElastic(inputID).then( function (c) { $scope.results = c; }); },