diff --git a/lxl-web/src/lib/components/Search.svelte b/lxl-web/src/lib/components/Search.svelte index 94cc240c6..2f4951238 100644 --- a/lxl-web/src/lib/components/Search.svelte +++ b/lxl-web/src/lib/components/Search.svelte @@ -9,9 +9,11 @@ export let autofocus: boolean = false; $: showAdvanced = $page.url.searchParams.get('_x') === 'advanced'; - let q = showAdvanced - ? $page.url.searchParams.get('_q')?.trim() - : $page.url.searchParams.get('_i')?.trim(); + let q = $page.params.fnurgel + ? '' //don't reflect related search on resource pages + : showAdvanced + ? $page.url.searchParams.get('_q')?.trim() + : $page.url.searchParams.get('_i')?.trim(); let params = getSortedSearchParams(addDefaultSearchParams($page.url.searchParams)); // Always reset these params on new search @@ -22,10 +24,10 @@ const searchParams = Array.from(params); afterNavigate(({ to }) => { - /** Update input value after navigation */ + /** Update input value after navigation on /find route */ if (to?.url) { let param = showAdvanced ? '_q' : '_i'; - q = new URL(to.url).searchParams.get(param)?.trim(); + q = $page.params.fnurgel ? '' : new URL(to.url).searchParams.get(param)?.trim(); } }); @@ -48,7 +50,7 @@ type="search" name="_q" {placeholder} - aria-label="Sök" + aria-label={$page.data.t('search.search')} spellcheck="false" bind:value={q} {autofocus} diff --git a/lxl-web/src/lib/components/find/FacetRange.svelte b/lxl-web/src/lib/components/find/FacetRange.svelte index 69c1a1193..f2987adaa 100644 --- a/lxl-web/src/lib/components/find/FacetRange.svelte +++ b/lxl-web/src/lib/components/find/FacetRange.svelte @@ -53,7 +53,6 @@ bind:value={rangeTo} /> - diff --git a/lxl-web/src/lib/components/find/SearchRelated.svelte b/lxl-web/src/lib/components/find/SearchRelated.svelte new file mode 100644 index 000000000..2774f87bc --- /dev/null +++ b/lxl-web/src/lib/components/find/SearchRelated.svelte @@ -0,0 +1,42 @@ + + +
+ + + + + {#each searchParams as [name, value]} + {#if name !== '_i' && name !== '_q'} + + {/if} + {/each} + + +
diff --git a/lxl-web/src/lib/components/find/SearchResult.svelte b/lxl-web/src/lib/components/find/SearchResult.svelte index d58c45efb..d419e83f2 100644 --- a/lxl-web/src/lib/components/find/SearchResult.svelte +++ b/lxl-web/src/lib/components/find/SearchResult.svelte @@ -10,6 +10,7 @@ import BiChevronDown from '~icons/bi/chevron-down'; import type { SearchResult, DisplayMapping } from '$lib/types/search'; import { shouldShowMapping } from '$lib/utils/search'; + import SearchRelated from './SearchRelated.svelte'; let showFiltersModal = false; export let searchResult: SearchResult; @@ -108,6 +109,7 @@
+ {#if numHits > 0}
.toolbar { - display: grid; + @apply grid; grid-template-areas: - 'filter-modal-toggle sort-select' - 'hits hits'; + 'filter-modal-toggle .' + 'search-related search-related' + 'hits sort-select'; + } + + .toolbar.has-search { + @apply gap-4; } .find-layout { @@ -227,6 +240,19 @@ grid-area: hits; } + .search-related { + grid-area: search-related; + } + + @media screen and (min-width: theme('screens.sm')) { + .toolbar { + grid-template-areas: + 'filter-modal-toggle search-related' + 'hits sort-select'; + grid-template-columns: auto 1fr; + } + } + @media screen and (min-width: theme('screens.md')) { .filters { display: block; @@ -237,7 +263,9 @@ } .toolbar { - grid-template-areas: 'hits sort-select'; + grid-template-areas: + 'search-related search-related' + 'hits sort-select'; } } .tab-header { @@ -253,4 +281,11 @@ @apply border-primary pb-3.5; border-bottom-width: 0.125rem; } + + @media screen and (min-width: theme('screens.lg')) { + .toolbar { + grid-template-areas: 'hits search-related sort-select'; + grid-template-columns: auto minmax(auto, theme('screens.sm')) auto; + } + } diff --git a/lxl-web/src/lib/i18n/locales/en.js b/lxl-web/src/lib/i18n/locales/en.js index 5dcfee60e..da22eb366 100644 --- a/lxl-web/src/lib/i18n/locales/en.js +++ b/lxl-web/src/lib/i18n/locales/en.js @@ -90,7 +90,8 @@ export default { showFewer: 'Show fewer', showDetails: 'Show more', hideDetails: 'Show less', - occursAs: 'as' + occursAs: 'as', + relatedSearchLabel: 'Search the results' }, sort: { sort: 'Sort', diff --git a/lxl-web/src/lib/i18n/locales/sv.js b/lxl-web/src/lib/i18n/locales/sv.js index b739ef926..455e60b38 100644 --- a/lxl-web/src/lib/i18n/locales/sv.js +++ b/lxl-web/src/lib/i18n/locales/sv.js @@ -89,7 +89,8 @@ export default { showFewer: 'Visa färre', showDetails: 'Visa mer', hideDetails: 'Visa mindre', - occursAs: 'förekommer som' + occursAs: 'förekommer som', + relatedSearchLabel: 'Sök i resultaten' }, sort: { sort: 'Sortera', diff --git a/lxl-web/src/routes/(app)/[[lang=lang]]/[fnurgel=fnurgel]/+page.server.ts b/lxl-web/src/routes/(app)/[[lang=lang]]/[fnurgel=fnurgel]/+page.server.ts index f1167d2f7..3080344bd 100644 --- a/lxl-web/src/routes/(app)/[[lang=lang]]/[fnurgel=fnurgel]/+page.server.ts +++ b/lxl-web/src/routes/(app)/[[lang=lang]]/[fnurgel=fnurgel]/+page.server.ts @@ -90,7 +90,10 @@ export const load = async ({ params, url, locals, fetch, isDataRequest }) => { if (resourceId) { searchParams.set('_o', resourceId); - searchParams.set('_i', '*'); + + if (!searchParams.has('_i')) { + searchParams.set('_i', '*'); + } searchParams = getSortedSearchParams(addDefaultSearchParams(searchParams)); } @@ -108,8 +111,7 @@ export const load = async ({ params, url, locals, fetch, isDataRequest }) => { } } - // Hide zero results from resource page - if (result.totalItems > 0) { + if (result) { return (await asResult( result, displayUtil,