Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the SS sketches shown as a SB layer -- one layer, not split … #543

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly just some careful renaming here

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering about local legend: v2 will want to be rebased onto this and we may want to rethink the legend

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, let's figure that out in #544. There's more changes to browse needed for v2, like updating the intervention popup


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
Loading