Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "No assigned county" instead of "Unspecified" in agency search results #960

Merged
merged 4 commits into from
Jun 16, 2017
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: 1 addition & 1 deletion src/components/AgencySearchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const AgencySearchResults = ({ data, groupKey, groupValues, onClick }) => {
data: noFederal.filter(d => d[groupKey] === key),
}))
dataGrouped.push({
key: 'Unspecified',
key: 'No assigned county',
data: noFederal.filter(d => d[groupKey] === null),
})

Expand Down
26 changes: 20 additions & 6 deletions src/components/ExplorerIntroNational.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
import lowerCase from 'lodash.lowercase'
import upperFirst from 'lodash.upperfirst'
import PropTypes from 'prop-types'
import React from 'react'

import Term from './Term'
import { estimatedTerm, nibrsTerm, srsTerm } from './Terms'
import { formatNum } from '../util/formats'
import mapCrimeToGlossaryTerm from '../util/glossary'

const ExplorerIntroNational = ({ crime, ucr, until }) => {
const isArson = crime === 'arson'
const untilUcr = ucr.find(p => p.year === until)
const crimeTerm = (
<Term id={mapCrimeToGlossaryTerm(crime)} size="sm">
{upperFirst(lowerCase(crime))}
</Term>
)

return (
<div>
{!isArson
? <div>
<p className="serif">
Crime rates for the nation are derived from both
{crimeTerm} rates for the nation are derived from both
{' '}
{srsTerm}
{' '}
and
{' '}
{nibrsTerm}
{' '}
reports sent to the FBI.
reports voluntarily submitted to the FBI.
</p>
<p className="serif">
In
Expand All @@ -31,10 +40,15 @@ const ExplorerIntroNational = ({ crime, ucr, until }) => {
{' '}
{estimatedTerm}
{' '}
crime statistics for the nation
based on data voluntarily reported by{' '}
{formatNum(untilUcr.participating_agencies)}{' '}
law enforcement agencies.
crime statistics for the nation based on data received from
{' '}
{formatNum(untilUcr.participating_agencies)}
{' '}
law enforcement agencies out of
{' '}
{formatNum(untilUcr.total_agencies)}
{' '}
in the country that year.
</p>
</div>
: <div>
Expand Down
21 changes: 17 additions & 4 deletions src/components/ExplorerIntroState.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import lowerCase from 'lodash.lowercase'
import startCase from 'lodash.startcase'
import upperFirst from 'lodash.upperfirst'
import React from 'react'

import Term from './Term'
import { estimatedTerm, nibrsTerm, srsTerm } from './Terms'
import { formatNum } from '../util/formats'
import mapCrimeToGlossaryTerm from '../util/glossary'
import ucrParticipationLookup from '../util/ucr'

const getReportTerms = ({ nibrs, srs, hybrid }) =>
Expand All @@ -18,17 +22,22 @@ const ExplorerIntroState = ({ crime, place, ucr, until }) => {
const { nibrs, srs } = ucrParticipationLookup(place)
const untilUcr = ucr.find(p => p.year === until)
const reportTerms = getReportTerms({ nibrs, srs, hybrid: nibrs && srs })
const crimeTerm = (
<Term id={mapCrimeToGlossaryTerm(crime)} size="sm">
{upperFirst(lowerCase(crime))}
</Term>
)

return (
<div>
{!isArson
? <div>
<p className="serif">
Crime rates for {startCase(place)} are derived from
{crimeTerm} rates for {startCase(place)} are derived from
{' '}
{reportTerms}
{' '}
reports sent to the FBI.
reports voluntarily submitted to the FBI.
</p>
<p className="serif">
In
Expand All @@ -38,11 +47,15 @@ const ExplorerIntroState = ({ crime, place, ucr, until }) => {
{' '}
{startCase(place)}
{' '}
based on data voluntarily reported by
based on data received from
{' '}
{formatNum(untilUcr.participating_agencies)}
{' '}
law enforcement agencies.
law enforcement agencies out of
{' '}
{formatNum(untilUcr.total_agencies)}
{' '}
in the state that year.
</p>
</div>
: <div>
Expand Down
3 changes: 1 addition & 2 deletions src/components/NibrsStackedBarDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'

const fmt = p => (p > 0.01 ? format('.0%')(p) : '<1%')

const NibrsStackedBarDetails = ({ colorMap, data, total }) => (
const NibrsStackedBarDetails = ({ colorMap, data, total }) =>
<ul className="list-style-none p0 m0 fs-14">
{data.map((d, i) => {
const notLast = i + 1 !== data.length ? 'mb1' : ''
Expand All @@ -25,7 +25,6 @@ const NibrsStackedBarDetails = ({ colorMap, data, total }) => (
)
})}
</ul>
)

NibrsStackedBarDetails.propTypes = {
colorMap: PropTypes.func.isRequired,
Expand Down
12 changes: 1 addition & 11 deletions src/containers/ExplorerHeaderContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,10 @@ const ExplorerHeaderContainer = ({
<div className="lg-col lg-col-4 xs-hide sm-hide md-hide">
<PlaceThumbnail selected={startCase(usState)} />
<div className="mt-tiny fs-14 right">
{isAgency
{isAgency && !isLoading
? `${placeDisplay}, ${startCase(usState)}`
: startCase(usState)}
</div>
<PlaceThumbnail selected={startCase(usState)} isAgency={isAgency} />
{isAgency &&
!isLoading &&
<div className="mt-tiny fs-14">
<span
className="mr1 inline-block bg-red-bright circle"
style={{ width: 8, height: 8 }}
/>
{agency.agency_name}
</div>}
</div>
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions src/containers/NibrsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { nibrsTerm } from '../components/Terms'
import parseNibrs from '../util/nibrs'
import { getAgency, oriToState } from '../util/ori'
import { getPlaceInfo } from '../util/place'
import ucrParticipation, {
shouldFetchNibrs as shouldShowNibrs,
} from '../util/ucr'
import ucrParticipation, { shouldFetchNibrs as shouldShowNibrs } from '../util/ucr'

const fbiLink = 'https://ucr.fbi.gov/ucr-program-data-collections'
const formatNumber = format(',')
Expand Down Expand Up @@ -70,10 +68,12 @@ const NibrsContainer = ({
totalCount = filteredData.offenderRaceCode.reduce((a, b) => a + b.count, 0)
content = (
<div className="clearfix mxn1">
{dataParsed.map((d, i) => (
{dataParsed.map((d, i) =>
<div
key={i}
className={`lg-col lg-col-6 mb2 px1 ${i % 2 === 0 ? 'clear-left' : ''}`}
className={`lg-col lg-col-6 mb2 px1 ${i % 2 === 0
? 'clear-left'
: ''}`}
>
<NibrsCard
crime={crime}
Expand All @@ -83,8 +83,8 @@ const NibrsContainer = ({
until={until}
{...d}
/>
</div>
))}
</div>,
)}
</div>
)
} else if (error) {
Expand Down