Files
immich/web/src/lib/components/photos-page/actions/change-location-action.svelte
T
martin ec92608024 fix(web): disable metadata edit if user is not owner (#5415)
* fix(web): disable metadata edit if user is not owner

* pr feedback

* pr feedback

* get data from page data

* fix: better representation

* feat: warn user if there's issues with the selected assets

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-12-01 14:58:24 -06:00

43 lines
1.3 KiB
Svelte

<script lang="ts">
import { api } from '@api';
import MenuOption from '../../shared-components/context-menu/menu-option.svelte';
import { getAssetControlContext } from '../asset-select-control-bar.svelte';
import ChangeLocation from '$lib/components/shared-components/change-location.svelte';
import { handleError } from '../../../utils/handle-error';
import { user } from '$lib/stores/user.store';
import { getSelectedAssets } from '$lib/utils/asset-utils';
export let menuItem = false;
const { clearSelect, getOwnedAssets } = getAssetControlContext();
let isShowChangeLocation = false;
async function handleConfirm(point: { lng: number; lat: number }) {
isShowChangeLocation = false;
const ids = getSelectedAssets(getOwnedAssets(), $user);
try {
await api.assetApi.updateAssets({
assetBulkUpdateDto: {
ids,
latitude: point.lat,
longitude: point.lng,
},
});
} catch (error) {
handleError(error, 'Unable to update location');
}
clearSelect();
}
</script>
{#if menuItem}
<MenuOption text="Change location" on:click={() => (isShowChangeLocation = true)} />
{/if}
{#if isShowChangeLocation}
<ChangeLocation
on:confirm={({ detail: point }) => handleConfirm(point)}
on:cancel={() => (isShowChangeLocation = false)}
/>
{/if}