Skip to content

Commit

Permalink
Change subscheme to scheme when giving default name to "sub"schemes. …
Browse files Browse the repository at this point in the history
…Don't require user to expand 'sub'scheme to see its interventions
  • Loading branch information
Peter York committed Nov 6, 2023
1 parent f7b31e7 commit eb0c8e6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
16 changes: 10 additions & 6 deletions src/lib/sidebar/PipelineListMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import { DefaultButton } from "lib/govuk";
import { gjScheme } from "stores";
import type { Scheme } from "types";
import EntireSubscheme from "./EntireSubscheme.svelte";
import ListedIntervention from "./ListedIntervention.svelte";
import PipelineSchemeDetails from "./PipelineSchemeDetails.svelte";
import { interventionWarning } from "./scheme_data";
function addSubscheme() {
gjScheme.update((gj: any) => {
Expand Down Expand Up @@ -51,10 +53,12 @@
<h2>Subschemes</h2>
<DefaultButton on:click={addSubscheme}>Add Subscheme</DefaultButton>
{#each $gjScheme.subschemes as subscheme}
<EntireSubscheme
{subscheme}
{getSubschemeNameUpdater}
superscheme={$gjScheme}
/>
<PipelineSchemeDetails {subscheme} {getSubschemeNameUpdater} />
<ul style="margin-left: l5px">
{#each $gjScheme.features.filter((feature) => feature.properties.pipeline?.schemeId === subscheme.id) as feature}
{@const warning = interventionWarning("pipeline", feature)}
<ListedIntervention {feature} schema={"pipeline"} {warning} />
{/each}
</ul>
{/each}
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,25 @@
WarningButton,
} from "lib/govuk";
import { gjScheme, mode } from "stores";
import type { FeatureUnion, Scheme, PipelineScheme } from "types";
import ListedIntervention from "./ListedIntervention.svelte";
import { interventionWarning } from "./scheme_data";
import PipelineSchemeForm from "./PipelineSchemeForm.svelte";
import type { FeatureUnion, PipelineScheme } from "types";
import PipelineSchemeForm from "./PipelineSchemeForm.svelte";
export let subscheme: PipelineScheme;
export let superscheme: Scheme;
export let getSubschemeNameUpdater: Function;
let displayDeleteConfirmation = false;
let features: FeatureUnion[] = superscheme.features.filter((feature) => {
return feature.properties.pipeline?.schemeId === subscheme.id;
});
// @ts-ignore we know subschemes exists because otherwise this wouldn't be rendered
$: disabledSubschemeDeletion = $gjScheme.subschemes?.length < 2;
let numErrors = 0;
function deleteSubscheme() {
displayDeleteConfirmation = false;
const clonedScheme = JSON.parse(JSON.stringify($gjScheme));
clonedScheme.features = clonedScheme.features.filter(
(feature: FeatureUnion) => {
return (
feature.properties.pipeline?.schemeId !== subscheme.id
);
return feature.properties.pipeline?.schemeId !== subscheme.id;
}
);
clonedScheme.subschemes = clonedScheme.subschemes?.filter(
Expand All @@ -54,7 +45,7 @@
value={subscheme.name}
on:change={getSubschemeNameUpdater(subscheme.name)}
/>
<PipelineSchemeForm {subscheme}/>
<PipelineSchemeForm {subscheme} />
<WarningButton
disabled={disabledSubschemeDeletion}
on:click={() => (displayDeleteConfirmation = true)}
Expand Down Expand Up @@ -89,9 +80,5 @@
errorMessage="There's a problem with {numErrors} interventions below"
/>
{/if}
{#each features as feature}
{@const warning = interventionWarning("pipeline", feature)}
<ListedIntervention {feature} schema={"pipeline"} {warning} />
{/each}
</CollapsibleCard>
{/if}
4 changes: 2 additions & 2 deletions src/lib/sidebar/scheme_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export function backfillSuperscheme(
if (!json.scheme_name) {
json.scheme_name = authorityName
? `${authorityName} LCWIP`
: "Untitled Supserscheme";
: "Unnamed Supserscheme";
}

json.subschemes = json.subschemes
? json.subschemes
: [
{
id: 0,
name: "Untitled Subscheme",
name: "Unnamed Scheme",
scheme_type: "",
status: "",
timescale: "",
Expand Down

0 comments on commit eb0c8e6

Please sign in to comment.