mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 11:42:15 +01:00
improve focus handling for time entry create modal and update end date if start date is after end, fixes ST-250
This commit is contained in:
@@ -2,9 +2,8 @@
|
|||||||
import TextInput from '@/Components/TextInput.vue';
|
import TextInput from '@/Components/TextInput.vue';
|
||||||
import SecondaryButton from '@/Components/SecondaryButton.vue';
|
import SecondaryButton from '@/Components/SecondaryButton.vue';
|
||||||
import DialogModal from '@/Components/DialogModal.vue';
|
import DialogModal from '@/Components/DialogModal.vue';
|
||||||
import { ref, watch } from 'vue';
|
import { nextTick, ref, watch } from 'vue';
|
||||||
import PrimaryButton from '@/Components/PrimaryButton.vue';
|
import PrimaryButton from '@/Components/PrimaryButton.vue';
|
||||||
import { useFocus } from '@vueuse/core';
|
|
||||||
import TimeTrackerTagDropdown from '@/Components/Common/TimeTracker/TimeTrackerTagDropdown.vue';
|
import TimeTrackerTagDropdown from '@/Components/Common/TimeTracker/TimeTrackerTagDropdown.vue';
|
||||||
import TimeTrackerProjectTaskDropdown from '@/Components/Common/TimeTracker/TimeTrackerProjectTaskDropdown.vue';
|
import TimeTrackerProjectTaskDropdown from '@/Components/Common/TimeTracker/TimeTrackerProjectTaskDropdown.vue';
|
||||||
import BillableToggleButton from '@/Components/Common/BillableToggleButton.vue';
|
import BillableToggleButton from '@/Components/Common/BillableToggleButton.vue';
|
||||||
@@ -19,6 +18,16 @@ const { createTimeEntry } = useTimeEntriesStore();
|
|||||||
const show = defineModel('show', { default: false });
|
const show = defineModel('show', { default: false });
|
||||||
const saving = ref(false);
|
const saving = ref(false);
|
||||||
|
|
||||||
|
const description = ref<HTMLInputElement | null>(null);
|
||||||
|
|
||||||
|
watch(show, (value) => {
|
||||||
|
if (value) {
|
||||||
|
nextTick(() => {
|
||||||
|
description.value?.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const timeEntryDefaultValues = {
|
const timeEntryDefaultValues = {
|
||||||
description: '',
|
description: '',
|
||||||
project_id: null,
|
project_id: null,
|
||||||
@@ -36,12 +45,15 @@ const localStart = ref(
|
|||||||
getLocalizedDayJs(timeEntryDefaultValues.start).format()
|
getLocalizedDayJs(timeEntryDefaultValues.start).format()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const localEnd = ref(getLocalizedDayJs(timeEntryDefaultValues.end).format());
|
||||||
|
|
||||||
watch(localStart, (value) => {
|
watch(localStart, (value) => {
|
||||||
timeEntry.value.start = getLocalizedDayJs(value).utc().format();
|
timeEntry.value.start = getLocalizedDayJs(value).utc().format();
|
||||||
|
if (getLocalizedDayJs(localEnd.value).isBefore(getLocalizedDayJs(value))) {
|
||||||
|
localEnd.value = value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const localEnd = ref(getLocalizedDayJs(timeEntryDefaultValues.end).format());
|
|
||||||
|
|
||||||
watch(localEnd, (value) => {
|
watch(localEnd, (value) => {
|
||||||
timeEntry.value.end = getLocalizedDayJs(value).utc().format();
|
timeEntry.value.end = getLocalizedDayJs(value).utc().format();
|
||||||
});
|
});
|
||||||
@@ -53,10 +65,6 @@ async function submit() {
|
|||||||
localEnd.value = getLocalizedDayJs(timeEntryDefaultValues.end).format();
|
localEnd.value = getLocalizedDayJs(timeEntryDefaultValues.end).format();
|
||||||
show.value = false;
|
show.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const projectNameInput = ref<HTMLInputElement | null>(null);
|
|
||||||
|
|
||||||
useFocus(projectNameInput, { initialValue: true });
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -73,11 +81,11 @@ useFocus(projectNameInput, { initialValue: true });
|
|||||||
<InputLabel for="description" value="Description" />
|
<InputLabel for="description" value="Description" />
|
||||||
<TextInput
|
<TextInput
|
||||||
id="description"
|
id="description"
|
||||||
|
ref="description"
|
||||||
v-model="timeEntry.description"
|
v-model="timeEntry.description"
|
||||||
@keydown.enter="submit"
|
@keydown.enter="submit"
|
||||||
type="text"
|
type="text"
|
||||||
class="mt-1 block w-full"
|
class="mt-1 block w-full" />
|
||||||
autofocus />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user