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';
|
2023-11-30 04:52:28 +01:00
|
|
|
export let menuItem = false;
|
|
|
|
|
const { clearSelect, getOwnedAssets } = getAssetControlContext();
|
|
|
|
|
|
|
|
|
|
let isShowChangeDate = false;
|
|
|
|
|
|
|
|
|
|
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-04 21:53:00 +02:00
|
|
|
<MenuOption text={$t('change_date')} icon={mdiCalendarEditOutline} on:click={() => (isShowChangeDate = true)} />
|
2023-11-30 04:52:28 +01:00
|
|
|
{/if}
|
|
|
|
|
{#if isShowChangeDate}
|
|
|
|
|
<ChangeDate
|
|
|
|
|
initialDate={DateTime.now()}
|
|
|
|
|
on:confirm={({ detail: date }) => handleConfirm(date)}
|
|
|
|
|
on:cancel={() => (isShowChangeDate = false)}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|