11<script lang =" ts" >
22 import RestrictionRow from ' ./RestrictionRow.svelte' ;
33 import { restrictionFilters } from ' $lib/state.svelte' ;
4+ import RestrictionSection from ' ./RestrictionSection.svelte' ;
5+ import FilterPanel from ' ./FilterPanel.svelte' ;
46
57 const { data } = $props ();
68
1315 map .set (airport , []);
1416 }
1517
16- if (restrictionFilters .areas .length === 0
17- || (restrictionFilters .areas .includes (restriction .to )
18- || restrictionFilters .areas .includes (restriction .from ))) {
18+ const noAreaSelected = restrictionFilters .areas .length === 0 ;
19+ const searchIsEmpty = restrictionFilters .airport === ' ' ;
20+ const areaMatches = restrictionFilters .areas .includes (restriction .from ) || (restrictionFilters .includeIncoming && restrictionFilters .areas .includes (restriction .to ));
21+ const searchMatches = restriction .airport .toLowerCase ().includes (restrictionFilters .airport .toLowerCase ());
22+
23+ const isAreaMatch = noAreaSelected || areaMatches ;
24+ const isSearchMatch = searchMatches || searchIsEmpty ;
25+
26+ if (isAreaMatch && isSearchMatch ) {
1927 map .get (airport ).push (restriction );
2028 }
2129 });
2937
3038 return map ;
3139 });
32-
33- const areas = [
34- ' Area 1' ,
35- ' Area 2' ,
36- ' Area 3' ,
37- ' Area 4' ,
38- ' Area 5' ,
39- ' Area 6' ,
40- ' Area 7'
41- ];
42-
43- function toggleAreaFilter(area : string ) {
44- if (restrictionFilters .areas .includes (area )) {
45- restrictionFilters .areas = restrictionFilters .areas .filter (a => a !== area );
46- } else {
47- restrictionFilters .areas .push (area );
48- }
49- }
5040 </script >
5141
5242<svelte:head >
5343 <title >ICCT - Restrictions</title >
5444</svelte:head >
55- <h2 >Filters</h2 >
56- <div class =" flex gap-2" >
57- {#each areas .filter ((a ) => a && a .includes (' Area' )) as area }
58- <button class =" px-2 py-1 rounded-md border border-b-zinc-200"
59- class:bg-zinc- 200={restrictionFilters .areas .includes (area )}
60- onclick =" {() => toggleAreaFilter (area )}" >{area }</button >
61- {/each }
62- </div >
45+ <FilterPanel />
6346<div class =" w-full" >
6447 {#each restrictions as [airport, r]}
65- <div class =" w-full flex mb-2 p-2" >
66- <div class ="w-32 text-left mr-4 font-medium border rounded-md p-2 bg-gray-700 text-white" >{airport }</div >
67- <div class =" flex-grow flex flex-col" >
68- <div class =" flex border-b border-b-zinc-400 font-medium" >
69- <div class =" w-5/12" >Route</div >
70- <div class =" w-1/12" >From</div >
71- <div class =" w-1/12" >To</div >
72- <div class =" w-3/12" >Restriction</div >
73- <div class =" w-2/12" >Notes</div >
74- </div >
75- {#each r as restriction }
76- <RestrictionRow {restriction } />
77- {/each }
78- </div >
79- </div >
48+ <RestrictionSection {airport } restrictions ={r } />
8049 {/each }
8150</div >
0 commit comments