Skip to content

Commit

Permalink
Simplify the SS sketches shown as a SB layer -- one layer, not split …
Browse files Browse the repository at this point in the history
…by ATF/LCWIP.
  • Loading branch information
dabreegster committed Nov 20, 2024
1 parent dd9d28d commit 9f808cb
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 194 deletions.
2 changes: 1 addition & 1 deletion src/lib/browse/schemes/Filters.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
currentMilestones as currentMilestoneColors,
} from "./colors";
export let source: string;
export let source: "ATF" | "LCWIP" | "Local";
export let schemesGj: Schemes;
export let filterSchemeText: string;
export let filterInterventionText: string;
Expand Down
224 changes: 74 additions & 150 deletions src/lib/browse/schemes/SchemesLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
import { importAllLocalSketches, setupSchemes } from "./data";
import Filters from "./Filters.svelte";
import {
mainAtfSchemes,
mainLcwipSchemes,
filterMainAtfSchemeText,
filterMainAtfInterventionText,
filterMainLcwipSchemeText,
filterMainLcwipInterventionText,
localAtfSchemes,
localLcwipSchemes,
filterLocalAtfSchemeText,
filterLocalAtfInterventionText,
filterLocalLcwipSchemeText,
filterLocalLcwipInterventionText,
atfSchemes,
lcwipSchemes,
filterAtfSchemeText,
filterAtfInterventionText,
filterLcwipSchemeText,
filterLcwipInterventionText,
localSchemes,
filterLocalSchemeText,
filterLocalInterventionText,
} from "./stores";
import InterventionLayer from "./InterventionLayer.svelte";
import { colorInterventionsBySchema, schemaLegend } from "schemas";
Expand All @@ -35,45 +32,37 @@
let errorMessage = "";
let mainAtfName = "main_atf_schemes";
let mainAtfTitle = "ATF schemes";
let mainAtfShow = showHideLayer(mainAtfName);
let mainAtfStyle = "fundingProgramme";
$: [mainAtfColor, mainAtfLegend] = pickStyle(mainAtfStyle);
let atfName = "atf_schemes";
let atfTitle = "ATF schemes";
let atfShow = showHideLayer(atfName);
let atfStyle = "fundingProgramme";
$: [atfColor, atfLegend] = pickStyle(atfStyle);
let mainLcwipName = "main_lcwip_schemes";
let mainLcwipTitle = "LCWIP schemes";
let mainLcwipShow = showHideLayer(mainLcwipName);
let mainLcwipStyle = "interventionType";
$: [mainLcwipColor, mainLcwipLegend] = pickStyle(mainLcwipStyle);
let lcwipName = "lcwip_schemes";
let lcwipTitle = "LCWIP schemes";
let lcwipShow = showHideLayer(lcwipName);
let lcwipStyle = "interventionType";
$: [lcwipColor, lcwipLegend] = pickStyle(lcwipStyle);
let localAtfName = "local_atf_schemes";
let localAtfTitle = "Your ATF schemes";
let localAtfShow = showHideLayer(localAtfName);
let localAtfStyle = "fundingProgramme";
$: [localAtfColor, localAtfLegend] = pickStyle(localAtfStyle);
let localLcwipName = "local_lcwip_schemes";
let localLcwipTitle = "Your LCWIP schemes";
let localLcwipShow = showHideLayer(localLcwipName);
let localLcwipStyle = "interventionType";
$: [localLcwipColor, localLcwipLegend] = pickStyle(localLcwipStyle);
let localName = "local_schemes";
let localTitle = "Your schemes";
let localShow = showHideLayer(localName);
$: [localColor, localLegend] = pickStyle("interventionType");
function loadMainFile(filename: string, text: string) {
try {
setupSchemes(JSON.parse(text), mainAtfSchemes, mainLcwipSchemes);
$mainAtfShow = true;
$mainLcwipShow = true;
setupSchemes(JSON.parse(text), atfSchemes, lcwipSchemes);
$atfShow = true;
$lcwipShow = true;
errorMessage = "";
} catch (err) {
errorMessage = `The file you loaded is broken: ${err}`;
}
}
function importLocalSketches() {
setupSchemes(importAllLocalSketches(), localAtfSchemes, localLcwipSchemes);
$localAtfShow = true;
$localLcwipShow = true;
$localSchemes = importAllLocalSketches();
$localShow = true;
}
function pickStyle(
Expand Down Expand Up @@ -112,19 +101,15 @@
{/if}

<CheckboxGroup small>
{#if Object.entries($mainAtfSchemes.schemes).length > 0}
<LayerControl
name={mainAtfName}
title={mainAtfTitle}
bind:show={$mainAtfShow}
>
{#if Object.entries($atfSchemes.schemes).length > 0}
<LayerControl name={atfName} title={atfTitle} bind:show={$atfShow}>
<span slot="help">
<p>
<WarningIcon text="Scheme data caveats" />Please note there are data
quality caveats for all scheme data:
</p>
<ul>
{#each $mainAtfSchemes.notes ?? [] as note}
{#each $atfSchemes.notes ?? [] as note}
<li><p>{note}</p></li>
{/each}
</ul>
Expand All @@ -133,9 +118,9 @@
<div slot="controls" style="border: 1px solid black; padding: 8px;">
<Filters
source="ATF"
bind:schemesGj={$mainAtfSchemes}
bind:filterSchemeText={$filterMainAtfSchemeText}
bind:filterInterventionText={$filterMainAtfInterventionText}
bind:schemesGj={$atfSchemes}
bind:filterSchemeText={$filterAtfSchemeText}
bind:filterInterventionText={$filterAtfInterventionText}
/>

<Select
Expand All @@ -145,26 +130,22 @@
["interventionType", "By intervention type"],
["currentMilestone", "By current milestone"],
]}
bind:value={mainAtfStyle}
bind:value={atfStyle}
/>
<Legend rows={mainAtfLegend} />
<Legend rows={atfLegend} />
</div>
</LayerControl>
{/if}

{#if Object.entries($mainLcwipSchemes.schemes).length > 0}
<LayerControl
name={mainLcwipName}
title={mainLcwipTitle}
bind:show={$mainLcwipShow}
>
{#if Object.entries($lcwipSchemes.schemes).length > 0}
<LayerControl name={lcwipName} title={lcwipTitle} bind:show={$lcwipShow}>
<span slot="help">
<p>
<WarningIcon text="Scheme data caveats" />Please note there are data
quality caveats for all scheme data:
</p>
<ul>
{#each $mainLcwipSchemes.notes ?? [] as note}
{#each $lcwipSchemes.notes ?? [] as note}
<li><p>{note}</p></li>
{/each}
</ul>
Expand All @@ -173,17 +154,17 @@
<div slot="controls" style="border: 1px solid black; padding: 8px;">
<Filters
source="LCWIP"
bind:schemesGj={$mainLcwipSchemes}
bind:filterSchemeText={$filterMainLcwipSchemeText}
bind:filterInterventionText={$filterMainLcwipInterventionText}
bind:schemesGj={$lcwipSchemes}
bind:filterSchemeText={$filterLcwipSchemeText}
bind:filterInterventionText={$filterLcwipInterventionText}
/>

<Select
label="Colour interventions"
choices={[["interventionType", "By intervention type"]]}
bind:value={mainLcwipStyle}
bind:value={lcwipStyle}
/>
<Legend rows={mainLcwipLegend} />
<Legend rows={lcwipLegend} />
</div>
</LayerControl>
{/if}
Expand All @@ -199,118 +180,61 @@
</SecondaryButton>

<CheckboxGroup small>
{#if Object.entries($localAtfSchemes.schemes).length > 0}
<LayerControl
name={localAtfName}
title={localAtfTitle}
bind:show={$localAtfShow}
>
{#if Object.entries($localSchemes.schemes).length > 0}
<LayerControl name={localName} title={localTitle} bind:show={$localShow}>
<span slot="help">
<p>
<WarningIcon text="Scheme data caveats" />Please note there are data
quality caveats for all scheme data:
</p>
<ul>
{#each $localAtfSchemes.notes ?? [] as note}
{#each $localSchemes.notes ?? [] as note}
<li><p>{note}</p></li>
{/each}
</ul>
</span>

<div slot="controls" style="border: 1px solid black; padding: 8px;">
<Filters
source="ATF"
bind:schemesGj={$localAtfSchemes}
bind:filterSchemeText={$filterLocalAtfSchemeText}
bind:filterInterventionText={$filterLocalAtfInterventionText}
source="Local"
bind:schemesGj={$localSchemes}
bind:filterSchemeText={$filterLocalSchemeText}
bind:filterInterventionText={$filterLocalInterventionText}
/>

<Select
label="Colour interventions"
choices={[
["fundingProgramme", "By funding programme"],
["interventionType", "By intervention type"],
["currentMilestone", "By current milestone"],
]}
bind:value={localAtfStyle}
/>
<Legend rows={localAtfLegend} />
</div>
</LayerControl>
{/if}

{#if Object.entries($localLcwipSchemes.schemes).length > 0}
<LayerControl
name={localLcwipName}
title={localLcwipTitle}
bind:show={$localLcwipShow}
>
<span slot="help">
<p>
<WarningIcon text="Scheme data caveats" />Please note there are data
quality caveats for all scheme data:
</p>
<ul>
{#each $localLcwipSchemes.notes ?? [] as note}
<li><p>{note}</p></li>
{/each}
</ul>
</span>

<div slot="controls" style="border: 1px solid black; padding: 8px;">
<Filters
source="LCWIP"
bind:schemesGj={$localLcwipSchemes}
bind:filterSchemeText={$filterLocalLcwipSchemeText}
bind:filterInterventionText={$filterLocalLcwipInterventionText}
/>

<Select
label="Colour interventions"
choices={[["interventionType", "By intervention type"]]}
bind:value={localLcwipStyle}
/>
<Legend rows={localLcwipLegend} />
<Legend rows={localLegend} />
</div>
</LayerControl>
{/if}
</CheckboxGroup>
</CollapsibleCard>

<InterventionLayer
name="main_atf"
description={mainAtfTitle}
show={$mainAtfShow}
schemesGj={$mainAtfSchemes}
filterSchemeText={$filterMainAtfSchemeText}
filterInterventionText={$filterMainAtfInterventionText}
color={mainAtfColor}
/>
<InterventionLayer
name="main_lcwip"
description={mainLcwipTitle}
show={$mainLcwipShow}
schemesGj={$mainLcwipSchemes}
filterSchemeText={$filterMainLcwipSchemeText}
filterInterventionText={$filterMainLcwipInterventionText}
color={mainLcwipColor}
name="atf"
description={atfTitle}
show={$atfShow}
schemesGj={$atfSchemes}
filterSchemeText={$filterAtfSchemeText}
filterInterventionText={$filterAtfInterventionText}
color={atfColor}
/>

<InterventionLayer
name="local_atf"
description={localAtfTitle}
show={$localAtfShow}
schemesGj={$localAtfSchemes}
filterSchemeText={$filterLocalAtfSchemeText}
filterInterventionText={$filterLocalAtfInterventionText}
color={localAtfColor}
name="lcwip"
description={lcwipTitle}
show={$lcwipShow}
schemesGj={$lcwipSchemes}
filterSchemeText={$filterLcwipSchemeText}
filterInterventionText={$filterLcwipInterventionText}
color={lcwipColor}
/>

<InterventionLayer
name="local_lcwip"
description={localLcwipTitle}
show={$localLcwipShow}
schemesGj={$localLcwipSchemes}
filterSchemeText={$filterLocalLcwipSchemeText}
filterInterventionText={$filterLocalLcwipInterventionText}
color={localLcwipColor}
name="local"
description={localTitle}
show={$localShow}
schemesGj={$localSchemes}
filterSchemeText={$filterLocalSchemeText}
filterInterventionText={$filterLocalInterventionText}
color={localColor}
/>
28 changes: 10 additions & 18 deletions src/lib/browse/schemes/stores.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
import { writable, type Writable } from "svelte/store";
import type { Schemes } from "types";

// There are four variations -- main and local ATF and LCWIP schemes
// There are three variations -- ATF, LCWIP, and local (any schema)

// TODO Bundle this into one type, so it's easier to plumb around
export const mainAtfSchemes: Writable<Schemes> = writable({
export const atfSchemes: Writable<Schemes> = writable({
type: "FeatureCollection",
features: [],
schemes: {},
});
export const filterMainAtfInterventionText: Writable<string> = writable("");
export const filterMainAtfSchemeText: Writable<string> = writable("");
export const filterAtfInterventionText: Writable<string> = writable("");
export const filterAtfSchemeText: Writable<string> = writable("");

export const mainLcwipSchemes: Writable<Schemes> = writable({
export const lcwipSchemes: Writable<Schemes> = writable({
type: "FeatureCollection",
features: [],
schemes: {},
});
export const filterMainLcwipInterventionText: Writable<string> = writable("");
export const filterMainLcwipSchemeText: Writable<string> = writable("");
export const filterLcwipInterventionText: Writable<string> = writable("");
export const filterLcwipSchemeText: Writable<string> = writable("");

export const localAtfSchemes: Writable<Schemes> = writable({
export const localSchemes: Writable<Schemes> = writable({
type: "FeatureCollection",
features: [],
schemes: {},
});
export const filterLocalAtfInterventionText: Writable<string> = writable("");
export const filterLocalAtfSchemeText: Writable<string> = writable("");

export const localLcwipSchemes: Writable<Schemes> = writable({
type: "FeatureCollection",
features: [],
schemes: {},
});
export const filterLocalLcwipInterventionText: Writable<string> = writable("");
export const filterLocalLcwipSchemeText: Writable<string> = writable("");
export const filterLocalInterventionText: Writable<string> = writable("");
export const filterLocalSchemeText: Writable<string> = writable("");
Loading

0 comments on commit 9f808cb

Please sign in to comment.