-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LWS-143: Related hits search (#1059)
Adds a search input in the toolbar section for the related search result * Added component SearchRelated that searches in the context of the current _o and _p. * Zero results for the related search is no longer hidden, as it can now happen as a result of an active search. * Some modifications to 'main search' to stay independent of related search. TODO * Searching completely clears any existing filters, due to frontends inability to modify _q param in a safe way. If we need to keep the filters, maybe template links (such as in year range) could be a solution. --------- Co-authored-by: Johan Bisse Mattsson <bisse.mattsson@kb.se>
- Loading branch information
1 parent
5109c74
commit eb5819b
Showing
7 changed files
with
98 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script lang="ts"> | ||
import BiSearch from '~icons/bi/search'; | ||
import { page } from '$app/stores'; | ||
import type { Link } from '$lib/utils/xl'; | ||
export let view: Link; | ||
let _i = $page.url.searchParams.get('_i')?.trim() || ''; | ||
let url = new URL($page.url.origin + view['@id']); | ||
let searchParams = new URLSearchParams(url.search); | ||
searchParams.set('_sort', $page.url.searchParams.get('_sort')?.trim() || ''); | ||
function handleSubmit() { | ||
if (!_i) { | ||
_i = '*'; | ||
} | ||
} | ||
</script> | ||
|
||
<form action="" on:submit={handleSubmit} class="flex w-full gap-2 lg:max-w-xl"> | ||
<label for="search-related" class="sr-only">{$page.data.t('search.relatedSearchLabel')}</label> | ||
<input | ||
class="flex-1" | ||
id="search-related" | ||
type="search" | ||
placeholder={$page.data.t('search.relatedSearchLabel')} | ||
bind:value={_i} | ||
/> | ||
<button class="button-primary" type="submit"> | ||
<BiSearch fill="currentColor" aria-hidden="true" /> | ||
<span class="sr-only sm:not-sr-only">{$page.data.t('search.search')}</span> | ||
</button> | ||
|
||
{#each searchParams as [name, value]} | ||
{#if name !== '_i' && name !== '_q'} | ||
<input type="hidden" {name} {value} /> | ||
{/if} | ||
{/each} | ||
<input type="hidden" name="_i" value={_i} /> | ||
<input type="hidden" name="_q" value={_i} /> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters