fix(web): preserve search text (#12531)

This commit is contained in:
Jason Rasmussen 2024-09-09 23:49:56 -04:00 committed by GitHub
parent 6674d67abe
commit 710cbd694b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 36 deletions

View file

@ -2,46 +2,25 @@
import RadioButton from '$lib/components/elements/radio-button.svelte';
import { t } from 'svelte-i18n';
export let filename: string | undefined;
export let context: string | undefined;
enum TextSearchOptions {
Context = 'context',
Filename = 'filename',
}
let selectedOption = filename ? TextSearchOptions.Filename : TextSearchOptions.Context;
$: {
if (selectedOption === TextSearchOptions.Context) {
filename = undefined;
} else {
context = undefined;
}
}
export let query: string | undefined;
export let queryType: 'smart' | 'metadata' = 'smart';
</script>
<fieldset>
<legend class="immich-form-label">{$t('search_type')}</legend>
<div class="flex flex-wrap gap-x-5 gap-y-2 mt-1 mb-2">
<RadioButton
name="query-type"
id="context-radio"
bind:group={selectedOption}
label={$t('context')}
value={TextSearchOptions.Context}
/>
<RadioButton name="query-type" id="context-radio" label={$t('context')} bind:group={queryType} value="smart" />
<RadioButton
name="query-type"
id="file-name-radio"
bind:group={selectedOption}
label={$t('file_name_or_extension')}
value={TextSearchOptions.Filename}
bind:group={queryType}
value="metadata"
/>
</div>
</fieldset>
{#if selectedOption === TextSearchOptions.Context}
{#if queryType === 'smart'}
<label for="context-input" class="immich-form-label">{$t('search_by_context')}</label>
<input
class="immich-form-input hover:cursor-text w-full !mt-1"
@ -49,7 +28,7 @@
id="context-input"
name="context"
placeholder={$t('sunrise_on_the_beach')}
bind:value={context}
bind:value={query}
/>
{:else}
<label for="file-name-input" class="immich-form-label">{$t('search_by_filename')}</label>
@ -59,7 +38,7 @@
id="file-name-input"
name="file-name"
placeholder={$t('search_by_filename_example')}
bind:value={filename}
bind:value={query}
aria-labelledby="file-name-label"
/>
{/if}