add context menus to calendar view + ui package

This commit is contained in:
Gregor Vostrak
2026-03-03 14:42:35 +01:00
parent 192c8c3b88
commit 452acca942
20 changed files with 705 additions and 30 deletions

View File

@@ -9,7 +9,9 @@ import {
type CreateClientBody,
type CreateProjectBody,
type Project,
type TimeEntry,
} from '@/packages/api/src';
import { getDayJsInstance } from '@/packages/ui/src/utils/time';
import { TimeEntryCalendar } from '@/packages/ui/src';
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
import { useTagsStore } from '@/utils/useTags';
@@ -55,6 +57,39 @@ async function deleteTimeEntry(timeEntryId: string): Promise<void> {
await deleteTimeEntryMutation(timeEntryId);
}
async function duplicateTimeEntry(entry: TimeEntry): Promise<void> {
await createTimeEntryMutation({
start: entry.start,
end: entry.end,
billable: entry.billable,
description: entry.description,
project_id: entry.project_id,
task_id: entry.task_id,
tags: entry.tags,
});
}
async function splitTimeEntry(entry: TimeEntry): Promise<void> {
if (!entry.end) return;
const start = getDayJsInstance()(entry.start);
const end = getDayJsInstance()(entry.end);
const midpoint = start.add(end.diff(start) / 2, 'millisecond').startOf('minute');
// Update the original entry to end at the midpoint
await updateTimeEntryMutation({ ...entry, end: midpoint.utc().format() });
// Create a new entry from midpoint to original end
await createTimeEntryMutation({
start: midpoint.utc().format(),
end: entry.end,
billable: entry.billable,
description: entry.description,
project_id: entry.project_id,
task_id: entry.task_id,
tags: entry.tags,
});
}
async function createTag(name: string) {
return await useTagsStore().createTag(name);
}
@@ -101,6 +136,8 @@ function onRefresh() {
:create-time-entry="createTimeEntry"
:update-time-entry="updateTimeEntry"
:delete-time-entry="deleteTimeEntry"
:duplicate-time-entry="duplicateTimeEntry"
:split-time-entry="splitTimeEntry"
:create-client="createClient"
:create-project="createProject"
:create-tag="createTag"