|
2 | 2 | // @ts-ignore no declarations
|
3 | 3 | import { initAll } from "govuk-frontend";
|
4 | 4 | import AppVersion from "lib/browse/AppVersion.svelte";
|
5 |
| - import { processInput, type Scheme } from "lib/browse/data"; |
| 5 | + import { processInput, type AllSchemeGJ, type Scheme } from "lib/browse/data"; |
6 | 6 | import Filters from "lib/browse/Filters.svelte";
|
7 | 7 | import LayerControls from "lib/browse/LayerControls.svelte";
|
8 | 8 | import LoadRemoteSchemeData from "lib/browse/LoadRemoteSchemeData.svelte";
|
|
19 | 19 | ZoomOutMap,
|
20 | 20 | } from "lib/common";
|
21 | 21 | import { ErrorMessage } from "lib/govuk";
|
22 |
| - import { gjScheme, mapStyle } from "stores"; |
| 22 | + import { mapStyle } from "stores"; |
23 | 23 | import { onMount } from "svelte";
|
24 | 24 |
|
25 |
| - // TODO Remove after the input data is fixed to plumb correct authority names. |
26 |
| - let authorityNames: Set<string> = new Set(authorityNamesList); |
27 |
| -
|
28 | 25 | onMount(() => {
|
29 | 26 | // For govuk components. Must happen here.
|
30 | 27 | initAll();
|
31 | 28 | });
|
32 | 29 |
|
| 30 | + // TODO Remove after the input data is fixed to plumb correct authority names. |
| 31 | + let authorityNames: Set<string> = new Set(authorityNamesList); |
| 32 | +
|
33 | 33 | const params = new URLSearchParams(window.location.search);
|
34 | 34 | mapStyle.set(params.get("style") || "dataviz");
|
35 | 35 | let errorMessage = "";
|
36 | 36 |
|
| 37 | + let schemesGj: AllSchemeGJ = { |
| 38 | + type: "FeatureCollection", |
| 39 | + features: [], |
| 40 | + schemes: {}, |
| 41 | + }; |
37 | 42 | let schemes: Map<string, Scheme> = new Map();
|
38 | 43 | let schemesToBeShown: Set<string> = new Set();
|
39 | 44 | let filterText = "";
|
40 | 45 | let showSchemes = true;
|
41 | 46 |
|
42 | 47 | function loadFile(text: string) {
|
43 | 48 | try {
|
44 |
| - gjScheme.set(JSON.parse(text)); |
45 |
| - // @ts-ignore TODO We're abusing the gjScheme store in the browse page for now |
46 |
| - schemes = processInput($gjScheme); |
| 49 | + schemesGj = JSON.parse(text); |
| 50 | + schemes = processInput(schemesGj); |
47 | 51 | errorMessage = "";
|
48 | 52 | } catch (err) {
|
49 | 53 | errorMessage = `The file you loaded is broken: ${err}`;
|
|
55 | 59 | <div slot="sidebar" class="govuk-prose">
|
56 | 60 | <div style="display: flex; justify-content: space-between">
|
57 | 61 | <h1>Browse schemes</h1>
|
58 |
| - <ZoomOutMap boundaryGeojson={$gjScheme} /> |
| 62 | + <ZoomOutMap boundaryGeojson={schemesGj} /> |
59 | 63 | </div>
|
60 | 64 | <AppVersion />
|
61 | 65 | <LoggedIn />
|
|
67 | 71 |
|
68 | 72 | {#if schemes.size > 0}
|
69 | 73 | <Filters
|
| 74 | + bind:schemesGj |
70 | 75 | {schemes}
|
71 | 76 | bind:schemesToBeShown
|
72 | 77 | bind:filterText
|
|
77 | 82 | <ul>
|
78 | 83 | {#each schemes.values() as scheme}
|
79 | 84 | {#if schemesToBeShown.has(scheme.scheme_reference)}
|
80 |
| - <SchemeCard {scheme} {authorityNames} /> |
| 85 | + <SchemeCard {schemesGj} {scheme} {authorityNames} /> |
81 | 86 | {/if}
|
82 | 87 | {/each}
|
83 | 88 | </ul>
|
84 | 89 | </div>
|
85 | 90 | <div slot="main">
|
86 | 91 | <MapLibreMap style={$mapStyle} startBounds={[-5.96, 49.89, 2.31, 55.94]}>
|
87 |
| - <InterventionLayer {filterText} {showSchemes} /> |
| 92 | + <InterventionLayer {schemesGj} {filterText} {showSchemes} /> |
88 | 93 | <div class="top-right">
|
89 | 94 | <LayerControls />
|
90 | 95 | </div>
|
|
0 commit comments