2023-06-10 21:06:13 +02:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import CircleIconButton from '$lib/components/elements/buttons/circle-icon-button.svelte';
|
2023-08-03 11:44:12 -04:00
|
|
|
import type { AssetInteractionStore } from '$lib/stores/asset-interaction.store';
|
2024-03-21 13:14:13 +01:00
|
|
|
import { type AssetStore, isSelectingAllAssets } from '$lib/stores/assets.store';
|
2024-05-07 22:05:19 -05:00
|
|
|
import { mdiSelectAll, mdiSelectRemove } from '@mdi/js';
|
2024-10-21 02:11:00 +08:00
|
|
|
import { selectAllAssets, cancelMultiselect } from '$lib/utils/asset-utils';
|
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;
|
|
|
|
|
assetInteractionStore: AssetInteractionStore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { assetStore, assetInteractionStore }: Props = $props();
|
2023-06-10 21:06:13 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleSelectAll = async () => {
|
2024-03-21 13:14:13 +01:00
|
|
|
await selectAllAssets(assetStore, assetInteractionStore);
|
|
|
|
|
};
|
2023-08-01 04:27:56 +03:00
|
|
|
|
2024-03-21 13:14:13 +01:00
|
|
|
const handleCancel = () => {
|
2024-10-21 02:11:00 +08:00
|
|
|
cancelMultiselect(assetInteractionStore);
|
2023-07-01 00:50:47 -04:00
|
|
|
};
|
2023-06-10 21:06:13 +02:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-21 13:14:13 +01:00
|
|
|
{#if $isSelectingAllAssets}
|
2024-11-14 08:43:25 -06:00
|
|
|
<CircleIconButton title={$t('unselect_all')} icon={mdiSelectRemove} onclick={handleCancel} />
|
2024-03-21 13:14:13 +01:00
|
|
|
{:else}
|
2024-11-14 08:43:25 -06:00
|
|
|
<CircleIconButton title={$t('select_all')} icon={mdiSelectAll} onclick={handleSelectAll} />
|
2023-06-10 21:06:13 +02:00
|
|
|
{/if}
|