Search: small fixes to UX, cleanup of console.Log

This commit is contained in:
Pieter Vander Vennet 2024-09-15 02:25:57 +02:00
parent 3e2027a366
commit b92b74df69
7 changed files with 22 additions and 15 deletions

View file

@ -110,12 +110,15 @@ export default class SearchState {
const { layer, filter, index } = payload
for (const [name, otherLayer] of state.layerState.filteredLayers) {
otherLayer.isDisplayed.setData(name === layer.id)
const layer = otherLayer.layerDef
if(!layer.isNormal()){
continue
}
otherLayer.isDisplayed.setData(payload.layer.id === layer.id)
}
const flayer = state.layerState.filteredLayers.get(layer.id)
flayer.isDisplayed.set(true)
const filtercontrol = flayer.appliedFilters.get(filter.id)
console.log("Could not apply", layer.id, ".", filter.id, index)
if (filtercontrol.data === index) {
filtercontrol.setData(undefined)
} else {
@ -136,6 +139,5 @@ export default class SearchState {
this.state.selectedElement.set(localElement)
return
}
console.log(">>>",feature)
}
}

View file

@ -24,7 +24,7 @@
{theme}
{state}
>
{#if $search && hasSelection && themes[0] === theme}
{#if $search && hasSelection && themes?.[0] === theme}
<span class="thanks hidden-on-mobile" aria-hidden="true">
<Tr t={Translations.t.general.morescreen.enterToOpen} />
</span>
@ -33,7 +33,7 @@
{/each}
</div>
{#if themes.length === 0}
{#if themes?.length === 0}
<NoThemeResultButton {search} />
{/if}
</section>

View file

@ -22,6 +22,9 @@
function enableAllLayers() {
for (const flayer of $nonactiveLayers) {
if (!flayer.layerDef.isNormal()) {
continue
}
flayer.isDisplayed.set(true)
}
}
@ -41,7 +44,7 @@
}
</script>
{#if activeFilters.length > 0 || $activeLayers.length === 1 || $nonactiveLayers.length > 0}
{#if activeFilters.length > 0 || $nonactiveLayers.length > 0}
<SidebarUnit>
<div class="flex justify-between">
<h3><Tr t={t.activeFilters}/></h3>

View file

@ -19,11 +19,13 @@
function apply() {
loading = true
console.log("Loading is now ", loading)
window.requestAnimationFrame(() => {
state.searchState.apply(entry)
loading = false
state.searchState.closeIfFullscreen()
})
setTimeout(() => {
window.requestAnimationFrame(() => {
state.searchState.apply(entry)
loading = false
state.searchState.closeIfFullscreen()
})
}, 25)
}
</script>
<button on:click={() => apply()} class:disabled={loading}>

View file

@ -25,7 +25,6 @@
descriptionTr = layer?.tagRenderings?.find(tr => tr.labels.indexOf("description") >= 0)
}
let dispatch = createEventDispatcher<{ select }>()
let distance = state.mapProperties.location.mapD(l => GeoOperations.distanceBetween([l.lon, l.lat], [entry.lon, entry.lat]))
let bearing = state.mapProperties.location.mapD(l => GeoOperations.bearing([l.lon, l.lat], [entry.lon, entry.lat]))
let mapRotation = state.mapProperties.rotation
@ -55,7 +54,7 @@
<button class="unstyled w-full link-no-underline searchresult" on:click={() => select() }>
<div class="p-2 flex items-center w-full gap-y-2">
{#if layer}
<ToSvelte construct={() => layer.defaultIcon(entry.feature.properties).SetClass("w-6 h-6")} />
<ToSvelte construct={() => layer.defaultIcon(entry.feature.properties)?.SetClass("w-6 h-6")} />
{:else if entry.category}
<Icon icon={GeocodingUtils.categoryToIcon[entry.category]} clss="w-6 h-6 shrink-0" color="#aaa" />
{/if}

View file

@ -11,7 +11,9 @@
import Translations from "../i18n/Translations"
export let state: ThemeViewState
let activeFilters: Store<ActiveFilter[]> = state.layerState.activeFilters.map(fs => fs.filter(f => Constants.priviliged_layers.indexOf(<any>f.layer.id) < 0))
let activeFilters: Store<ActiveFilter[]> = state.layerState.activeFilters.map(fs => fs.filter(f =>
(f.filter.options[0].fields.length === 0) &&
Constants.priviliged_layers.indexOf(<any>f.layer.id) < 0))
let allowOtherThemes = state.featureSwitches.featureSwitchBackToThemeOverview
let searchTerm = state.searchState.searchTerm
</script>

View file

@ -1123,7 +1123,6 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be
): Promise<{ content: T } | { error: string; url: string; statuscode?: number }> {
const injected = Utils.injectedDownloads[url]
if (injected !== undefined) {
console.debug("Using injected resource for test for URL", url)
return { content: injected }
}
const result = await Utils.downloadAdvanced(