Skip to content

Commit

Permalink
Filter PMP by stage. #94
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Nov 28, 2024
1 parent 1f88a02 commit cc32923
Showing 1 changed file with 56 additions and 30 deletions.
86 changes: 56 additions & 30 deletions src/routes/route_check/problems_map/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
WarningButton,
CollapsibleCard,
Checkbox,
CheckboxGroup,
IconButton,
} from "govuk-svelte";
import { tick } from "svelte";
Expand Down Expand Up @@ -66,6 +67,8 @@
let hoveringSidebar: ID | null = null;
let streetviewOn = false;
let showRoute = true;
let showExisting = true;
let showDesign = true;
$: if (map) {
map.getCanvas().style.cursor =
Expand Down Expand Up @@ -291,6 +294,20 @@
}
}
}
function show(
showExisting: boolean,
showDesign: boolean,
stage: "Existing" | "Design" | "",
) {
if (!showExisting && stage == "Existing") {
return false;
}
if (!showDesign && stage == "Design") {
return false;
}
return true;
}
</script>

<svelte:window on:keydown={onKeyDown} />
Expand All @@ -311,6 +328,11 @@
<Checkbox bind:checked={showRoute}>Show route</Checkbox>
</CollapsibleCard>

<CheckboxGroup small>
<Checkbox bind:checked={showExisting}>Show existing problems</Checkbox>
<Checkbox bind:checked={showDesign}>Show design problems</Checkbox>
</CheckboxGroup>

<div style="background-color: grey; padding: 4px">
<h3>Critical Issue Log</h3>
{#each $state.criticalIssues as critical, idx}
Expand Down Expand Up @@ -425,39 +447,43 @@
{/if}

{#each $state.criticalIssues as critical, idx}
<Marker
draggable
bind:lngLat={critical.point}
on:click={() => select({ kind: "critical", idx })}
on:dragend={() => select({ kind: "critical", idx })}
>
<svg width="40" height="40" xmlns="http://www.w3.org/2000/svg">
<rect width="40" height="40" fill={colors.critical.background} />
<text
x="50%"
y="50%"
style:fill="white"
style:font="bold 15px sans-serif"
dominant-baseline="middle"
text-anchor="middle"
>
{critical.criticalIssue}
</text>
</svg>
</Marker>
{#if show(showExisting, showDesign, critical.stage)}
<Marker
draggable
bind:lngLat={critical.point}
on:click={() => select({ kind: "critical", idx })}
on:dragend={() => select({ kind: "critical", idx })}
>
<svg width="40" height="40" xmlns="http://www.w3.org/2000/svg">
<rect width="40" height="40" fill={colors.critical.background} />
<text
x="50%"
y="50%"
style:fill="white"
style:font="bold 15px sans-serif"
dominant-baseline="middle"
text-anchor="middle"
>
{critical.criticalIssue}
</text>
</svg>
</Marker>
{/if}
{/each}

{#each $state.policyConflictLog as conflict, idx}
<Marker
draggable
bind:lngLat={conflict.point}
on:click={() => select({ kind: "conflict", idx })}
on:dragend={() => select({ kind: "conflict", idx })}
>
<span class="dot" style:background={policyConflictColor}>
{conflict.conflict}
</span>
</Marker>
{#if show(showExisting, showDesign, conflict.stage)}
<Marker
draggable
bind:lngLat={conflict.point}
on:click={() => select({ kind: "conflict", idx })}
on:dragend={() => select({ kind: "conflict", idx })}
>
<span class="dot" style:background={policyConflictColor}>
{conflict.conflict}
</span>
</Marker>
{/if}
{/each}

<GeoJSON data={hoverGj}>
Expand Down

0 comments on commit cc32923

Please sign in to comment.