2024-08-26 13:09:46 +02:00
|
|
|
<script lang="ts">
|
2024-08-30 02:18:29 +02:00
|
|
|
import { Store } from "../../Logic/UIEventSource"
|
2024-08-26 13:09:46 +02:00
|
|
|
import Loading from "../Base/Loading.svelte"
|
|
|
|
import Tr from "../Base/Tr.svelte"
|
|
|
|
import Translations from "../i18n/Translations"
|
|
|
|
import { default as SearchResultSvelte } from "./SearchResult.svelte"
|
|
|
|
import MoreScreen from "../BigComponents/MoreScreen"
|
2024-08-30 02:18:29 +02:00
|
|
|
import type { GeocodeResult } from "../../Logic/Geocoding/GeocodingProvider"
|
|
|
|
|
2024-08-26 13:09:46 +02:00
|
|
|
import ActiveFilters from "./ActiveFilters.svelte"
|
2024-08-26 17:24:12 +02:00
|
|
|
import Constants from "../../Models/Constants"
|
|
|
|
import type { ActiveFilter } from "../../Logic/State/LayerState"
|
2024-08-30 02:18:29 +02:00
|
|
|
import ThemeViewState from "../../Models/ThemeViewState"
|
|
|
|
import FilterResult from "./FilterResult.svelte"
|
|
|
|
import ThemeResult from "./ThemeResult.svelte"
|
2024-08-26 13:09:46 +02:00
|
|
|
|
2024-08-30 02:18:29 +02:00
|
|
|
export let state: ThemeViewState
|
2024-08-26 17:24:12 +02:00
|
|
|
let activeFilters: Store<ActiveFilter[]> = state.layerState.activeFilters.map(fs => fs.filter(f => Constants.priviliged_layers.indexOf(<any>f.layer.id) < 0))
|
2024-08-30 02:18:29 +02:00
|
|
|
let recentlySeen: Store<GeocodeResult[]> = state.searchState.recentlySearched.seenThisSession
|
2024-08-26 13:09:46 +02:00
|
|
|
let recentThemes = state.userRelatedState.recentlyVisitedThemes.mapD(thms => thms.filter(th => th !== state.layout.id).slice(0, 3))
|
|
|
|
let allowOtherThemes = state.featureSwitches.featureSwitchBackToThemeOverview
|
2024-08-30 02:18:29 +02:00
|
|
|
let searchTerm = state.searchState.searchTerm
|
|
|
|
let results = state.searchState.suggestions
|
|
|
|
let filterResults = state.searchState.filterSuggestions
|
|
|
|
let themeResults = state.searchState.themeSuggestions
|
|
|
|
|
2024-08-26 13:09:46 +02:00
|
|
|
</script>
|
2024-08-30 02:18:29 +02:00
|
|
|
<div class="p-4">
|
2024-08-26 13:09:46 +02:00
|
|
|
|
2024-08-30 02:18:29 +02:00
|
|
|
<ActiveFilters activeFilters={$activeFilters} />
|
|
|
|
|
|
|
|
{#if $filterResults.length > 0}
|
|
|
|
<h3>Pick a filter below</h3>
|
|
|
|
|
|
|
|
<div class="flex flex-wrap">
|
|
|
|
{#each $filterResults as filterResult (filterResult)}
|
|
|
|
<FilterResult {state} entry={filterResult} />
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
{/if}
|
2024-08-26 13:09:46 +02:00
|
|
|
|
2024-08-30 02:18:29 +02:00
|
|
|
{#if $searchTerm.length > 0}
|
|
|
|
<h3>Locations</h3>
|
|
|
|
{/if}
|
|
|
|
{#if $searchTerm.length > 0 && $results === undefined}
|
|
|
|
<div class="flex justify-center m-4 my-8">
|
|
|
|
<Loading />
|
|
|
|
</div>
|
|
|
|
{:else if $results?.length > 0}
|
|
|
|
{#each $results as entry (entry)}
|
|
|
|
<SearchResultSvelte on:select {entry} {state} />
|
|
|
|
{/each}
|
|
|
|
{:else if $searchTerm.length > 0 || $recentlySeen?.length > 0 || $recentThemes?.length > 0}
|
|
|
|
<div class="flex flex-col gap-y-8"
|
|
|
|
tabindex="-1">
|
|
|
|
{#if $searchTerm.length > 0}
|
|
|
|
<b class="flex justify-center p-4">
|
|
|
|
<Tr t={Translations.t.general.search.nothingFor.Subs({term: $searchTerm})} />
|
|
|
|
</b>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if $recentlySeen?.length > 0}
|
|
|
|
<div>
|
|
|
|
<h3 class="m-2">
|
|
|
|
<Tr t={Translations.t.general.search.recents} />
|
|
|
|
</h3>
|
|
|
|
{#each $recentlySeen as entry}
|
|
|
|
<SearchResultSvelte {entry} {state} on:select />
|
2024-08-26 13:09:46 +02:00
|
|
|
{/each}
|
|
|
|
</div>
|
2024-08-30 02:18:29 +02:00
|
|
|
{/if}
|
2024-08-26 13:09:46 +02:00
|
|
|
|
2024-08-30 02:18:29 +02:00
|
|
|
{#if $recentThemes?.length > 0 && $allowOtherThemes}
|
|
|
|
<div>
|
|
|
|
<h3 class="m-2">
|
|
|
|
<Tr t={Translations.t.general.search.recentThemes} />
|
|
|
|
</h3>
|
|
|
|
{#each $recentThemes as themeId (themeId)}
|
|
|
|
<SearchResultSvelte
|
|
|
|
entry={{payload: MoreScreen.officialThemesById.get(themeId), osm_id: themeId, category: "theme"}}
|
|
|
|
{state}
|
|
|
|
on:select />
|
|
|
|
{/each}
|
2024-08-26 13:09:46 +02:00
|
|
|
</div>
|
|
|
|
{/if}
|
2024-08-30 02:18:29 +02:00
|
|
|
</div>
|
|
|
|
{/if}
|
2024-08-26 13:09:46 +02:00
|
|
|
|
|
|
|
|
2024-08-30 02:18:29 +02:00
|
|
|
{#if $themeResults.length > 0}
|
|
|
|
<h3>
|
|
|
|
Other maps
|
|
|
|
</h3>
|
|
|
|
{#each $themeResults as entry}
|
|
|
|
<ThemeResult {state} {entry} />
|
|
|
|
{/each}
|
|
|
|
{/if}
|
2024-08-26 13:09:46 +02:00
|
|
|
|
2024-08-30 02:18:29 +02:00
|
|
|
</div>
|