diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 555e6e8..38dea98 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -799,6 +799,35 @@ + +
+ + +

Entry Templates

+ +
+
+
+

{{ tpl.name }}

+

+ {{ getTemplateProjectName(tpl.project_id) }} + - {{ formatTemplateDuration(tpl.duration) }} +

+
+ +
+
+

No saved templates. Use "Save as Template" in the Entries view.

@@ -1279,6 +1308,7 @@ import { useToastStore } from '../stores/toast' import { useOnboardingStore } from '../stores/onboarding' import { useRecurringStore } from '../stores/recurring' import type { RecurringEntry } from '../stores/recurring' +import { useEntryTemplatesStore } from '../stores/entryTemplates' import AppNumberInput from '../components/AppNumberInput.vue' import AppSelect from '../components/AppSelect.vue' import AppShortcutRecorder from '../components/AppShortcutRecorder.vue' @@ -1293,6 +1323,7 @@ import type { SoundEvent } from '../utils/audio' const settingsStore = useSettingsStore() const toastStore = useToastStore() const recurringStore = useRecurringStore() +const entryTemplatesStore = useEntryTemplatesStore() const onboardingStore = useOnboardingStore() const recurringEntries = computed(() => recurringStore.entries) @@ -1835,6 +1866,24 @@ function formatDuration(seconds: number): string { return `${m}m` } +// Entry template helpers +function getTemplateProjectName(projectId: number): string { + return recProjects.value.find(p => p.id === projectId)?.name || 'Unknown' +} + +function formatTemplateDuration(seconds: number): string { + const h = Math.floor(seconds / 3600) + const m = Math.floor((seconds % 3600) / 60) + if (h > 0 && m > 0) return `${h}h ${m}m` + if (h > 0) return `${h}h` + if (m > 0) return `${m}m` + return '0m' +} + +async function deleteEntryTemplate(id: number) { + await entryTemplatesStore.deleteTemplate(id) +} + function buildRecurrenceRule(): string { if (recPattern.value === 'weekly') { return 'weekly:' + recWeeklyDays.value.join(',') @@ -2113,6 +2162,9 @@ onMounted(async () => { await recurringStore.fetchEntries() recProjects.value = await invoke>('get_projects') + // Load entry templates + await entryTemplatesStore.fetchTemplates() + // Load calendar sources await fetchCalendarSources()