mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 20:22:15 +01:00
only update the current time entry when the description was actually changed, not on all blur
This commit is contained in:
@@ -13,7 +13,7 @@ import type {
|
|||||||
TimeEntry,
|
TimeEntry,
|
||||||
Client,
|
Client,
|
||||||
} from '@/utils/api';
|
} from '@/utils/api';
|
||||||
import { ref } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import type { Dayjs } from 'dayjs';
|
import type { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
const currentTimeEntry = defineModel<TimeEntry>('currentTimeEntry', {
|
const currentTimeEntry = defineModel<TimeEntry>('currentTimeEntry', {
|
||||||
@@ -70,6 +70,19 @@ function onToggleButtonPress(newState: boolean) {
|
|||||||
emit('stopTimer');
|
emit('stopTimer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const tempDescription = ref(currentTimeEntry.value.description);
|
||||||
|
watch(
|
||||||
|
() => currentTimeEntry.value.description,
|
||||||
|
() => {
|
||||||
|
tempDescription.value = currentTimeEntry.value.description;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
function updateTimeEntryDescription() {
|
||||||
|
if (currentTimeEntry.value.description !== tempDescription.value) {
|
||||||
|
currentTimeEntry.value.description = tempDescription.value;
|
||||||
|
emit('updateTimeEntry');
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -83,9 +96,9 @@ function onToggleButtonPress(newState: boolean) {
|
|||||||
placeholder="What are you working on?"
|
placeholder="What are you working on?"
|
||||||
data-testid="time_entry_description"
|
data-testid="time_entry_description"
|
||||||
ref="currentTimeEntryDescriptionInput"
|
ref="currentTimeEntryDescriptionInput"
|
||||||
v-model="currentTimeEntry.description"
|
v-model="tempDescription"
|
||||||
@keydown.enter="startTimerIfNotActive"
|
@keydown.enter="startTimerIfNotActive"
|
||||||
@blur="$emit('updateTimeEntry')"
|
@blur="updateTimeEntryDescription"
|
||||||
class="w-full rounded-l-lg py-4 sm:py-2.5 px-3.5 border-b border-b-card-background-separator lg:px-4 text-base @4xl:text-lg text-white font-medium bg-transparent border-none placeholder-muted focus:ring-0 transition"
|
class="w-full rounded-l-lg py-4 sm:py-2.5 px-3.5 border-b border-b-card-background-separator lg:px-4 text-base @4xl:text-lg text-white font-medium bg-transparent border-none placeholder-muted focus:ring-0 transition"
|
||||||
type="text" />
|
type="text" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user