mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
chore: Refactor Edit Album Modal (#18653)
This commit is contained in:
parent
8ea40973a7
commit
10181defb1
@ -143,7 +143,6 @@
|
|||||||
|
|
||||||
let albumGroupOption: string = $state(AlbumGroupBy.None);
|
let albumGroupOption: string = $state(AlbumGroupBy.None);
|
||||||
|
|
||||||
let albumToEdit: AlbumResponseDto | null = $state(null);
|
|
||||||
let albumToShare: AlbumResponseDto | null = $state(null);
|
let albumToShare: AlbumResponseDto | null = $state(null);
|
||||||
let albumToDelete: AlbumResponseDto | null = null;
|
let albumToDelete: AlbumResponseDto | null = null;
|
||||||
|
|
||||||
@ -257,9 +256,14 @@
|
|||||||
await deleteSelectedAlbum();
|
await deleteSelectedAlbum();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEdit = (album: AlbumResponseDto) => {
|
const handleEdit = async (album: AlbumResponseDto) => {
|
||||||
albumToEdit = album;
|
|
||||||
closeAlbumContextMenu();
|
closeAlbumContextMenu();
|
||||||
|
const editedAlbum = await modalManager.show(EditAlbumForm, {
|
||||||
|
album,
|
||||||
|
});
|
||||||
|
if (editedAlbum) {
|
||||||
|
successEditAlbumInfo(editedAlbum);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteSelectedAlbum = async () => {
|
const deleteSelectedAlbum = async () => {
|
||||||
@ -305,8 +309,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const successEditAlbumInfo = (album: AlbumResponseDto) => {
|
const successEditAlbumInfo = (album: AlbumResponseDto) => {
|
||||||
albumToEdit = null;
|
|
||||||
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: $t('album_info_updated'),
|
message: $t('album_info_updated'),
|
||||||
type: NotificationType.Info,
|
type: NotificationType.Info,
|
||||||
@ -422,15 +424,3 @@
|
|||||||
<MenuOption icon={mdiDeleteOutline} text={$t('delete')} onClick={() => setAlbumToDelete()} />
|
<MenuOption icon={mdiDeleteOutline} text={$t('delete')} onClick={() => setAlbumToDelete()} />
|
||||||
{/if}
|
{/if}
|
||||||
</RightClickContextMenu>
|
</RightClickContextMenu>
|
||||||
|
|
||||||
{#if allowEdit}
|
|
||||||
<!-- Edit Modal -->
|
|
||||||
{#if albumToEdit}
|
|
||||||
<EditAlbumForm
|
|
||||||
album={albumToEdit}
|
|
||||||
onEditSuccess={successEditAlbumInfo}
|
|
||||||
onCancel={() => (albumToEdit = null)}
|
|
||||||
onClose={() => (albumToEdit = null)}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
{/if}
|
|
||||||
|
@ -8,12 +8,10 @@
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
album: AlbumResponseDto;
|
album: AlbumResponseDto;
|
||||||
onEditSuccess?: ((album: AlbumResponseDto) => unknown) | undefined;
|
onClose: (album?: AlbumResponseDto) => void;
|
||||||
onCancel?: (() => unknown) | undefined;
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { album = $bindable(), onEditSuccess = undefined, onCancel = undefined, onClose }: Props = $props();
|
let { album = $bindable(), onClose }: Props = $props();
|
||||||
|
|
||||||
let albumName = $state(album.albumName);
|
let albumName = $state(album.albumName);
|
||||||
let description = $state(album.description);
|
let description = $state(album.description);
|
||||||
@ -32,7 +30,7 @@
|
|||||||
});
|
});
|
||||||
album.albumName = albumName;
|
album.albumName = albumName;
|
||||||
album.description = description;
|
album.description = description;
|
||||||
onEditSuccess?.(album);
|
onClose(album);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, $t('errors.unable_to_update_album_info'));
|
handleError(error, $t('errors.unable_to_update_album_info'));
|
||||||
} finally {
|
} finally {
|
||||||
@ -71,7 +69,7 @@
|
|||||||
|
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<div class="flex gap-2 w-full">
|
<div class="flex gap-2 w-full">
|
||||||
<Button shape="round" color="secondary" fullWidth onclick={() => onCancel?.()}>{$t('cancel')}</Button>
|
<Button shape="round" color="secondary" fullWidth onclick={() => onClose()}>{$t('cancel')}</Button>
|
||||||
<Button shape="round" type="submit" fullWidth disabled={isSubmitting} form="edit-album-form">{$t('save')}</Button>
|
<Button shape="round" type="submit" fullWidth disabled={isSubmitting} form="edit-album-form">{$t('save')}</Button>
|
||||||
</div>
|
</div>
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user