<commit_before>(function () {
  'use strict';

  angular
    .module('fusionSeedApp.components.searchbox')
    .directive('searchBox', searchbox);

  function searchbox(){
    'ngInject';
    return {
      restrict: 'EA',
      controller: Controller,
      templateUrl: 'assets/components/searchBox/searchBox.html',
      scope: true,
      controllerAs: 'ta',
      bindToController: {
        query: '='
      },
      require: '^form'
    };
  }

  function Controller($log, $scope, $q, ConfigService, SearchBoxDataService){
    'ngInject';
    var ta = this;
    ta.typeaheadField = ConfigService.getTypeaheadField();
    ta.doTypeaheadSearch = doTypeaheadSearch;
    ta.selectedSomething = selectedSomething;
    ta.updateSearchQuery = updateSearchQuery;

    //////////

    function selectedSomething(object){
      if(object){
        var newValue = object.originalObject[ta.typeaheadField];
        ta.query = newValue;
      }
    }

    function updateSearchQuery(inputString){
      ta.query = inputString;
    }

    function doTypeaheadSearch(userInputString, timeoutPromise) {
      var deferred = $q.defer();

      SearchBoxDataService
        .getQueryResults({
          q: userInputString,
          // make sure results are json.
          wt: 'json'
        })
        .then(function(resp){
          var objectToResolve = {
            data: resp.response.docs
          };
          deferred.resolve(objectToResolve);
        })
        .catch(function(error){
          timeoutPromise.reject(error);
        });

      return deferred.promise;
    }


  }

})();<commit_msg>Search box now respects current filters.<commit_after>(function () {
  'use strict';

  angular
    .module('fusionSeedApp.components.searchbox')
    .directive('searchBox', searchbox);

  function searchbox(){
    'ngInject';
    return {
      restrict: 'EA',
      controller: Controller,
      templateUrl: 'assets/components/searchBox/searchBox.html',
      scope: true,
      controllerAs: 'ta',
      bindToController: {
        query: '='
      },
      require: '^form'
    };
  }

  function Controller($log, $scope, $q, ConfigService, QueryService, SearchBoxDataService){
    'ngInject';
    var ta = this;
    ta.typeaheadField = ConfigService.getTypeaheadField();
    ta.doTypeaheadSearch = doTypeaheadSearch;
    ta.selectedSomething = selectedSomething;
    ta.updateSearchQuery = updateSearchQuery;

    //////////

    function selectedSomething(object){
      if(object){
        var newValue = object.originalObject[ta.typeaheadField];
        ta.query = newValue;
      }
    }

    function updateSearchQuery(inputString){
      ta.query = inputString;
    }

    function doTypeaheadSearch(userInputString, timeoutPromise) {
      var deferred = $q.defer();

      SearchBoxDataService
        .getQueryResults(QueryService.getQueryObject())
        .then(function(resp){
          var objectToResolve = {
            data: resp.response.docs
          };
          deferred.resolve(objectToResolve);
        })
        .catch(function(error){
          timeoutPromise.reject(error);
        });

      return deferred.promise;
    }


  }

})();
{'fraction_non_alphanumeric': 0.11959608709372041, 'fraction_numerical': 0.0, 'mean_word_length': 2.4122712594187297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3952240', 'n_tokens_mistral': 915, 'n_tokens_neox': 884, 'n_words': 161}