From 2ca9e98b885c0352769ec98059ab715d9ab8f96d Mon Sep 17 00:00:00 2001 From: simonredfern Date: Thu, 15 Oct 2026 11:00:11 +0200 Subject: [PATCH] Overlapping toggle button --- src/routes/registry/activities/+page.svelte | 59 ++++++++++++++++----- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/src/routes/registry/activities/+page.svelte b/src/routes/registry/activities/+page.svelte index c3ff518..f2f2762 100644 --- a/src/routes/registry/activities/+page.svelte +++ b/src/routes/registry/activities/+page.svelte @@ -72,10 +72,10 @@ (activity.activity_id && overlaps.get(activity.activity_id)) || []; /** - * The filtered activities that have an area to draw, for the map's quick list: - * overlapping ones first, then by name. + * The filtered activities that have an area to draw: overlapping ones first, then by + * name, as the map's quick list shows them. */ - const mapped = $derived( + const withArea = $derived( filtered .filter((a) => a.activity_id && data.areas[a.activity_id]) .sort( @@ -84,8 +84,22 @@ (a.name ?? '').localeCompare(b.name ?? '') ) ); - const overlappingCount = $derived(mapped.filter((a) => overlapsWith(a).length > 0).length); - const mappedCount = $derived(mapped.length); + const overlappingCount = $derived(withArea.filter((a) => overlapsWith(a).length > 0).length); + const mappedCount = $derived(withArea.length); + + /** Map view only: overlaps need the areas, which only the map view loads. */ + let overlap = $state('all'); + const overlapItems = [ + { value: 'all', label: 'All' }, + { value: 'overlapping', label: 'Overlapping' }, + { value: 'separate', label: 'Not overlapping' } + ]; + /** What the quick list and the map show, after the overlap toggle. */ + const mapped = $derived( + overlap === 'all' + ? withArea + : withArea.filter((a) => overlapsWith(a).length > 0 === (overlap === 'overlapping')) + ); let activitiesMap = $state>(); let focusedId = $state(null); @@ -98,7 +112,11 @@ } const filtersApplied = $derived( - search.trim() !== '' || creditType !== 'all' || country !== 'all' || status !== 'all' + search.trim() !== '' || + creditType !== 'all' || + country !== 'all' || + status !== 'all' || + overlap !== 'all' ); function clearFilters() { @@ -106,6 +124,7 @@ creditType = 'all'; country = 'all'; status = 'all'; + overlap = 'all'; } /** @@ -249,12 +268,20 @@ {/if} - {#if overlappingCount > 0} -

-

+ {#if overlappingCount > 0 || overlap !== 'all'} +
+

+

+ +
{/if} {#if mapped.length > 0}