2023-09-24 15:22:46 +02:00
|
|
|
<script lang="ts">
|
2024-02-13 17:07:37 -05:00
|
|
|
import { updateAlbumInfo, type AlbumResponseDto } from '@immich/sdk';
|
2024-04-05 21:19:26 +02:00
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
|
|
|
|
import Button from '$lib/components/elements/buttons/button.svelte';
|
|
|
|
|
import AlbumCover from '$lib/components/album-page/album-cover.svelte';
|
2024-04-16 05:06:15 +00:00
|
|
|
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2023-09-24 15:22:46 +02:00
|
|
|
|
|
|
|
|
export let album: AlbumResponseDto;
|
2024-04-05 21:19:26 +02:00
|
|
|
export let onEditSuccess: ((album: AlbumResponseDto) => unknown) | undefined = undefined;
|
|
|
|
|
export let onCancel: (() => unknown) | undefined = undefined;
|
2024-04-16 05:06:15 +00:00
|
|
|
export let onClose: () => void;
|
2023-09-24 15:22:46 +02:00
|
|
|
|
2024-04-05 21:19:26 +02:00
|
|
|
let albumName = album.albumName;
|
|
|
|
|
let description = album.description;
|
2023-09-24 15:22:46 +02:00
|
|
|
|
2024-04-05 21:19:26 +02:00
|
|
|
let isSubmitting = false;
|
|
|
|
|
|
|
|
|
|
const handleUpdateAlbumInfo = async () => {
|
|
|
|
|
isSubmitting = true;
|
2023-09-24 15:22:46 +02:00
|
|
|
try {
|
2024-02-13 17:07:37 -05:00
|
|
|
await updateAlbumInfo({
|
2023-09-24 15:22:46 +02:00
|
|
|
id: album.id,
|
|
|
|
|
updateAlbumDto: {
|
2024-04-05 21:19:26 +02:00
|
|
|
albumName,
|
|
|
|
|
description,
|
2023-09-24 15:22:46 +02:00
|
|
|
},
|
|
|
|
|
});
|
2024-04-05 21:19:26 +02:00
|
|
|
album.albumName = albumName;
|
|
|
|
|
album.description = description;
|
|
|
|
|
onEditSuccess?.(album);
|
2023-09-24 15:22:46 +02:00
|
|
|
} catch (error) {
|
2024-04-05 21:19:26 +02:00
|
|
|
handleError(error, 'Unable to update album info');
|
|
|
|
|
} finally {
|
|
|
|
|
isSubmitting = false;
|
2023-09-24 15:22:46 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
2024-06-04 21:53:00 +02:00
|
|
|
<FullScreenModal title={$t('edit_album')} width="wide" {onClose}>
|
2024-04-16 05:06:15 +00:00
|
|
|
<form on:submit|preventDefault={handleUpdateAlbumInfo} autocomplete="off" id="edit-album-form">
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
|
<div class="hidden sm:flex">
|
2024-06-14 18:16:48 -05:00
|
|
|
<AlbumCover {album} class="h-[200px] w-[200px] m-4 shadow-lg" />
|
2024-04-05 21:19:26 +02:00
|
|
|
</div>
|
|
|
|
|
|
2024-04-16 05:06:15 +00:00
|
|
|
<div class="flex-grow">
|
|
|
|
|
<div class="m-4 flex flex-col gap-2">
|
2024-06-04 21:53:00 +02:00
|
|
|
<label class="immich-form-label" for="name">{$t('name')}</label>
|
2024-04-16 05:06:15 +00:00
|
|
|
<input class="immich-form-input" id="name" type="text" bind:value={albumName} />
|
|
|
|
|
</div>
|
2023-09-24 15:22:46 +02:00
|
|
|
|
2024-04-16 05:06:15 +00:00
|
|
|
<div class="m-4 flex flex-col gap-2">
|
2024-06-04 21:53:00 +02:00
|
|
|
<label class="immich-form-label" for="description">{$t('description')}</label>
|
2024-04-16 05:06:15 +00:00
|
|
|
<textarea class="immich-form-input" id="description" bind:value={description} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-09-24 15:22:46 +02:00
|
|
|
</div>
|
2024-04-16 05:06:15 +00:00
|
|
|
</form>
|
|
|
|
|
<svelte:fragment slot="sticky-bottom">
|
2024-06-04 21:53:00 +02:00
|
|
|
<Button color="gray" fullwidth on:click={() => onCancel?.()}>{$t('cancel')}</Button>
|
|
|
|
|
<Button type="submit" fullwidth disabled={isSubmitting} form="edit-album-form">{$t('ok')}</Button>
|
2024-04-16 05:06:15 +00:00
|
|
|
</svelte:fragment>
|
|
|
|
|
</FullScreenModal>
|