Skip to content

Commit

Permalink
- Fix some TS errors
Browse files Browse the repository at this point in the history
- Move guidance button closer to score
- Cite source
  • Loading branch information
dabreegster committed Aug 7, 2024
1 parent 71bda86 commit 8864378
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/routes/route_check/jat_check/Form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
bind:value={$state.jat[junctionIdx][stage].movements[idx].score}
/>

<Guidance />

<TextArea
label="Comments"
bind:value={$state.jat[junctionIdx][stage].movements[idx].notes}
/>

<Guidance />
14 changes: 7 additions & 7 deletions src/routes/route_check/jat_check/guidance/Guidance.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { Radio, SecondaryButton } from "govuk-svelte";
import { pairs, Modal } from "$lib";
import { guidance, type GuidanceObject } from "./data.ts";
import { guidance, type GuidanceObject, type JunctionType } from "./data";
let junctionTypes: string[] = Object.keys(guidance);
let selectedJunctionType: string = junctionTypes[0];
let junctionTypes = Object.keys(guidance) as JunctionType[];
let selectedJunctionType: JunctionType = junctionTypes[0];
let movementTypes: string[] = [];
let selectedMovementType: string = "";
Expand All @@ -20,12 +20,12 @@
selectedMovementType,
);
function getMovementTypes(junctionType: string): string[] {
function getMovementTypes(junctionType: JunctionType): string[] {
let result = Object.keys(guidance[junctionType]).filter(
(key) => key !== "summary" && key !== "otherJunctionTypeWhichApplies",
);
let otherJunctionTypeWhichApplies =
guidance[junctionType].otherJunctionTypeWhichApplies;
let otherJunctionTypeWhichApplies = guidance[junctionType]
.otherJunctionTypeWhichApplies as JunctionType | "";
if (otherJunctionTypeWhichApplies) {
result = result.concat(
Object.keys(guidance[otherJunctionTypeWhichApplies]).filter(
Expand All @@ -37,7 +37,7 @@
}
function getGuidanceObject(
junctionType: string,
junctionType: JunctionType,
movementType: string,
): GuidanceObject {
if (!movementTypes.includes(movementType)) {
Expand Down
12 changes: 11 additions & 1 deletion src/routes/route_check/jat_check/guidance/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copied manually from
// https://assets.publishing.service.gov.uk/media/5ffa1f96d3bf7f65d9e35825/cycle-infrastructure-design-ltn-1-20.pdf
// (LTN 1/20) appendix B

export const guidance = {
"Any type of junction": {
otherJunctionTypeWhichApplies: "",
Expand All @@ -23,6 +27,7 @@ export const guidance = {
],
},
},

"Simple priority T-junction": {
otherJunctionTypeWhichApplies: "",
"Right turn from minor arm": {
Expand Down Expand Up @@ -67,7 +72,8 @@ export const guidance = {
],
},
},
"Crossroads": {

Crossroads: {
otherJunctionTypeWhichApplies: "Simple priority T-junction",
"Ahead from minor arm": {
scoreZero: [
Expand All @@ -81,6 +87,7 @@ export const guidance = {
],
},
},

"Traffic Signals": {
otherJunctionTypeWhichApplies: "",
"All movements": {
Expand Down Expand Up @@ -108,6 +115,7 @@ export const guidance = {
],
},
},

Roundabout: {
otherJunctionTypeWhichApplies: "",
"All movements": {
Expand All @@ -128,6 +136,8 @@ export const guidance = {
},
};

export type JunctionType = keyof typeof guidance;

export interface GuidanceObject {
scoreZero: string[];
scoreOne: string[];
Expand Down

0 comments on commit 8864378

Please sign in to comment.