2023-06-10 21:06:13 +02:00
|
|
|
<script lang="ts">
|
2025-05-15 09:35:21 -06:00
|
|
|
import type { AssetInteraction } from '$lib/stores/asset-interaction.svelte';
|
2025-06-04 22:27:54 -04:00
|
|
|
import { AssetStore } from '$lib/managers/timeline-manager/asset-store.svelte';
|
|
|
|
|
import { isSelectingAllAssets } from '$lib/stores/assets-store.svelte';
|
2025-05-15 09:35:21 -06:00
|
|
|
import { cancelMultiselect, selectAllAssets } from '$lib/utils/asset-utils';
|
2025-06-02 09:47:23 -05:00
|
|
|
import { Button, IconButton } from '@immich/ui';
|
2024-05-07 22:05:19 -05:00
|
|
|
import { mdiSelectAll, mdiSelectRemove } from '@mdi/js';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2023-08-01 04:27:56 +03:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
assetStore: AssetStore;
|
2024-12-14 19:30:33 +01:00
|
|
|
assetInteraction: AssetInteraction;
|
2025-05-15 09:35:21 -06:00
|
|
|
withText?: boolean;
|
2024-11-14 08:43:25 -06:00
|
|
|
}
|
|
|
|
|
|
2025-05-15 09:35:21 -06:00
|
|
|
let { assetStore, assetInteraction, withText = false }: Props = $props();
|
2023-06-10 21:06:13 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleSelectAll = async () => {
|
2024-12-14 19:30:33 +01:00
|
|
|
await selectAllAssets(assetStore, assetInteraction);
|
2024-03-21 13:14:13 +01:00
|
|
|
};
|
2023-08-01 04:27:56 +03:00
|
|
|
|
2024-03-21 13:14:13 +01:00
|
|
|
const handleCancel = () => {
|
2024-12-14 19:30:33 +01:00
|
|
|
cancelMultiselect(assetInteraction);
|
2023-07-01 00:50:47 -04:00
|
|
|
};
|
2023-06-10 21:06:13 +02:00
|
|
|
</script>
|
|
|
|
|
|
2025-05-15 09:35:21 -06:00
|
|
|
{#if withText}
|
|
|
|
|
<Button
|
|
|
|
|
leadingIcon={$isSelectingAllAssets ? mdiSelectRemove : mdiSelectAll}
|
|
|
|
|
size="medium"
|
|
|
|
|
color="secondary"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
onclick={$isSelectingAllAssets ? handleCancel : handleSelectAll}
|
|
|
|
|
>
|
|
|
|
|
{$isSelectingAllAssets ? $t('unselect_all') : $t('select_all')}
|
|
|
|
|
</Button>
|
2024-03-21 13:14:13 +01:00
|
|
|
{:else}
|
2025-06-02 09:47:23 -05:00
|
|
|
<IconButton
|
|
|
|
|
shape="round"
|
|
|
|
|
color="secondary"
|
|
|
|
|
variant="ghost"
|
|
|
|
|
aria-label={$isSelectingAllAssets ? $t('unselect_all') : $t('select_all')}
|
2025-05-15 09:35:21 -06:00
|
|
|
icon={$isSelectingAllAssets ? mdiSelectRemove : mdiSelectAll}
|
|
|
|
|
onclick={$isSelectingAllAssets ? handleCancel : handleSelectAll}
|
|
|
|
|
/>
|
2023-06-10 21:06:13 +02:00
|
|
|
{/if}
|