- remove if-tags from around search-albums-section

- Add translation to remove filter button tooltip
This commit is contained in:
CJPeckover
2025-06-09 23:21:04 -04:00
parent 2ab176d16c
commit 2d921a2756
2 changed files with 51 additions and 53 deletions
+1
View File
@@ -1487,6 +1487,7 @@
"refreshing_metadata": "Refreshing metadata",
"regenerating_thumbnails": "Regenerating thumbnails",
"remove": "Remove",
"remove_album": "Remove album",
"remove_assets_album_confirmation": "Are you sure you want to remove {count, plural, one {# asset} other {# assets}} from the album?",
"remove_assets_shared_link_confirmation": "Are you sure you want to remove {count, plural, one {# asset} other {# assets}} from this shared link?",
"remove_assets_title": "Remove assets?",
@@ -1,7 +1,6 @@
<script lang="ts">
import Icon from '$lib/components/elements/icon.svelte';
import Combobox, { type ComboBoxOption } from '$lib/components/shared-components/combobox.svelte';
import { preferences } from '$lib/stores/user.store';
import { getAssetThumbnailUrl } from '$lib/utils';
import { getAllAlbums, type AlbumResponseDto } from '@immich/sdk';
import { mdiClose } from '@mdi/js';
@@ -14,13 +13,14 @@
}
let { selectedAlbums = $bindable() }: Props = $props();
let allAlbums: AlbumResponseDto[] = $state([]);
let albumMap = $derived(Object.fromEntries(allAlbums.map((album) => [album.id, album])));
let selectedOption = $state(undefined);
let sortedSelectedAlbums = $derived(Array.from(selectedAlbums).sort((a, b) => albumMap[b]?.albumName?.length - albumMap[a]?.albumName?.length));
let sortedSelectedAlbums = $derived(
Array.from(selectedAlbums).sort((a, b) => albumMap[b]?.albumName?.length - albumMap[a]?.albumName?.length),
);
onMount(async () => {
allAlbums = await getAllAlbums({});
@@ -36,60 +36,57 @@
selectedOption = undefined;
};
const handleRemove = (tag: string) => {
selectedAlbums.delete(tag);
const handleRemove = (album: string) => {
selectedAlbums.delete(album);
};
</script>
{#if $preferences?.tags?.enabled}
<div id="location-selection">
<form autocomplete="off" id="create-album-form">
<div class="my-4 flex flex-col gap-2">
<Combobox
onSelect={handleSelect}
hasThumbnails
label={$t('albums').toUpperCase()}
defaultFirstOption
options={allAlbums.map((album) => ({
id: album.id,
label: album.albumName,
value: album.id,
thumbnail: album.albumThumbnailAssetId ? getAssetThumbnailUrl(album.albumThumbnailAssetId) : undefined,
}))}
bind:selectedOption
placeholder={$t('search_albums')}
/>
</div>
</form>
<div id="location-selection">
<form autocomplete="off" id="create-album-form">
<div class="my-4 flex flex-col gap-2">
<Combobox
onSelect={handleSelect}
hasThumbnails
label={$t('albums').toUpperCase()}
defaultFirstOption
options={allAlbums.map((album) => ({
id: album.id,
label: album.albumName,
value: album.id,
thumbnail: album.albumThumbnailAssetId ? getAssetThumbnailUrl(album.albumThumbnailAssetId) : undefined,
}))}
bind:selectedOption
placeholder={$t('search_albums')}
/>
</div>
</form>
<section class="flex flex-wrap pt-2 gap-1">
{#each sortedSelectedAlbums as albumId (albumId)}
{@const album = albumMap[albumId]}
{#if album}
<div class="album-chip-container flex group transition-all">
<span
class="album-chip inline-block h-min whitespace-nowrap ps-3 pe-1 group-hover:ps-3 py-1 text-center align-baseline leading-none text-gray-100 dark:text-immich-dark-gray bg-immich-primary dark:bg-immich-dark-primary roudned-s-full hover:bg-immich-primary/80 dark:hover:bg-immich-dark-primary/80 transition-all"
>
<p class="text-sm album-chip">
{album.albumName}
</p>
</span>
<button
type="button"
class="text-gray-100 dark:text-immich-dark-gray bg-immich-primary/95 dark:bg-immich-dark-primary/95 rounded-e-full place-items-center place-content-center pe-2 ps-1 py-1 hover:bg-immich-primary/80 dark:hover:bg-immich-dark-primary/80 transition-all"
title="Remove tag"
onclick={() => handleRemove(albumId)}
>
<Icon path={mdiClose} />
</button>
</div>
{/if}
{/each}
</section>
</div>
{/if}
<section class="flex flex-wrap pt-2 gap-1">
{#each sortedSelectedAlbums as albumId (albumId)}
{@const album = albumMap[albumId]}
{#if album}
<div class="album-chip-container flex group transition-all">
<span
class="album-chip inline-block h-min whitespace-nowrap ps-3 pe-1 group-hover:ps-3 py-1 text-center align-baseline leading-none text-gray-100 dark:text-immich-dark-gray bg-immich-primary dark:bg-immich-dark-primary roudned-s-full hover:bg-immich-primary/80 dark:hover:bg-immich-dark-primary/80 transition-all"
>
<p class="text-sm album-chip">
{album.albumName}
</p>
</span>
<button
type="button"
class="text-gray-100 dark:text-immich-dark-gray bg-immich-primary/95 dark:bg-immich-dark-primary/95 rounded-e-full place-items-center place-content-center pe-2 ps-1 py-1 hover:bg-immich-primary/80 dark:hover:bg-immich-dark-primary/80 transition-all"
title={$t('remove_album')}
onclick={() => handleRemove(albumId)}
>
<Icon path={mdiClose} />
</button>
</div>
{/if}
{/each}
</section>
</div>
<style>
.album-chip-container {
@@ -100,4 +97,4 @@
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</style>