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';
|
|
|
|
|
import { BucketPosition, type AssetStore } from '$lib/stores/assets.store';
|
|
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
2023-07-01 00:50:47 -04:00
|
|
|
import SelectAll from 'svelte-material-icons/SelectAll.svelte';
|
|
|
|
|
import TimerSand from 'svelte-material-icons/TimerSand.svelte';
|
2023-08-03 11:44:12 -04:00
|
|
|
import { get } from 'svelte/store';
|
2023-08-01 04:27:56 +03:00
|
|
|
|
|
|
|
|
export let assetStore: AssetStore;
|
|
|
|
|
export let assetInteractionStore: AssetInteractionStore;
|
2023-06-10 21:06:13 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
let selecting = false;
|
2023-06-10 21:06:13 +02:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const handleSelectAll = async () => {
|
|
|
|
|
try {
|
|
|
|
|
selecting = true;
|
2023-06-10 21:06:13 +02:00
|
|
|
|
2023-08-01 04:27:56 +03:00
|
|
|
const assetGridState = get(assetStore);
|
|
|
|
|
for (const bucket of assetGridState.buckets) {
|
2023-08-02 21:57:11 -04:00
|
|
|
await assetStore.loadBucket(bucket.bucketDate, BucketPosition.Unknown);
|
2023-08-01 04:27:56 +03:00
|
|
|
for (const asset of bucket.assets) {
|
2023-08-11 12:00:51 -04:00
|
|
|
assetInteractionStore.selectAsset(asset);
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
|
}
|
2023-08-01 04:27:56 +03:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
selecting = false;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
handleError(e, 'Error selecting all assets');
|
|
|
|
|
}
|
|
|
|
|
};
|
2023-06-10 21:06:13 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if selecting}
|
2023-07-01 00:50:47 -04:00
|
|
|
<CircleIconButton title="Delete" logo={TimerSand} />
|
2023-06-10 21:06:13 +02:00
|
|
|
{/if}
|
|
|
|
|
{#if !selecting}
|
2023-07-01 00:50:47 -04:00
|
|
|
<CircleIconButton title="Select all" logo={SelectAll} on:click={handleSelectAll} />
|
2023-06-10 21:06:13 +02:00
|
|
|
{/if}
|