2023-11-30 04:52:28 +01:00
|
|
|
<script lang="ts">
|
|
|
|
|
import ChangeDate from '$lib/components/shared-components/change-date.svelte';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { user } from '$lib/stores/user.store';
|
|
|
|
|
import { getSelectedAssets } from '$lib/utils/asset-utils';
|
2023-11-30 04:52:28 +01:00
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
2024-02-14 08:09:49 -05:00
|
|
|
import { updateAssets } from '@immich/sdk';
|
2023-11-30 04:52:28 +01:00
|
|
|
import { DateTime } from 'luxon';
|
|
|
|
|
import MenuOption from '../../shared-components/context-menu/menu-option.svelte';
|
|
|
|
|
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
|
2024-03-21 19:39:33 +01:00
|
|
|
import { mdiCalendarEditOutline } from '@mdi/js';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
menuItem?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let { menuItem = false }: Props = $props();
|
2023-11-30 04:52:28 +01:00
|
|
|
const { clearSelect, getOwnedAssets } = getAssetControlContext();
|
|
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let isShowChangeDate = $state(false);
|
2023-11-30 04:52:28 +01:00
|
|
|
|
|
|
|
|
const handleConfirm = async (dateTimeOriginal: string) => {
|
|
|
|
|
isShowChangeDate = false;
|
2023-12-01 21:58:24 +01:00
|
|
|
const ids = getSelectedAssets(getOwnedAssets(), $user);
|
2023-11-30 04:52:28 +01:00
|
|
|
|
|
|
|
|
try {
|
2024-02-14 08:09:49 -05:00
|
|
|
await updateAssets({ assetBulkUpdateDto: { ids, dateTimeOriginal } });
|
2023-11-30 04:52:28 +01:00
|
|
|
} catch (error) {
|
2024-06-04 21:53:00 +02:00
|
|
|
handleError(error, $t('errors.unable_to_change_date'));
|
2023-11-30 04:52:28 +01:00
|
|
|
}
|
|
|
|
|
clearSelect();
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
{#if menuItem}
|
2024-06-20 21:15:36 +00:00
|
|
|
<MenuOption text={$t('change_date')} icon={mdiCalendarEditOutline} onClick={() => (isShowChangeDate = true)} />
|
2023-11-30 04:52:28 +01:00
|
|
|
{/if}
|
|
|
|
|
{#if isShowChangeDate}
|
2024-09-20 23:02:58 +02:00
|
|
|
<ChangeDate initialDate={DateTime.now()} onConfirm={handleConfirm} onCancel={() => (isShowChangeDate = false)} />
|
2023-11-30 04:52:28 +01:00
|
|
|
{/if}
|