Skip to content

Commit

Permalink
NPM run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter York committed Oct 31, 2023
1 parent 78a9f8d commit 2447f11
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 26 deletions.
12 changes: 9 additions & 3 deletions src/lib/govuk/TextInput.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { createEventDispatcher } from "svelte";
import FormElement from "./FormElement.svelte";
export let label: string;
Expand All @@ -9,10 +9,16 @@
const dispatch = createEventDispatcher();
function forwardEvent(e: any) {
dispatch('change', e.target.value);
dispatch("change", e.target.value);
}
</script>

<FormElement {label} id={label}>
<input type="text" class="govuk-input" id={label} bind:value on:change={forwardEvent} />
<input
type="text"
class="govuk-input"
id={label}
bind:value
on:change={forwardEvent}
/>
</FormElement>
2 changes: 1 addition & 1 deletion src/lib/sidebar/EditForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ATF4Form from "lib/forms/ATF4Form.svelte";
import FormV1 from "lib/forms/FormV1.svelte";
import FormV2 from "lib/forms/FormV2.svelte";
import PipelineForm from "lib/forms/PipelineForm.svelte";
import PlanningForm from "lib/forms/PlanningForm.svelte";
import {
ButtonGroup,
Expand All @@ -16,7 +17,6 @@
import type { FeatureUnion, Schema } from "types";
import { interventionName, interventionWarning } from "./scheme_data";
import UnexpectedProperties from "./UnexpectedProperties.svelte";
import PipelineForm from "lib/forms/PipelineForm.svelte";
// TODO Should this just be in a store?
export let schema: Schema;
Expand Down
41 changes: 30 additions & 11 deletions src/lib/sidebar/EntireSubscheme.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<script lang="ts">
import { feature } from "@turf/helpers";
import { CollapsibleCard, Modal } from "lib/common";
import { ButtonGroup, ErrorMessage, SecondaryButton, TextInput, WarningButton } from "lib/govuk";
import {
ButtonGroup,
ErrorMessage,
SecondaryButton,
TextInput,
WarningButton,
} from "lib/govuk";
import { gjScheme, mode } from "stores";
import { onMount } from "svelte";
import type { FeatureUnion, Scheme, Subscheme } from "types";
import ListedIntervention from "./ListedIntervention.svelte";
import { interventionWarning } from "./scheme_data";
import { feature } from "@turf/helpers";
export let subscheme: Subscheme;
export let superscheme: Scheme;
Expand All @@ -23,16 +29,22 @@
});
});
function deleteSubscheme () {
function deleteSubscheme() {
displayDeleteConfirmation = false;
const clonedScheme = JSON.parse(JSON.stringify($gjScheme));
clonedScheme.features = clonedScheme.features.filter((feature: FeatureUnion) =>{
return feature.properties.pipelineIntervention?.schemeId !== subscheme.id
});
clonedScheme.subschemes = clonedScheme.subschemes?.filter((thatSubscheme: Subscheme) => {
return thatSubscheme.id !== subscheme.id;
});
gjScheme.set(clonedScheme);
clonedScheme.features = clonedScheme.features.filter(
(feature: FeatureUnion) => {
return (
feature.properties.pipelineIntervention?.schemeId !== subscheme.id
);
}
);
clonedScheme.subschemes = clonedScheme.subschemes?.filter(
(thatSubscheme: Subscheme) => {
return thatSubscheme.id !== subscheme.id;
}
);
gjScheme.set(clonedScheme);
}
</script>

Expand All @@ -53,7 +65,14 @@
>
<p>This will delete all its interventions.</p>
<ButtonGroup>
<WarningButton on:click={() => {console.log("hello"); deleteSubscheme();}}>Delete this subscheme and related interventions</WarningButton>
<WarningButton
on:click={() => {
console.log("hello");
deleteSubscheme();
}}
>
Delete this subscheme and related interventions
</WarningButton>
<SecondaryButton on:click={() => (displayDeleteConfirmation = false)}>
Cancel
</SecondaryButton>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/sidebar/ListedIntervention.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import bbox from "@turf/bbox";
import { WarningIcon } from "lib/common";
import { gjScheme, map, mode, sidebarHover } from "stores";
import type { FeatureUnion, Schema } from "types";
import { interventionName } from "./scheme_data";
import { WarningIcon } from "lib/common";
import { interventionName } from "./scheme_data";
export let schema: Schema;
export let feature: FeatureUnion;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/sidebar/PipelineListMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
return (schemeNameChangeEvent: any) => {
console.log(schemeNameChangeEvent);
const newSchemeName = schemeNameChangeEvent.detail;
console.log(newSchemeName )
console.log(newSchemeName);
$gjScheme.subschemes = $gjScheme.subschemes?.map((subscheme) => {
if (subscheme.name === originalSchemeName) {
subscheme.name = newSchemeName;
Expand Down
21 changes: 15 additions & 6 deletions src/lib/sidebar/scheme_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export function backfill(json: Scheme) {
return json;
}

export function backfillSuperscheme(json: Scheme, authorityName?: string): Scheme {
export function backfillSuperscheme(
json: Scheme,
authorityName?: string
): Scheme {
let idCounter = 1;
for (let f of json.features) {
// Fix input from other tools where properties may be null
Expand All @@ -45,13 +48,19 @@ export function backfillSuperscheme(json: Scheme, authorityName?: string): Schem
}

if (!json.scheme_name) {
json.scheme_name = authorityName ? `${authorityName} LCWIP` : "Untitled Supserscheme";
json.scheme_name = authorityName
? `${authorityName} LCWIP`
: "Untitled Supserscheme";
}

json.subschemes = json.subschemes ? json.subschemes : [{
id: 0,
name: "Untitled Subscheme",
}];
json.subschemes = json.subschemes
? json.subschemes
: [
{
id: 0,
name: "Untitled Subscheme",
},
];

return json;
}
Expand Down
3 changes: 1 addition & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export interface Scheme {
export interface Subscheme {
id: number;
name: string;

}

// TODO Can we use a wildcard type, like Feature<? extends Geometry>
Expand Down Expand Up @@ -55,7 +54,7 @@ export interface InterventionProps {
planning?: Planning;
v2?: Intervention;
atf4?: ATF4Intervention;
pipelineIntervention?: PipelineIntervention;
pipelineIntervention?: PipelineIntervention;
// An extra field present in input for the browse schemes page only
scheme_reference?: string;

Expand Down

0 comments on commit 2447f11

Please sign in to comment.