Skip to content

Commit

Permalink
Another fix for #6: change interventionWarning to just take props, an…
Browse files Browse the repository at this point in the history
…d wire in current edits
  • Loading branch information
dabreegster committed Nov 5, 2024
1 parent 98f9c2e commit 764a0da
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface Config<F, S> {

initializeEmptyScheme: (scheme: SchemeData) => SchemeData & S;

interventionWarning: (feature: FeatureWithID<F>) => string | null;
interventionWarning: (props: FeatureProps<F>) => string | null;

// When id is null, a new feature is being created
editFeatureForm: null | ComponentType<
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sidebar/EditFeatureForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Delete
</WarningButton>

<ErrorMessage errorMessage={cfg.interventionWarning(feature)} />
<ErrorMessage errorMessage={cfg.interventionWarning($featureProps)} />

<svelte:component
this={cfg.editFeatureForm}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/sidebar/PerSchemeControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$: numErrors = $gjSchemes.features.filter(
(f) =>
f.properties.scheme_reference == scheme_reference &&
cfg.interventionWarning(f) != null,
cfg.interventionWarning(f.properties) != null,
).length;
$: numFeatures = $gjSchemes.features.filter(
(f) => f.properties.scheme_reference == scheme_reference,
Expand Down Expand Up @@ -170,7 +170,7 @@

<ol class="govuk-list govuk-list--number">
{#each $gjSchemes.features.filter((f) => f.properties.scheme_reference == scheme_reference) as feature (feature.id)}
{@const warning = cfg.interventionWarning(feature)}
{@const warning = cfg.interventionWarning(feature.properties)}
<li>
<!-- svelte-ignore a11y-invalid-attribute -->
<a
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
return s;
},
interventionWarning: (feature) => null,
interventionWarning: (props) => null,
editFeatureForm: ExampleFeatureForm,
Expand Down

0 comments on commit 764a0da

Please sign in to comment.