Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Feature/fix typeahead sort #178

Merged
merged 2 commits into from
May 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions openfecwebapp/tests/selenium/base_test_class.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import logging
import unittest

import pytest
Expand All @@ -10,6 +11,10 @@

from openfecwebapp.sauce import SauceClient

# Silence Selenium logs
remote_logger = logging.getLogger('selenium.webdriver.remote.remote_connection')
remote_logger.setLevel(logging.WARN)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A++++++++++

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Does this mean we'll just see warnings and failures?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this logger, we'll only see messaged logged at WARN, ERROR, or CRITICAL. All other loggers are unaffected.



sauce_url = 'http://{0}:{1}@ondemand.saucelabs.com:80/wd/hub'.format(
os.getenv('SAUCE_USERNAME'),
Expand Down
61 changes: 29 additions & 32 deletions static/js/modules/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* global require, module, window, Bloodhound, API_LOCATION, API_VERSION, API_KEY */

var $ = require('jquery');
var _ = require('underscore');
require('typeahead.js');
var URI = require('URIjs');
var Handlebars = require('handlebars');
Expand All @@ -11,35 +12,27 @@ var events = require('./events.js');
var terms = require('./terms');
var glossary = require('./glossary.js');

var filterCandidates = function(result) {

var officeFull,
officeMap,
filteredResults;

officeMap = {
"H": "House of Representatives",
"S": "Senate",
"P": "President"
}

officeFull = officeMap[result.office_sought];
var officeMap = {
H: 'House of Representatives',
S: 'Senate',
P: 'President'
};

filteredResults = {
var filterCandidates = function(result) {
return {
name: result.name,
id: result.candidate_id,
office: officeFull
}
return filteredResults;
}
office: officeMap[result.office_sought]
};
};

var filterCommittees = function(result) {
var filteredResults = {
return {
name: result.name,
id: result.committee_id
}
return filteredResults;
}
};
};

module.exports = {
init: function(){
Expand Down Expand Up @@ -68,12 +61,14 @@ module.exports = {
remote: {
url: url,
filter: function(response) {
var results = $.map(response.results, function(result){
if ( result.candidate_id !== null ) {
return _.chain(response.results)
.filter(function(result) {
return result.candidate_id;
})
.map(function(result) {
return filterCandidates(result);
}
});
return results;
})
.value();
}
},
datumTokenizer: function(d) {
Expand All @@ -91,12 +86,14 @@ module.exports = {
remote: {
url: url,
filter: function(response) {
var results = $.map(response.results, function(result) {
if ( result.committee_id !== null ) {
return _.chain(response.results)
.filter(function(result) {
return result.committee_id;
})
.map(function(result) {
return filterCommittees(result);
}
});
return results;
})
.value();
}
},
datumTokenizer: function(d) {
Expand All @@ -117,7 +114,7 @@ module.exports = {
committeeSuggestion = Handlebars.compile('<span>{{ name }}</span>');
headerTpl = function(label) {
return Handlebars.compile('<span class="tt-dropdown-title">' + label + '</span>');
}
};

// Setting up main search typehead
$('.search-bar').typeahead({
Expand Down