1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-22 11:42:46 +01:00

Add select all to search

This commit is contained in:
Yonggan 2023-06-10 14:21:02 +02:00
parent a8c8e33c10
commit 6f09f28206
6 changed files with 209 additions and 197 deletions

View file

@ -347,7 +347,7 @@
assets={multiSelectAsset} assets={multiSelectAsset}
clearSelect={() => (multiSelectAsset = new Set())} clearSelect={() => (multiSelectAsset = new Set())}
> >
<CircleIconButton title="Delete" logo={SelectAll} on:click={handleSelectAll}/> <CircleIconButton title="Select all" logo={SelectAll} on:click={handleSelectAll}/>
<DownloadAction filename={album.albumName} sharedLinkKey={sharedLink?.key} /> <DownloadAction filename={album.albumName} sharedLinkKey={sharedLink?.key} />
{#if isOwned} {#if isOwned}
<RemoveFromAlbum bind:album /> <RemoveFromAlbum bind:album />

View file

@ -7,7 +7,6 @@
import {api, AssetResponseDto} from '@api'; import {api, AssetResponseDto} from '@api';
import SelectAll from 'svelte-material-icons/SelectAll.svelte'; import SelectAll from 'svelte-material-icons/SelectAll.svelte';
import TimerSand from 'svelte-material-icons/TimerSand.svelte'; import TimerSand from 'svelte-material-icons/TimerSand.svelte';
import {getAssetControlContext} from '../asset-select-control-bar.svelte';
import { import {
assetInteractionStore, assetInteractionStore,
selectedAssets selectedAssets
@ -45,5 +44,5 @@
<CircleIconButton title="Delete" logo={TimerSand}/> <CircleIconButton title="Delete" logo={TimerSand}/>
{/if} {/if}
{#if !selecting} {#if !selecting}
<CircleIconButton title="Delete" logo={SelectAll} on:click={handleSelectAll}/> <CircleIconButton title="Select all" logo={SelectAll} on:click={handleSelectAll}/>
{/if} {/if}

View file

@ -62,7 +62,7 @@
clearSelect={() => (selectedAssets = new Set())} clearSelect={() => (selectedAssets = new Set())}
> >
<ArchiveAction unarchive onAssetArchive={(asset) => onAssetDelete(asset.id)} /> <ArchiveAction unarchive onAssetArchive={(asset) => onAssetDelete(asset.id)} />
<CircleIconButton title="Delete" logo={SelectAll} on:click={handleSelectAll}/> <CircleIconButton title="Select all" logo={SelectAll} on:click={handleSelectAll}/>
<CreateSharedLink /> <CreateSharedLink />
<AssetSelectContextMenu icon={Plus} title="Add"> <AssetSelectContextMenu icon={Plus} title="Add">
<AddToAlbum /> <AddToAlbum />

View file

@ -53,7 +53,7 @@
<AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}> <AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}>
<FavoriteAction removeFavorite onAssetFavorite={(asset) => onAssetDelete(asset.id)}/> <FavoriteAction removeFavorite onAssetFavorite={(asset) => onAssetDelete(asset.id)}/>
<CreateSharedLink/> <CreateSharedLink/>
<CircleIconButton title="Delete" logo={SelectAll} on:click={handleSelectAll}/> <CircleIconButton title="Select all" logo={SelectAll} on:click={handleSelectAll}/>
<AssetSelectContextMenu icon={Plus} title="Add"> <AssetSelectContextMenu icon={Plus} title="Add">
<AddToAlbum/> <AddToAlbum/>
<AddToAlbum shared/> <AddToAlbum shared/>

View file

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { afterNavigate, goto } from '$app/navigation'; import {afterNavigate, goto} from '$app/navigation';
import { page } from '$app/stores'; import {page} from '$app/stores';
import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte'; import ImageThumbnail from '$lib/components/assets/thumbnail/image-thumbnail.svelte';
import EditNameInput from '$lib/components/faces-page/edit-name-input.svelte'; import EditNameInput from '$lib/components/faces-page/edit-name-input.svelte';
import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte'; import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte';
@ -13,13 +13,16 @@
import AssetSelectControlBar from '$lib/components/photos-page/asset-select-control-bar.svelte'; import AssetSelectControlBar from '$lib/components/photos-page/asset-select-control-bar.svelte';
import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte'; import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte';
import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte'; import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte';
import { AppRoute } from '$lib/constants'; import SelectAll from 'svelte-material-icons/SelectAll.svelte';
import { handleError } from '$lib/utils/handle-error'; import {AppRoute} from '$lib/constants';
import { AssetResponseDto, api } from '@api'; import {handleError} from '$lib/utils/handle-error';
import {AssetResponseDto, api} from '@api';
import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte'; import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte';
import DotsVertical from 'svelte-material-icons/DotsVertical.svelte'; import DotsVertical from 'svelte-material-icons/DotsVertical.svelte';
import Plus from 'svelte-material-icons/Plus.svelte'; import Plus from 'svelte-material-icons/Plus.svelte';
import type { PageData } from './$types'; import type {PageData} from './$types';
import {archivedAsset} from "$lib/stores/archived-asset.store";
import CircleIconButton from "$lib/components/elements/buttons/circle-icon-button.svelte";
export let data: PageData; export let data: PageData;
@ -30,7 +33,7 @@
$: isAllArchive = Array.from(selectedAssets).every((asset) => asset.isArchived); $: isAllArchive = Array.from(selectedAssets).every((asset) => asset.isArchived);
$: isAllFavorite = Array.from(selectedAssets).every((asset) => asset.isFavorite); $: isAllFavorite = Array.from(selectedAssets).every((asset) => asset.isFavorite);
afterNavigate(({ from }) => { afterNavigate(({from}) => {
// Prevent setting previousRoute to the current page. // Prevent setting previousRoute to the current page.
if (from && from.route.id !== $page.route.id) { if (from && from.route.id !== $page.route.id) {
previousRoute = from.url.href; previousRoute = from.url.href;
@ -41,7 +44,7 @@
try { try {
isEditName = false; isEditName = false;
data.person.name = name; data.person.name = name;
await api.personApi.updatePerson({ id: data.person.id, personUpdateDto: { name } }); await api.personApi.updatePerson({id: data.person.id, personUpdateDto: {name}});
} catch (error) { } catch (error) {
handleError(error, 'Unable to save name'); handleError(error, 'Unable to save name');
} }
@ -50,19 +53,23 @@
const onAssetDelete = (assetId: string) => { const onAssetDelete = (assetId: string) => {
data.assets = data.assets.filter((asset: AssetResponseDto) => asset.id !== assetId); data.assets = data.assets.filter((asset: AssetResponseDto) => asset.id !== assetId);
}; };
const handleSelectAll = () => {
selectedAssets = new Set(data.assets)
}
</script> </script>
{#if isMultiSelectionMode} {#if isMultiSelectionMode}
<AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}> <AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}>
<CreateSharedLink /> <CreateSharedLink/>
<CircleIconButton title="Select all" logo={SelectAll} on:click={handleSelectAll}/>
<AssetSelectContextMenu icon={Plus} title="Add"> <AssetSelectContextMenu icon={Plus} title="Add">
<AddToAlbum /> <AddToAlbum/>
<AddToAlbum shared /> <AddToAlbum shared/>
</AssetSelectContextMenu> </AssetSelectContextMenu>
<DeleteAssets {onAssetDelete} /> <DeleteAssets {onAssetDelete}/>
<AssetSelectContextMenu icon={DotsVertical} title="Add"> <AssetSelectContextMenu icon={DotsVertical} title="Add">
<DownloadAction menuItem /> <DownloadAction menuItem/>
<FavoriteAction menuItem removeFavorite={isAllFavorite} /> <FavoriteAction menuItem removeFavorite={isAllFavorite}/>
<ArchiveAction <ArchiveAction
menuItem menuItem
unarchive={isAllArchive} unarchive={isAllArchive}

View file

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { afterNavigate, goto } from '$app/navigation'; import {afterNavigate, goto} from '$app/navigation';
import { page } from '$app/stores'; import {page} from '$app/stores';
import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte'; import AddToAlbum from '$lib/components/photos-page/actions/add-to-album.svelte';
import ArchiveAction from '$lib/components/photos-page/actions/archive-action.svelte'; import ArchiveAction from '$lib/components/photos-page/actions/archive-action.svelte';
import CreateSharedLink from '$lib/components/photos-page/actions/create-shared-link.svelte'; import CreateSharedLink from '$lib/components/photos-page/actions/create-shared-link.svelte';
@ -12,12 +12,14 @@
import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte'; import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte';
import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte'; import GalleryViewer from '$lib/components/shared-components/gallery-viewer/gallery-viewer.svelte';
import SearchBar from '$lib/components/shared-components/search-bar/search-bar.svelte'; import SearchBar from '$lib/components/shared-components/search-bar/search-bar.svelte';
import type { AssetResponseDto } from '@api'; import type {AssetResponseDto} from '@api';
import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte'; import ArrowLeft from 'svelte-material-icons/ArrowLeft.svelte';
import DotsVertical from 'svelte-material-icons/DotsVertical.svelte'; import DotsVertical from 'svelte-material-icons/DotsVertical.svelte';
import ImageOffOutline from 'svelte-material-icons/ImageOffOutline.svelte'; import ImageOffOutline from 'svelte-material-icons/ImageOffOutline.svelte';
import Plus from 'svelte-material-icons/Plus.svelte'; import Plus from 'svelte-material-icons/Plus.svelte';
import type { PageData } from './$types'; import type {PageData} from './$types';
import SelectAll from 'svelte-material-icons/SelectAll.svelte';
import CircleIconButton from "$lib/components/elements/buttons/circle-icon-button.svelte";
export let data: PageData; export let data: PageData;
@ -26,7 +28,7 @@
// manually and navigate back to that. // manually and navigate back to that.
let previousRoute = '/explore'; let previousRoute = '/explore';
afterNavigate(({ from }) => { afterNavigate(({from}) => {
// Prevent setting previousRoute to the current page. // Prevent setting previousRoute to the current page.
if (from && from.route.id !== $page.route.id) { if (from && from.route.id !== $page.route.id) {
previousRoute = from.url.href; previousRoute = from.url.href;
@ -44,28 +46,32 @@
const onAssetDelete = (assetId: string) => { const onAssetDelete = (assetId: string) => {
searchResultAssets = searchResultAssets.filter((a: AssetResponseDto) => a.id !== assetId); searchResultAssets = searchResultAssets.filter((a: AssetResponseDto) => a.id !== assetId);
}; };
const handleSelectAll = () => {
selectedAssets = new Set(searchResultAssets)
}
</script> </script>
<section> <section>
{#if isMultiSelectionMode} {#if isMultiSelectionMode}
<AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}> <AssetSelectControlBar assets={selectedAssets} clearSelect={() => (selectedAssets = new Set())}>
<CreateSharedLink /> <CreateSharedLink/>
<CircleIconButton title="Select all" logo={SelectAll} on:click={handleSelectAll}/>
<AssetSelectContextMenu icon={Plus} title="Add"> <AssetSelectContextMenu icon={Plus} title="Add">
<AddToAlbum /> <AddToAlbum/>
<AddToAlbum shared /> <AddToAlbum shared/>
</AssetSelectContextMenu> </AssetSelectContextMenu>
<DeleteAssets {onAssetDelete} /> <DeleteAssets {onAssetDelete}/>
<AssetSelectContextMenu icon={DotsVertical} title="Add"> <AssetSelectContextMenu icon={DotsVertical} title="Add">
<DownloadAction menuItem /> <DownloadAction menuItem/>
<FavoriteAction menuItem removeFavorite={isAllFavorite} /> <FavoriteAction menuItem removeFavorite={isAllFavorite}/>
<ArchiveAction menuItem unarchive={isAllArchived} /> <ArchiveAction menuItem unarchive={isAllArchived}/>
</AssetSelectContextMenu> </AssetSelectContextMenu>
</AssetSelectControlBar> </AssetSelectControlBar>
{:else} {:else}
<ControlAppBar on:close-button-click={() => goto(previousRoute)} backIcon={ArrowLeft}> <ControlAppBar on:close-button-click={() => goto(previousRoute)} backIcon={ArrowLeft}>
<div class="w-full max-w-2xl flex-1 pl-4"> <div class="w-full max-w-2xl flex-1 pl-4">
<SearchBar grayTheme={false} value={term} /> <SearchBar grayTheme={false} value={term}/>
</div> </div>
</ControlAppBar> </ControlAppBar>
{/if} {/if}
@ -88,7 +94,7 @@
class="flex items-center place-content-center w-full min-h-[calc(66vh_-_11rem)] dark:text-white" class="flex items-center place-content-center w-full min-h-[calc(66vh_-_11rem)] dark:text-white"
> >
<div class="flex flex-col content-center items-center text-center"> <div class="flex flex-col content-center items-center text-center">
<ImageOffOutline size="3.5em" /> <ImageOffOutline size="3.5em"/>
<p class="font-medium text-3xl mt-5">No results</p> <p class="font-medium text-3xl mt-5">No results</p>
<p class="text-base font-normal">Try a synonym or more general keyword</p> <p class="text-base font-normal">Try a synonym or more general keyword</p>
</div> </div>