Skip to content
This repository was archived by the owner on Jan 7, 2020. It is now read-only.

Add filter-by-lei option and assorted utilities #198

Merged
merged 1 commit into from
Nov 14, 2019
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
2 changes: 2 additions & 0 deletions src/constants/leis.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/geo/CategorySelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const categories = [
{value: 'counties', label: 'County'},
{value: 'msamds', label: 'MSA/MD'},
{value: 'nationwide', label: 'Nationwide'},
{value: 'leis', label: 'Instituion by LEI'}
]

const CategorySelect = ({ category, onChange }) => {
Expand Down
10 changes: 9 additions & 1 deletion src/geo/selectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import STATEOBJ from '../constants/stateObj.js'
import MSATOSTATE from '../constants/msaToState.js'
import VARIABLES from '../constants/variables.js'
import COUNTIES from '../constants/counties.js'
import LEIS from '../constants/leis.js'
import fipsToState from '../constants/fipsToState.js'
import msaToName from '../constants/msaToName.js'

const itemFnMap = {
states: createStateOption,
msamds: createMSAOption,
counties: createCountyOption,
leis: createLEIOption
}

function makeItemSelectValues(category, items){
Expand Down Expand Up @@ -104,6 +106,10 @@ function createCountyOption(id){
}
}

function createLEIOption(id){
return {value: id, label: `${id} - ${LEIS[id]}`}
}

function createItemOptions(props) {
const subsetYear = props.location.pathname.split('/')[2]
const statesWithMsas = stateToMsas[subsetYear]
Expand All @@ -112,7 +118,8 @@ function createItemOptions(props) {
nationwide: [{value: 'nationwide', label: 'NATIONWIDE'}],
states: [],
msamds: [],
counties: []
counties: [],
leis: []
}

const msaSet = new Set()
Expand All @@ -127,6 +134,7 @@ function createItemOptions(props) {
})

itemOptions.counties = Object.keys(COUNTIES).map(createCountyOption)
itemOptions.leis = Object.keys(LEIS).map(createLEIOption)

return itemOptions
}
Expand Down
5 changes: 4 additions & 1 deletion src/query.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import MSAS from './constants/msaToName.js'
import STATES from './constants/stateObj.js'
import COUNTIES from './constants/counties.js'
import LEIS from './constants/leis.js'
import VARIABLES from './constants/variables.js'

const msaKeys = Object.keys(MSAS)
const stateKeys = Object.keys(STATES)
const countyKeys= Object.keys(COUNTIES)
const countyKeys = Object.keys(COUNTIES)
const leiKeys = Object.keys(LEIS)
const varKeys = Object.keys(VARIABLES)

export function makeParam(s, key) {
Expand Down Expand Up @@ -51,6 +53,7 @@ export function sanitizeArray(key, val) {
if(key === 'msamds') knownKeys = msaKeys
else if(key === 'states') knownKeys = stateKeys
else if(key === 'counties') knownKeys = countyKeys
else if(key === 'leis') knownKeys = leiKeys
else knownKeys = Object.keys(VARIABLES[key].mapping)

val.forEach(v => {
Expand Down