This commit is contained in:
@@ -12,7 +12,7 @@ const emit = defineEmits<{
|
||||
|
||||
const description = ref("");
|
||||
const selectedClientId = ref("");
|
||||
const selectedTags = ref<string[]>([]);
|
||||
const selectedTagId = ref<string | null>(null);
|
||||
const startDate = ref("");
|
||||
const startTime = ref("");
|
||||
const endDate = ref("");
|
||||
@@ -26,11 +26,10 @@ startDate.value = today;
|
||||
endDate.value = today;
|
||||
|
||||
function toggleTag(tagId: string) {
|
||||
const index = selectedTags.value.indexOf(tagId);
|
||||
if (index > -1) {
|
||||
selectedTags.value.splice(index, 1);
|
||||
if (selectedTagId.value === tagId) {
|
||||
selectedTagId.value = null;
|
||||
} else {
|
||||
selectedTags.value.push(tagId);
|
||||
selectedTagId.value = tagId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +96,7 @@ async function submitManualEntry() {
|
||||
clientId: selectedClientId.value,
|
||||
startTime: startDateTime,
|
||||
endTime: endDateTime,
|
||||
tags: selectedTags.value,
|
||||
tagId: selectedTagId.value,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -112,7 +111,7 @@ async function submitManualEntry() {
|
||||
|
||||
description.value = "";
|
||||
selectedClientId.value = "";
|
||||
selectedTags.value = [];
|
||||
selectedTagId.value = null;
|
||||
startDate.value = today;
|
||||
endDate.value = today;
|
||||
startTime.value = "";
|
||||
@@ -136,7 +135,7 @@ async function submitManualEntry() {
|
||||
function clearForm() {
|
||||
description.value = "";
|
||||
selectedClientId.value = "";
|
||||
selectedTags.value = [];
|
||||
selectedTagId.value = null;
|
||||
startDate.value = today;
|
||||
endDate.value = today;
|
||||
startTime.value = "";
|
||||
@@ -300,7 +299,7 @@ function clearForm() {
|
||||
@click="toggleTag(tag.id)"
|
||||
:class="[
|
||||
'badge badge-lg cursor-pointer transition-all hover:scale-105',
|
||||
selectedTags.includes(tag.id)
|
||||
selectedTagId === tag.id
|
||||
? 'badge-primary shadow-lg shadow-primary/20'
|
||||
: 'badge-outline hover:bg-base-300/50',
|
||||
]"
|
||||
|
||||
@@ -7,6 +7,7 @@ const props = defineProps<{
|
||||
startTime: number;
|
||||
description: string | null;
|
||||
clientId: string;
|
||||
tagId?: string;
|
||||
} | null;
|
||||
clients: { id: string; name: string }[];
|
||||
tags: { id: string; name: string; color: string | null }[];
|
||||
@@ -17,7 +18,7 @@ const startTime = ref<number | null>(null);
|
||||
const elapsedTime = ref(0);
|
||||
const description = ref("");
|
||||
const selectedClientId = ref("");
|
||||
const selectedTags = ref<string[]>([]);
|
||||
const selectedTagId = ref<string | null>(null);
|
||||
let interval: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
function formatTime(ms: number) {
|
||||
@@ -46,11 +47,10 @@ function formatTime(ms: number) {
|
||||
}
|
||||
|
||||
function toggleTag(tagId: string) {
|
||||
const index = selectedTags.value.indexOf(tagId);
|
||||
if (index > -1) {
|
||||
selectedTags.value.splice(index, 1);
|
||||
if (selectedTagId.value === tagId) {
|
||||
selectedTagId.value = null;
|
||||
} else {
|
||||
selectedTags.value.push(tagId);
|
||||
selectedTagId.value = tagId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ onMounted(() => {
|
||||
startTime.value = props.initialRunningEntry.startTime;
|
||||
description.value = props.initialRunningEntry.description || "";
|
||||
selectedClientId.value = props.initialRunningEntry.clientId;
|
||||
selectedTagId.value = props.initialRunningEntry.tagId || null;
|
||||
elapsedTime.value = Date.now() - startTime.value;
|
||||
interval = setInterval(() => {
|
||||
elapsedTime.value = Date.now() - startTime.value!;
|
||||
@@ -83,7 +84,7 @@ async function startTimer() {
|
||||
body: JSON.stringify({
|
||||
description: description.value,
|
||||
clientId: selectedClientId.value,
|
||||
tags: selectedTags.value,
|
||||
tagId: selectedTagId.value,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -109,7 +110,7 @@ async function stopTimer() {
|
||||
startTime.value = null;
|
||||
description.value = "";
|
||||
selectedClientId.value = "";
|
||||
selectedTags.value = [];
|
||||
selectedTagId.value = null;
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
@@ -163,7 +164,7 @@ async function stopTimer() {
|
||||
@click="toggleTag(tag.id)"
|
||||
:class="[
|
||||
'badge badge-lg cursor-pointer transition-all hover:scale-105',
|
||||
selectedTags.includes(tag.id)
|
||||
selectedTagId === tag.id
|
||||
? 'badge-primary shadow-lg shadow-primary/20'
|
||||
: 'badge-outline hover:bg-base-300/50',
|
||||
]"
|
||||
|
||||
Reference in New Issue
Block a user