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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,9 @@
import Translations from "../i18n/Translations" import Translations from "../i18n/Translations"
export let state: ThemeViewState 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 allowOtherThemes = state.featureSwitches.featureSwitchBackToThemeOverview
let searchTerm = state.searchState.searchTerm let searchTerm = state.searchState.searchTerm
</script> </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 }> { ): Promise<{ content: T } | { error: string; url: string; statuscode?: number }> {
const injected = Utils.injectedDownloads[url] const injected = Utils.injectedDownloads[url]
if (injected !== undefined) { if (injected !== undefined) {
console.debug("Using injected resource for test for URL", url)
return { content: injected } return { content: injected }
} }
const result = await Utils.downloadAdvanced( const result = await Utils.downloadAdvanced(