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

Commit

Permalink
Merge pull request #218 from cfpb/includes-values-hotfix
Browse files Browse the repository at this point in the history
use simpler JS for ie11
  • Loading branch information
meissadia authored Dec 12, 2019
2 parents e7baf3d + 67f27da commit 1fa54de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions src/geo/Geography.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,18 @@ class Geography extends Component {
}

checkIfLargeFile(category, items) {
const leisSelected = this.state && this.state.leis.length
const leisSelected = this.state && this.state.leis.length
const leisFetched = this.state && !this.state.leiDetails.loading

if(category === 'leis'){
if(items.length && leisFetched)
if(items.length && leisFetched)
return this.checkIfLargeCount(items, this.state.leiDetails.counts)
if(!items.length)

if(!items.length)
return this.checkIfLargeFile(this.state.category, this.state.items)
}
if(leisSelected && leisFetched)

if(leisSelected && leisFetched)
return this.checkIfLargeCount(this.state.leis, this.state.leiDetails.counts)

if(isNationwide(category)) return true
Expand Down Expand Up @@ -187,11 +187,11 @@ class Geography extends Component {

onInstitutionChange(selectedLEIs = []){
let leis = selectedLEIs.map(l => l.value)
if(leis.includes('all')) leis = []
if(leis.indexOf('all') !== -1) leis = []

return this.setState({leis, details: {}}, () => {
return this.setStateAndRoute({
isLargeFile: this.checkIfLargeFile('leis', this.state.leis)
return this.setStateAndRoute({
isLargeFile: this.checkIfLargeFile('leis', this.state.leis)
})
})
}
Expand Down Expand Up @@ -229,7 +229,7 @@ class Geography extends Component {
}

if(!newState.variables[variable][subvar.id]) delete newState.variables[variable][subvar.id]

const largeFile = this.checkIfLargeFile(this.state.category, this.state.items)

this.setStateAndRoute({
Expand Down Expand Up @@ -262,9 +262,9 @@ class Geography extends Component {
}

render() {
const { category, details, error, isLargeFile, items, leiDetails, leis,
const { category, details, error, isLargeFile, items, leiDetails, leis,
loadingDetails, orderedVariables, variables } = this.state

const nationwide = isNationwide(category)
const enabled = nationwide || items.length
const checksExist = someChecksExist(variables)
Expand Down Expand Up @@ -317,7 +317,7 @@ class Geography extends Component {
{details.aggregations && !error
? this.showAggregations(details, orderedVariables)
: null}
<ActionsWarningsErrors
<ActionsWarningsErrors
downloadEnabled={enabled}
downloadCallback={checksExist ? this.requestSubsetCSV : this.requestItemCSV}
showSummaryButton={!details.aggregations}
Expand Down
6 changes: 3 additions & 3 deletions src/geo/InstitutionSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const InstitutionSelect = ({
items,
onChange,
leiDetails
}) => {
}) => {
const category = 'leis'
const {leis, loading} = leiDetails
const selectedValues = items.map(lei => createLEIOption(lei, leis))
Expand Down Expand Up @@ -59,9 +59,9 @@ const styleFn = {

export function pruneLeiOptions(data, selected) {
const selectedLeis = selected.map(s => s.value)
const institutions = Object.values(data)
const institutions = Object.keys(data).map(v => data[v])
const opts = institutions
.filter(institution => !selectedLeis.includes(institution.lei))
.filter(institution => selectedLeis.indexOf(institution.lei) === -1)
.map(institution => ({ value: institution.lei, label: `${institution.name.toUpperCase()} - ${institution.lei}` }))
.sort(sortByLabel)
opts.unshift({ value: 'all', label: `All Financial Institutions (${institutions.length})` })
Expand Down

0 comments on commit 1fa54de

Please sign in to comment.