Skip to content

Commit

Permalink
Tweak display of layers
Browse files Browse the repository at this point in the history
  • Loading branch information
janbaykara committed Mar 11, 2024
1 parent 0987b7c commit 9ab38e8
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 153 deletions.
101 changes: 14 additions & 87 deletions nextjs/src/components/SelectSourceData.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,13 @@
import * as React from "react";
import {
Calendar,
MoreHorizontal,
Tags,
Trash,
User,
Database,
} from "lucide-react";

import { Button } from "@/components/ui/button";
import {
Command,
CommandDialog,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
CommandList
} from "@/components/ui/command"
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { EnrichmentDataSource, SourcePath } from "@/lib/data";
import { AutoUpdateConfig } from "@/__generated__/graphql";

Expand Down Expand Up @@ -81,7 +48,7 @@ export function SourcePathSelector({
{source.sourcePaths.map((sourcePath) => (
<CommandItem
key={val(sourcePath)}
value={val(sourcePath)}
value={label(sourcePath)}
onSelect={() => {
setValue(
source.slug,
Expand All @@ -90,64 +57,20 @@ export function SourcePathSelector({
setOpen(false);
}}
>
{label(sourcePath)}
<div>
<div>{label(sourcePath)}</div>
{!!description(sourcePath) && (
<div className="text-xs opacity-70">
{description(sourcePath)}
</div>
)}
</div>
</CommandItem>
))}
</CommandGroup>
))}
</CommandList>
</CommandDialog>
{/*
<Sheet>
<SheetTrigger>
{value && value.source && value.sourcePath
? `${value.source}: ${value.sourcePath}`
: "Select data"}
</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle>Select data</SheetTitle>
<SheetDescription>
{sources.map((source) => (
<DropdownMenuSub key={source.slug}>
<DropdownMenuSubTrigger>
<Database className="mr-2 h-4 w-4" />
{source.name || source.slug}
</DropdownMenuSubTrigger>
<DropdownMenuSubContent className="p-0">
<Command>
<CommandInput
placeholder="Filter available data..."
autoFocus={true}
/>
<CommandList>
<CommandEmpty>No data found.</CommandEmpty>
<CommandGroup>
{source.sourcePaths.map((sourcePath) => (
<CommandItem
key={val(sourcePath)}
value={val(sourcePath)}
onSelect={() => {
setValue(
source.slug,
val(sourcePath),
);
setOpen(false);
}}
>
{label(sourcePath)}
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</DropdownMenuSubContent>
</DropdownMenuSub>
))}
</SheetDescription>
</SheetHeader>
</SheetContent>
</Sheet> */}
</div>
);
}
Expand All @@ -158,4 +81,8 @@ function label(d: SourcePath) {

function val(d: SourcePath) {
return typeof d === "string" ? d : d.value;
}

function description(d: SourcePath) {
return typeof d === "string" ? "" : d.description;
}
2 changes: 1 addition & 1 deletion nextjs/src/components/ui/command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const CommandItem = React.forwardRef<
<CommandPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-meepGray-700 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className,
)}
{...props}
Expand Down
130 changes: 65 additions & 65 deletions nextjs/src/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,40 +45,52 @@ export const enrichmentDataSources: Array<EnrichmentDataSource> = [
builtIn: true,
sourcePaths: [
{
value: "postcode",
label: "Postcode",
value: "parliamentary_constituency_2025",
label: "GE2024 Westminster Parliamentary Constituency",
description:
"All current (‘live’) postcodes within the United Kingdom, the Channel Islands and the Isle of Man, received monthly from Royal Mail. 2, 3 or 4-character outward code, single space and 3-character inward code.",
"The Westminster Parliamentary Constituency code for each postcode.",
},
{
value: "outcode",
label: "Outward Code",
value: "parliamentary_constituency",
label: "GE2019 Westminster Parliamentary Constituency",
description:
'The outward code is the part of the postcode before the single space in the middle. It is between two and four characters long. A few outward codes are non-geographic, not divulging where mail is to be sent. Examples of outward codes include "L1", "W1A", "RH1", "RH10" or "SE1P".',
"The Westminster Parliamentary Constituency code for each postcode.",
},
{
value: "incode",
label: "Inward Code",
value: "admin_district",
label: "District (Council/Local Authority)",
description:
'The inward part is the part of the postcode after the single space in the middle. It is three characters long. The inward code assists in the delivery of post within a postal district. Examples of inward codes include "0NY", "7GZ", "7HF", or "8JQ".',
"The current district/unitary authority to which the postcode has been assigned.",
},
{
value: "quality",
label: "Positional Quality",
value: "admin_ward",
label: "Ward",
description:
"Shows the status of the assigned grid reference. 1 = within the building of the matched address closest to the postcode mean 2 = as for status value 1, except by visual inspection of Landline maps (Scotland only) 3 = approximate to within 50m 4 = postcode unit mean (mean of matched addresses with the same postcode, but not snapped to a building) 5 = imputed by ONS, by reference to surrounding postcode grid references 6 = postcode sector mean, (mainly | PO Boxes) 8 = postcode terminated prior to Gridlink® initiative, last known ONS postcode grid reference1 9 = no grid reference available",
"The current administrative/electoral area to which the postcode has been assigned.",
},
{
value: "eastings",
label: "Eastings",
value: "postcode",
label: "Postcode",
description:
"The Ordnance Survey postcode grid reference Easting to 1 metre resolution. Grid references for postcodes in Northern Ireland relate to the Irish Grid system. May be null if geolocation not available.",
"All current (‘live’) postcodes within the United Kingdom, the Channel Islands and the Isle of Man, received monthly from Royal Mail. 2, 3 or 4-character outward code, single space and 3-character inward code.",
},
{
value: "northings",
label: "Northings",
value: "parish",
label: "Parish (England)/community (Wales)",
description:
"The Ordnance Survey postcode grid reference Northing to 1 metre resolution. Grid references for postcodes in Northern Ireland relate to the Irish Grid system. May be null if geolocation not available.",
"The smallest type of administrative area in England is the parish (also known as 'civil parish'); the equivalent units in Wales are communities.",
},
{
value: "admin_county",
label: "County",
description:
"The current county to which the postcode has been assigned.",
},
{
value: "region",
label: "Region (formerly GOR)",
description:
"The Region code for each postcode. The nine GORs were abolished on 1 April 2011 and are now known as ‘Regions’. They were the primary statistical subdivisions of England and also the areas in which the Government Offices for the Regions fulfilled their role. Each GOR covered a number of local authorities.",
},
{
value: "country",
Expand All @@ -92,69 +104,70 @@ export const enrichmentDataSources: Array<EnrichmentDataSource> = [
description: "The health area code for the postcode.",
},
{
value: "admin_county",
label: "County",
value: "primary_care_trust",
label: "Primary Care Trust (PCT)",
description:
"The current county to which the postcode has been assigned.",
"The code for the Primary Care areas in England, LHBs in Wales, CHPs in Scotland, LCG in Northern Ireland and PHD in the Isle of Man; there are no equivalent areas in the Channel Islands. Care Trust/ Care Trust Plus (CT)/ local health board (LHB)/ community health partnership (CHP)/ local commissioning group (LCG)/ primary healthcare directorate (PHD).",
},
{
value: "admin_district",
label: "District",
value: "ccg",
label:
"Sub ICB Location (LOC)/ Local Health Board (LHB)/ Community Health Partnership (CHP)/ Local Commissioning Group (LCG)/ Primary Healthcare Directorate (PHD)",
description:
"The current district/unitary authority to which the postcode has been assigned.",
". The code for the Sub ICB Locations in England, LHBs in Wales, CHPs in Scotland, LCG in Northern Ireland and PHD in the Isle of Man; there are no equivalent areas in the Channel Islands. This was formerly Clinical Commissioning Group. From July 2022, CCGs were replaced by Sub-ICB locations.",
},
{
value: "admin_ward",
label: "Ward",
value: "ced",
label: "County Electoral District",
description:
"The current administrative/electoral area to which the postcode has been assigned.",
"The county electoral division code for each English postcode. Pseudo codes are included for the remainder of the UK. The field will be null for English postcodes with no grid reference. English county councils use county electoral divisions (CED) to elect councillors. These CEDs must be confined within district boundaries, but need not be based on whole electoral wards. The only exceptions are the Isles of Scilly and the Greater London Authority (GLA). CEDs do not exist within UAs.",
},
{
value: "longitude",
label: "Longitude",
value: "outcode",
label: "Outward Code",
description:
"The WGS84 longitude given the Postcode's national grid reference. May be null if geolocation not available.",
'The outward code is the part of the postcode before the single space in the middle. It is between two and four characters long. A few outward codes are non-geographic, not divulging where mail is to be sent. Examples of outward codes include "L1", "W1A", "RH1", "RH10" or "SE1P".',
},
{
value: "latitude",
label: "Latitude",
value: "incode",
label: "Inward Code",
description:
"The WGS84 latitude given the Postcode's national grid reference. May be null if geolocation not available.",
'The inward part is the part of the postcode after the single space in the middle. It is three characters long. The inward code assists in the delivery of post within a postal district. Examples of inward codes include "0NY", "7GZ", "7HF", or "8JQ".',
},
{
value: "parliamentary_constituency",
label: "Westminster Parliamentary Constituency",
value: "quality",
label: "Positional Quality",
description:
"The Westminster Parliamentary Constituency code for each postcode.",
"Shows the status of the assigned grid reference. 1 = within the building of the matched address closest to the postcode mean 2 = as for status value 1, except by visual inspection of Landline maps (Scotland only) 3 = approximate to within 50m 4 = postcode unit mean (mean of matched addresses with the same postcode, but not snapped to a building) 5 = imputed by ONS, by reference to surrounding postcode grid references 6 = postcode sector mean, (mainly | PO Boxes) 8 = postcode terminated prior to Gridlink® initiative, last known ONS postcode grid reference1 9 = no grid reference available",
},
{
value: "parliamentary_constituency_2025",
label: "GE2024 Westminster Parliamentary Constituency",
value: "eastings",
label: "Eastings",
description:
"The Westminster Parliamentary Constituency code for each postcode.",
"The Ordnance Survey postcode grid reference Easting to 1 metre resolution. Grid references for postcodes in Northern Ireland relate to the Irish Grid system. May be null if geolocation not available.",
},
{
value: "european_electoral_region",
label: "European Electoral Region (EER)",
description: "The European Electoral Region code for each postcode.",
value: "northings",
label: "Northings",
description:
"The Ordnance Survey postcode grid reference Northing to 1 metre resolution. Grid references for postcodes in Northern Ireland relate to the Irish Grid system. May be null if geolocation not available.",
},
{
value: "primary_care_trust",
label: "Primary Care Trust (PCT)",
value: "longitude",
label: "Longitude",
description:
"The code for the Primary Care areas in England, LHBs in Wales, CHPs in Scotland, LCG in Northern Ireland and PHD in the Isle of Man; there are no equivalent areas in the Channel Islands. Care Trust/ Care Trust Plus (CT)/ local health board (LHB)/ community health partnership (CHP)/ local commissioning group (LCG)/ primary healthcare directorate (PHD).",
"The WGS84 longitude given the Postcode's national grid reference. May be null if geolocation not available.",
},
{
value: "region",
label: "Region (formerly GOR)",
value: "latitude",
label: "Latitude",
description:
"The Region code for each postcode. The nine GORs were abolished on 1 April 2011 and are now known as ‘Regions’. They were the primary statistical subdivisions of England and also the areas in which the Government Offices for the Regions fulfilled their role. Each GOR covered a number of local authorities.",
"The WGS84 latitude given the Postcode's national grid reference. May be null if geolocation not available.",
},
{
value: "parish",
label: "Parish (England)/community (Wales)",
description:
"The smallest type of administrative area in England is the parish (also known as 'civil parish'); the equivalent units in Wales are communities.",
value: "european_electoral_region",
label: "European Electoral Region (EER)",
description: "The European Electoral Region code for each postcode.",
},
{
value: "lsoa",
Expand All @@ -168,19 +181,6 @@ export const enrichmentDataSources: Array<EnrichmentDataSource> = [
description:
"The 2011 Census middle layer SOA (MSOA) code for England and Wales and intermediate zone for Scotland.",
},
{
value: "ced",
label: "County Electoral District",
description:
"The county electoral division code for each English postcode. Pseudo codes are included for the remainder of the UK. The field will be null for English postcodes with no grid reference. English county councils use county electoral divisions (CED) to elect councillors. These CEDs must be confined within district boundaries, but need not be based on whole electoral wards. The only exceptions are the Isles of Scilly and the Greater London Authority (GLA). CEDs do not exist within UAs.",
},
{
value: "ccg",
label:
"Sub ICB Location (LOC)/ Local Health Board (LHB)/ Community Health Partnership (CHP)/ Local Commissioning Group (LCG)/ Primary Healthcare Directorate (PHD)",
description:
". The code for the Sub ICB Locations in England, LHBs in Wales, CHPs in Scotland, LCG in Northern Ireland and PHD in the Isle of Man; there are no equivalent areas in the Channel Islands. This was formerly Clinical Commissioning Group. From July 2022, CCGs were replaced by Sub-ICB locations.",
},
{
value: "nuts",
label:
Expand Down

0 comments on commit 9ab38e8

Please sign in to comment.