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

Renable new features #1347

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions src/components/LocationSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class LocationSelect extends React.Component {
States
</option>
{stateOpts}
<option value="" disabled>
Regions
</option>
{regionOpts}
</select>
</div>
)
Expand Down
17 changes: 7 additions & 10 deletions src/components/nibrs/NibrsIntro.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ const highlight = txt =>
const NibrsIntro = ({
crime,
isAgency,
nibrsFirstYear,
selectedYear,
participation,
placeDisplay,
totalCount,
until,
}) => {
const noun = 'incident'

if (isAgency) {
return (
<div className="m0 sm-col-10">
<p>
This agency reported {highlight(formatNum(totalCount))} individual{' '}
{crime} {pluralize(noun, totalCount)} to the FBI between{' '}
{highlight(nibrsFirstYear)} and {highlight(until)}.
In {highlight((selectedYear))}, this agency reported {highlight(formatNum(totalCount))} individual{' '}
{crime} {pluralize(noun, totalCount)} to the FBI.
</p>
</div>
)
Expand All @@ -38,9 +37,8 @@ const NibrsIntro = ({
return (
<div className="m0 sm-col-10">
<p>
There were {highlight(formatNum(totalCount))} individual {crime}{' '}
{pluralize(noun, totalCount)} reported to the FBI in {placeDisplay}{' '}
between {highlight(nibrsFirstYear)} and {highlight(until)} by{' '}
In {highlight((selectedYear))}, there were {highlight(formatNum(totalCount))} individual {crime}{' '}
{pluralize(noun, totalCount)} reported to the FBI in {placeDisplay}{' '} by{' '}
{highlight(agencyCt)} law enforcement {pluralize('agency', agencyCt)}{' '}
reporting {nibrsTerm} data.
</p>
Expand All @@ -51,11 +49,10 @@ const NibrsIntro = ({
NibrsIntro.propTypes = {
crime: PropTypes.string.isRequired,
isAgency: PropTypes.bool.isRequired,
nibrsFirstYear: PropTypes.number.isRequired,
selectedYear: PropTypes.number.isRequired,
placeDisplay: PropTypes.string.isRequired,
totalCount: PropTypes.number.isRequired,
participation: PropTypes.array.isRequired,
until: PropTypes.number.isRequired,
}

export default NibrsIntro
54 changes: 53 additions & 1 deletion src/containers/AgencyChartContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ class AgencyChartContainer extends React.Component {

const summaryData = summary.data.data


let nibrsData
let nibrsDataClean
let hasNoNibrsValues
let noNibrsDataText
if (submitsNibrs) {
nibrsData = nibrsCounts.data.offenseCount.data
nibrsDataClean = nibrsData
.filter(d => d.key === 'Incident Count' && d.data_year >= since && d.data_year <= until)
.sort((a, b) => a.data_year - b.data_year)

hasNoNibrsValues =
nibrsDataClean.length ===
nibrsDataClean.filter(d => d.actual === 0 && d.cleared === 0).length

noNibrsDataText = `There were no ${lowerCase(
pageType,
)} incidents reported during this time period.`
}
// if (!data || data.length === 0) return <NoData />

const fname = `${place}-${pageType}-${since}-${until}`
Expand Down Expand Up @@ -67,7 +86,27 @@ class AgencyChartContainer extends React.Component {
</div>}
</div>
)
}
} else if (!isSummary && submitsNibrs) {
return (
<div>
{hasNoSummaryValues
? <NoData text={noNibrsDataText} />
: <div>
<AgencyNibrsChart
crime={pageType}
data={nibrsDataClean}
since={since}
submitsNibrs
until={until}
/>
<DownloadDataBtn
data={[{ data: nibrsDataClean, filename: `${fname}.csv` }]}
filename={fname}
/>
</div>}
</div>
)
}
return <div />
}

Expand All @@ -84,6 +123,19 @@ class AgencyChartContainer extends React.Component {
<h2 className="mt0 mb2 fs-24 sm-fs-28 sans-serif">
{startCase(pageType)} reported by {agency.display}, {since}–{until}
</h2>
<div className="center">
{submitsNibrs &&
<AgencyChartToggle
isSummary={this.state.isSummary}
showSummary={() => {
this.setState({ isSummary: true })
}}
showNibrs={() => {
this.setState({ isSummary: false })
}}
/>
}
</div>
{this.generateTable(pageType, place, since, nibrsCounts, summary, until, submitsNibrs, this.state.isSummary)}
</div>
{!summary.loading &&
Expand Down
Loading