Skip to content

Commit

Permalink
Merge pull request #956 from cityofaustin/4404_crash_narrative_crash_…
Browse files Browse the repository at this point in the history
…diagram_ui

4404 crash narrative crash diagram UI
  • Loading branch information
tillyw authored Dec 22, 2020
2 parents b0abc05 + 223d8b2 commit 1657896
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 131 deletions.
6 changes: 0 additions & 6 deletions atd-vze/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
publish = "build"
command = "npm run build:staging"

# Deploy Preview context:
# All deploys generated from a pull/merge request
# will inherit these settings.
[context.deploy-preview.environment]
NODE_ENV = "staging"

[[headers]]
# Define which paths this specific [[headers]] block will cover.
for = "/*"
Expand Down
7 changes: 6 additions & 1 deletion atd-vze/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions atd-vze/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"react-router-config": "^5.0.1",
"react-router-dom": "^5.1.2",
"react-test-renderer": "^16.8.6",
"react-zoom-pan-pinch": "^1.6.1",
"reactstrap": "^8.0.0",
"serialize-javascript": ">=3.1.0",
"simple-line-icons": "^2.4.1",
Expand Down
1 change: 1 addition & 0 deletions atd-vze/src/queries/crashes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const GET_CRASH = gql`
atd_fatality_count
case_id
city_id
cr3_file_metadata
cr3_stored_flag
crash_date
crash_fatal_fl
Expand Down
50 changes: 0 additions & 50 deletions atd-vze/src/views/Crashes/CR3Record.js

This file was deleted.

156 changes: 84 additions & 72 deletions atd-vze/src/views/Crashes/Crash.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
CardHeader,
Col,
Row,
Table,
Alert,
Button,
} from "reactstrap";
Expand All @@ -18,7 +17,8 @@ import CrashMap from "./Maps/CrashMap";
import CrashEditCoordsMap from "./Maps/CrashEditCoordsMap";
import Widget02 from "../Widgets/Widget02";
import CrashChangeLog from "./CrashChangeLog";
import CR3Record from "./CR3Record";
import CrashDiagram from "./CrashDiagram";
import CrashNarrative from "./CrashNarrative";
import DataTable from "../../Components/DataTable";
import { crashDataMap } from "./crashDataMap";

Expand Down Expand Up @@ -144,12 +144,19 @@ function Crash(props) {
cr3_stored_flag: cr3StoredFlag,
temp_record: tempRecord,
geocode_method: geocodeMethod,
cr3_file_metadata: cr3FileMetadata,
investigator_narrative: investigatorNarrative,
} = data.atd_txdot_crashes[0];

const mapGeocoderAddress = createGeocoderAddressString(data);
const yearsLifeLostCount = calculateYearsLifeLost(
peopleData.atd_txdot_primaryperson.concat(peopleData.atd_txdot_person)
);
const hasLocation =
data &&
data.atd_txdot_crashes.length > 0 &&
data.atd_txdot_crashes[0]["location_id"];
const notEditingCoords = !isEditingCoords && latitude && longitude;

return (
<div className="animated fadeIn">
Expand Down Expand Up @@ -197,78 +204,83 @@ function Crash(props) {
</Col>
</Row>
<Row>
<Col xs="12" md="6">
<div className="mb-4">
<Card>
<CardHeader>
<Row>
<Col>
Crash Location (ID:{" "}
{(data && data.atd_txdot_crashes.length > 0 && data.atd_txdot_crashes[0]["location_id"] && (
<>
<Link
to={`/locations/${
data.atd_txdot_crashes[0]["location_id"]
}`}
>
{data.atd_txdot_crashes[0]["location_id"]}
</Link>
</>
)) ||
"unassigned"}
)
<br />
Geocode Provider:{" "}
{latitude && longitude
? geocodeMethod.name
: "No Primary Coordinates"}
</Col>
<Col>
{!isEditingCoords && (
<Button
color="primary"
style={{ float: "right" }}
onClick={e => setIsEditingCoords(!isEditingCoords)}
>
Edit Coordinates
</Button>
)}
</Col>
</Row>
</CardHeader>
<CardBody>
{(!latitude || !longitude) && (
<Alert color="danger">
Crash record is missing latitude and longitude values
required for map display.
</Alert>
)}
{!isEditingCoords && latitude && longitude ? (
<>
<CrashMap data={data.atd_txdot_crashes[0]} />
<Table responsive striped hover>
<tbody></tbody>
</Table>
</>
) : (
<>
<CrashEditCoordsMap
data={data.atd_txdot_crashes[0]}
mapGeocoderAddress={mapGeocoderAddress}
crashId={crashId}
refetchCrashData={refetch}
setIsEditingCoords={setIsEditingCoords}
/>
</>
)}
</CardBody>
</Card>
</div>
<Col xs="12" md="6" className="mb-4">
<Card className="h-100">
<CardHeader>
<Row>
<Col>
Crash Location (ID:{" "}
{(hasLocation && (
<Link
to={`/locations/${
data.atd_txdot_crashes[0]["location_id"]
}`}
>
{data.atd_txdot_crashes[0]["location_id"]}
</Link>
)) ||
"unassigned"}
)
<br />
Geocode Provider:{" "}
{latitude && longitude
? geocodeMethod.name
: "No Primary Coordinates"}
</Col>
<Col>
{!isEditingCoords && (
<Button
color="primary"
style={{ float: "right" }}
onClick={e => setIsEditingCoords(!isEditingCoords)}
>
Edit Coordinates
</Button>
)}
</Col>
</Row>
</CardHeader>
<CardBody style={{ minHeight: "350px" }}>
{(!latitude || !longitude) && (
<Alert color="danger">
Crash record is missing latitude and longitude values required
for map display.
</Alert>
)}
{notEditingCoords ? (
<CrashMap data={data.atd_txdot_crashes[0]} />
) : (
<CrashEditCoordsMap
data={data.atd_txdot_crashes[0]}
mapGeocoderAddress={mapGeocoderAddress}
crashId={crashId}
refetchCrashData={refetch}
setIsEditingCoords={setIsEditingCoords}
/>
)}
</CardBody>
</Card>
</Col>
<Col xs="12" md="6">
<CR3Record crashId={crashId} isCr3Stored={cr3StoredFlag === "Y"} isTempRecord={tempRecord} />
<Col xs="12" md="6" className="mb-4">
<CrashDiagram
crashId={crashId}
isCr3Stored={cr3StoredFlag === "Y"}
isTempRecord={tempRecord}
cr3FileMetadata={cr3FileMetadata}
/>
</Col>
<Col xs="12">
</Row>
{!!investigatorNarrative ? (
<Row>
<Col>
<CrashNarrative investigatorNarrative={investigatorNarrative} />
</Col>
</Row>
) : (
<div></div>
)}
<Row>
<Col>
<CrashCollapses data={data} props={props} />
</Col>
</Row>
Expand Down
Loading

0 comments on commit 1657896

Please sign in to comment.