From 75947ab6c28740e46ef9108f93c107d8693b5684 Mon Sep 17 00:00:00 2001 From: martin <74269598+martabal@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:04:43 +0100 Subject: [PATCH] feat(web): search albums (#7322) * feat: search albums * pr feedback * fix: comparison * pr feedback * simplify * chore: more compact album padding --------- Co-authored-by: Jason Rasmussen --- .../{faces-page => elements}/search-bar.svelte | 9 +++++---- .../lib/components/faces-page/people-list.svelte | 5 +++-- .../lib/components/layouts/user-page-layout.svelte | 2 +- web/src/routes/(user)/albums/+page.svelte | 13 ++++++++++--- web/src/routes/(user)/albums/[albumId]/+page.svelte | 8 ++++---- web/src/routes/(user)/people/+page.svelte | 5 +++-- 6 files changed, 26 insertions(+), 16 deletions(-) rename web/src/lib/components/{faces-page => elements}/search-bar.svelte (88%) diff --git a/web/src/lib/components/faces-page/search-bar.svelte b/web/src/lib/components/elements/search-bar.svelte similarity index 88% rename from web/src/lib/components/faces-page/search-bar.svelte rename to web/src/lib/components/elements/search-bar.svelte index e1f999dbca..9c6eded224 100644 --- a/web/src/lib/components/faces-page/search-bar.svelte +++ b/web/src/lib/components/elements/search-bar.svelte @@ -1,12 +1,13 @@ diff --git a/web/src/routes/(user)/albums/+page.svelte b/web/src/routes/(user)/albums/+page.svelte index fa0115d828..07000d9136 100644 --- a/web/src/routes/(user)/albums/+page.svelte +++ b/web/src/routes/(user)/albums/+page.svelte @@ -43,11 +43,13 @@ import { flip } from 'svelte/animate'; import type { PageData } from './$types'; import { useAlbums } from './albums.bloc'; + import SearchBar from '$lib/components/elements/search-bar.svelte'; export let data: PageData; let shouldShowEditUserForm = false; let selectedAlbum: AlbumResponseDto; + let searchAlbum = ''; let sortByOptions: Record = { albumTitle: { @@ -180,6 +182,8 @@ } } + $: albumsFiltered = $albums.filter((album) => album.albumName.toLowerCase().includes(searchAlbum.toLowerCase())); + const searchSort = (searched: string): Sort => { for (const key in sortByOptions) { if (sortByOptions[key].title === searched) { @@ -243,6 +247,9 @@
+
@@ -285,7 +292,7 @@ {#if $albumViewSettings.view === AlbumViewMode.Cover}
- {#each $albums as album, index (album.id)} + {#each albumsFiltered as album, index (album.id)} {:else if $albumViewSettings.view === AlbumViewMode.List} - +
@@ -310,7 +317,7 @@ - {#each $albums as album (album.id)} + {#each albumsFiltered as album (album.id)} goto(`${AppRoute.ALBUMS}/${album.id}`)} diff --git a/web/src/routes/(user)/albums/[albumId]/+page.svelte b/web/src/routes/(user)/albums/[albumId]/+page.svelte index 52b780acc2..7c9ca39acd 100644 --- a/web/src/routes/(user)/albums/[albumId]/+page.svelte +++ b/web/src/routes/(user)/albums/[albumId]/+page.svelte @@ -603,7 +603,7 @@ e.key === 'Enter' && titleInput.blur()} on:blur={handleUpdateName} - class="w-[99%] border-b-2 border-transparent text-6xl text-immich-primary outline-none transition-all dark:text-immich-dark-primary {isOwned + class="w-[99%] mb-2 border-b-2 border-transparent text-6xl text-immich-primary outline-none transition-all dark:text-immich-dark-primary {isOwned ? 'hover:border-gray-400' : 'hover:border-transparent'} bg-immich-bg focus:border-b-2 focus:border-immich-primary focus:outline-none dark:bg-immich-dark-bg dark:focus:border-immich-dark-primary dark:focus:bg-immich-dark-gray" type="text" @@ -616,7 +616,7 @@ {#if album.assetCount > 0} - +

{getDateRange()}

ยท

{album.assetCount} items

@@ -625,7 +625,7 @@ {#if album.sharedUsers.length > 0 || (album.hasSharedLink && isOwned)} -
+
{#if album.hasSharedLink && isOwned} {#if isOwned}