mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31:59 +00:00
fix(web): validation when editing asset date & time (#7160)
This commit is contained in:
parent
3915867b1b
commit
60ba37b3a7
2 changed files with 4 additions and 16 deletions
|
@ -1,11 +1,3 @@
|
||||||
<script lang="ts" context="module">
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
||||||
declare namespace Intl {
|
|
||||||
type Key = 'calendar' | 'collation' | 'currency' | 'numberingSystem' | 'timeZone' | 'unit';
|
|
||||||
function supportedValuesOf(input: Key): string[];
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from 'svelte';
|
import { createEventDispatcher } from 'svelte';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
|
@ -42,7 +34,9 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
let selectedDate = initialDate.toFormat("yyyy-MM-dd'T'HH:mm");
|
let selectedDate = initialDate.toFormat("yyyy-MM-dd'T'HH:mm");
|
||||||
let disabled = false;
|
|
||||||
|
// Keep local time if not it's really confusing
|
||||||
|
$: date = DateTime.fromISO(selectedDate).setZone(selectedOption.value, { keepLocalTime: true });
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{
|
const dispatch = createEventDispatcher<{
|
||||||
cancel: void;
|
cancel: void;
|
||||||
|
@ -52,13 +46,8 @@
|
||||||
const handleCancel = () => dispatch('cancel');
|
const handleCancel = () => dispatch('cancel');
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
let date = DateTime.fromISO(selectedDate);
|
|
||||||
|
|
||||||
date = date.setZone(selectedOption.value, { keepLocalTime: true }); // Keep local time if not it's really confusing
|
|
||||||
|
|
||||||
const value = date.toISO();
|
const value = date.toISO();
|
||||||
if (value) {
|
if (value) {
|
||||||
disabled = true;
|
|
||||||
dispatch('confirm', value);
|
dispatch('confirm', value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -76,7 +65,7 @@
|
||||||
cancelColor="secondary"
|
cancelColor="secondary"
|
||||||
title="Edit date & time"
|
title="Edit date & time"
|
||||||
prompt="Please select a new date:"
|
prompt="Please select a new date:"
|
||||||
{disabled}
|
disabled={!date.isValid}
|
||||||
on:confirm={handleConfirm}
|
on:confirm={handleConfirm}
|
||||||
on:cancel={handleCancel}
|
on:cancel={handleCancel}
|
||||||
>
|
>
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"lib": ["es2020", "DOM"],
|
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"module": "es2020",
|
"module": "es2020",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
|
Loading…
Reference in a new issue