current init
This commit is contained in:
276
frontend/src/views/AllTasksView.vue
Normal file
276
frontend/src/views/AllTasksView.vue
Normal file
@@ -0,0 +1,276 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { getAllSchemas, getAllTasks, toggleTask } from '../services/api'
|
||||
import CategoryBadge from '../components/CategoryBadge.vue'
|
||||
import Icon from '../components/Icon.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const items = ref([])
|
||||
const loading = ref(true)
|
||||
const mode = ref('schemas')
|
||||
|
||||
async function fetchData(showLoading = true) {
|
||||
if (showLoading) loading.value = true
|
||||
items.value = mode.value === 'schemas'
|
||||
? await getAllSchemas()
|
||||
: await getAllTasks()
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
function switchMode(newMode) {
|
||||
mode.value = newMode
|
||||
fetchData()
|
||||
}
|
||||
|
||||
function formatDate(dateStr) {
|
||||
return new Date(dateStr + 'T00:00:00').toLocaleDateString('de-DE', {
|
||||
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||
})
|
||||
}
|
||||
|
||||
const groupedItems = computed(() => {
|
||||
const today = new Date().toISOString().split('T')[0]
|
||||
const noDate = items.value.filter(i => !i.deadline)
|
||||
const current = items.value.filter(i => i.deadline && i.deadline >= today)
|
||||
const past = items.value.filter(i => i.deadline && i.deadline < today)
|
||||
|
||||
const monthMap = {}
|
||||
const months = []
|
||||
for (const item of past) {
|
||||
const d = new Date(item.deadline + 'T00:00:00')
|
||||
const sortKey = item.deadline.substring(0, 7)
|
||||
const label = d.toLocaleDateString('de-DE', { month: 'long', year: 'numeric' })
|
||||
if (!monthMap[sortKey]) {
|
||||
monthMap[sortKey] = { sortKey, label, items: [] }
|
||||
months.push(monthMap[sortKey])
|
||||
}
|
||||
monthMap[sortKey].items.push(item)
|
||||
}
|
||||
months.sort((a, b) => b.sortKey.localeCompare(a.sortKey))
|
||||
|
||||
return { noDate, current, months }
|
||||
})
|
||||
|
||||
async function handleToggle(item) {
|
||||
await toggleTask(item.schemaId, item.deadline)
|
||||
await fetchData(false)
|
||||
}
|
||||
|
||||
onMounted(fetchData)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="header-row">
|
||||
<button @click="router.push({ name: 'categories' })">Kategorien</button>
|
||||
<div class="btn-row">
|
||||
<button class="btn-primary" @click="router.push({ name: 'schema-create' })">
|
||||
<Icon name="plus" />
|
||||
</button>
|
||||
<button @click="router.back()"><Icon name="arrowLeft" /></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="filter-row">
|
||||
<div class="toggle-group">
|
||||
<button :class="{ 'btn-primary': mode === 'schemas' }" @click="switchMode('schemas')">
|
||||
Alle Schemas
|
||||
</button>
|
||||
<button :class="{ 'btn-primary': mode === 'occurrences' }" @click="switchMode('occurrences')">
|
||||
Alle Aufgaben
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="loading" class="loading">Laden...</p>
|
||||
|
||||
<ul v-else class="task-list">
|
||||
<!-- Schema-Modus: Anzeigen-Button -->
|
||||
<template v-if="mode === 'schemas'">
|
||||
<li v-for="(item, index) in items" :key="index" class="task-item">
|
||||
<div class="task-left">
|
||||
<span class="task-name">{{ item.name }}</span>
|
||||
<CategoryBadge :category="item.category" />
|
||||
</div>
|
||||
<button @click="router.push({ name: 'schema-detail', params: { id: item.id } })">
|
||||
Anzeigen
|
||||
</button>
|
||||
</li>
|
||||
</template>
|
||||
<!-- Aufgaben-Modus: gruppiert -->
|
||||
<template v-else>
|
||||
<!-- Ohne Datum -->
|
||||
<li
|
||||
v-for="(item, i) in groupedItems.noDate"
|
||||
:key="'nd-' + i"
|
||||
class="task-item task-item--clickable"
|
||||
@click="handleToggle(item)"
|
||||
>
|
||||
<div class="task-left">
|
||||
<span class="task-name" :class="{ 'task--completed': item.status === 'erledigt' }">{{ item.name }}</span>
|
||||
<CategoryBadge :category="item.category" />
|
||||
</div>
|
||||
<div class="task-right" @click.stop>
|
||||
<button @click="router.push({ name: 'task-detail', params: { id: item.taskId } })">Anzeigen</button>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<!-- Aktuell -->
|
||||
<li v-if="groupedItems.current.length" class="section-header"><span>Aktuell</span></li>
|
||||
<li
|
||||
v-for="(item, i) in groupedItems.current"
|
||||
:key="'cur-' + i"
|
||||
class="task-item task-item--clickable"
|
||||
@click="handleToggle(item)"
|
||||
>
|
||||
<div class="task-left">
|
||||
<span class="task-name" :class="{ 'task--completed': item.status === 'erledigt' }">{{ item.name }}</span>
|
||||
<CategoryBadge :category="item.category" />
|
||||
</div>
|
||||
<div class="task-right" @click.stop>
|
||||
<span class="task-date">{{ formatDate(item.deadline) }}</span>
|
||||
<button @click="router.push({ name: 'task-detail', params: { id: item.taskId } })">Anzeigen</button>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<!-- Vergangene Monate -->
|
||||
<template v-for="month in groupedItems.months" :key="month.sortKey">
|
||||
<li class="section-header"><span>{{ month.label }}</span></li>
|
||||
<li
|
||||
v-for="(item, i) in month.items"
|
||||
:key="month.sortKey + '-' + i"
|
||||
class="task-item task-item--clickable task-item--past"
|
||||
@click="handleToggle(item)"
|
||||
>
|
||||
<div class="task-left">
|
||||
<span class="task-name" :class="{ 'task--completed': item.status === 'erledigt' }">{{ item.name }}</span>
|
||||
<CategoryBadge :category="item.category" />
|
||||
</div>
|
||||
<span class="task-date">{{ formatDate(item.deadline) }}</span>
|
||||
</li>
|
||||
</template>
|
||||
</template>
|
||||
</ul>
|
||||
|
||||
<p v-if="!loading && items.length === 0" class="empty">Keine Einträge.</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.filter-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.toggle-group {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.toggle-group button {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.toggle-group button:first-child {
|
||||
border-radius: 6px 0 0 6px;
|
||||
}
|
||||
|
||||
.toggle-group button:last-child {
|
||||
border-radius: 0 6px 6px 0;
|
||||
}
|
||||
|
||||
.task-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.task-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.6rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.task-item:has(+ .section-header) {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.task-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.task-name {
|
||||
font-weight: 500;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
.task--completed {
|
||||
text-decoration: line-through;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.task-item--clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.task-item--clickable:hover {
|
||||
background: var(--accent-bg);
|
||||
}
|
||||
|
||||
.task-item--past {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
list-style: none;
|
||||
margin-top: 1rem;
|
||||
padding: 0;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.section-header span {
|
||||
margin-top: -0.7rem;
|
||||
background: var(--bg);
|
||||
padding: 0.15rem 0.75rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 999px;
|
||||
font-weight: 600;
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
.task-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.task-date {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.loading, .empty {
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
margin-top: 2rem;
|
||||
}
|
||||
</style>
|
||||
141
frontend/src/views/CategoriesView.vue
Normal file
141
frontend/src/views/CategoriesView.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useCategoriesStore } from '../stores/categories'
|
||||
import CategoryBadge from '../components/CategoryBadge.vue'
|
||||
import Icon from '../components/Icon.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const store = useCategoriesStore()
|
||||
|
||||
const newName = ref('')
|
||||
const newColor = ref('#808080')
|
||||
const editingId = ref(null)
|
||||
const editName = ref('')
|
||||
const editColor = ref('')
|
||||
|
||||
onMounted(() => store.fetchCategories(true))
|
||||
|
||||
async function add() {
|
||||
if (!newName.value.trim()) return
|
||||
await store.addCategory({ name: newName.value.trim(), color: newColor.value })
|
||||
newName.value = ''
|
||||
newColor.value = '#808080'
|
||||
}
|
||||
|
||||
function startEdit(cat) {
|
||||
editingId.value = cat.id
|
||||
editName.value = cat.name
|
||||
editColor.value = cat.color
|
||||
}
|
||||
|
||||
async function saveEdit() {
|
||||
if (!editName.value.trim()) return
|
||||
await store.editCategory(editingId.value, { name: editName.value.trim(), color: editColor.value })
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
async function remove(id) {
|
||||
await store.removeCategory(id)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="header-row">
|
||||
<div></div>
|
||||
<button @click="router.back()"><Icon name="arrowLeft" /></button>
|
||||
</div>
|
||||
|
||||
<div class="new-form">
|
||||
<input v-model="newName" type="text" placeholder="Name" />
|
||||
<input v-model="newColor" type="color" class="color-input" />
|
||||
<button class="btn-primary" @click="add"><Icon name="plus" /></button>
|
||||
</div>
|
||||
|
||||
<ul class="category-list">
|
||||
<li v-for="cat in store.items" :key="cat.id" class="category-item">
|
||||
<template v-if="editingId === cat.id">
|
||||
<input v-model="editName" type="text" />
|
||||
<input v-model="editColor" type="color" class="color-input" />
|
||||
<div class="btn-row">
|
||||
<button class="btn-primary" @click="saveEdit"><Icon name="save" /></button>
|
||||
<button @click="editingId = null"><Icon name="close" /></button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<CategoryBadge :category="cat" />
|
||||
<span class="category-name">{{ cat.name }}</span>
|
||||
<div class="btn-row">
|
||||
<button @click="startEdit(cat)"><Icon name="edit" /></button>
|
||||
<button class="btn-danger" @click="remove(cat.id)"><Icon name="trash" /></button>
|
||||
</div>
|
||||
</template>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p v-if="store.loaded && store.items.length === 0" class="empty">
|
||||
Keine Kategorien vorhanden.
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.new-form {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.new-form input[type="text"] {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.color-input {
|
||||
width: 40px;
|
||||
height: 36px;
|
||||
padding: 2px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.category-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.category-item input[type="text"] {
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.category-name {
|
||||
flex: 1;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
.empty {
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
margin-top: 2rem;
|
||||
}
|
||||
</style>
|
||||
107
frontend/src/views/HomeView.vue
Normal file
107
frontend/src/views/HomeView.vue
Normal file
@@ -0,0 +1,107 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useCategoriesStore } from '../stores/categories'
|
||||
import { getWeekTasks, toggleTask } from '../services/api'
|
||||
import DayColumn from '../components/DayColumn.vue'
|
||||
import TaskCard from '../components/TaskCard.vue'
|
||||
import Icon from '../components/Icon.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const categoriesStore = useCategoriesStore()
|
||||
|
||||
const rawDays = ref([])
|
||||
const rawTasksWithoutDeadline = ref([])
|
||||
const loading = ref(true)
|
||||
const showCompleted = ref(true)
|
||||
|
||||
function filterTasks(tasks) {
|
||||
if (showCompleted.value) return tasks
|
||||
return tasks.filter(t => t.status !== 'erledigt')
|
||||
}
|
||||
|
||||
const tasksWithoutDeadline = computed(() => filterTasks(rawTasksWithoutDeadline.value))
|
||||
const days = computed(() => rawDays.value.map(d => ({
|
||||
...d,
|
||||
tasks: filterTasks(d.tasks),
|
||||
})))
|
||||
|
||||
async function fetchWeek(showLoading = true) {
|
||||
if (showLoading) loading.value = true
|
||||
try {
|
||||
const data = await getWeekTasks()
|
||||
rawDays.value = data.days
|
||||
rawTasksWithoutDeadline.value = data.tasksWithoutDeadline
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleToggle(taskId, date) {
|
||||
await toggleTask(taskId, date)
|
||||
await fetchWeek(false)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
categoriesStore.fetchCategories()
|
||||
fetchWeek()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="top-bar">
|
||||
<div></div>
|
||||
<div class="btn-row">
|
||||
<button @click="router.push({ name: 'tasks-all' })">Übersicht</button>
|
||||
<button @click="showCompleted = !showCompleted" :title="showCompleted ? 'Erledigte ausblenden' : 'Erledigte anzeigen'">
|
||||
<Icon :name="showCompleted ? 'eyeOpen' : 'eyeClosed'" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="loading" class="loading">Laden...</p>
|
||||
|
||||
<template v-else>
|
||||
<div v-if="tasksWithoutDeadline.length" class="no-deadline-section">
|
||||
<TaskCard
|
||||
v-for="task in tasksWithoutDeadline"
|
||||
:key="task.id"
|
||||
:task="task"
|
||||
@toggle="handleToggle"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<DayColumn
|
||||
v-for="day in days"
|
||||
:key="day.date"
|
||||
:date="day.date"
|
||||
:tasks="day.tasks"
|
||||
@toggle="handleToggle"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.top-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1.5rem;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.no-deadline-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
</style>
|
||||
278
frontend/src/views/SchemaView.vue
Normal file
278
frontend/src/views/SchemaView.vue
Normal file
@@ -0,0 +1,278 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, inject } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useCategoriesStore } from '../stores/categories'
|
||||
import { getSchema, createSchema, updateSchema, deleteSchema } from '../services/api'
|
||||
import WeekdayPicker from '../components/WeekdayPicker.vue'
|
||||
import MonthdayPicker from '../components/MonthdayPicker.vue'
|
||||
import YearPicker from '../components/YearPicker.vue'
|
||||
import Icon from '../components/Icon.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const categoriesStore = useCategoriesStore()
|
||||
|
||||
const setDynamicLabel = inject('setDynamicLabel')
|
||||
const isEdit = computed(() => !!route.params.id)
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const error = ref(null)
|
||||
|
||||
const form = ref({
|
||||
name: '',
|
||||
categoryId: null,
|
||||
status: 'aktiv',
|
||||
taskType: 'einzel',
|
||||
deadline: null,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
weekdays: [],
|
||||
monthDays: [],
|
||||
yearDays: [],
|
||||
})
|
||||
|
||||
function formatDateForInput(dateStr) {
|
||||
if (!dateStr) return null
|
||||
return dateStr.split('T')[0]
|
||||
}
|
||||
|
||||
async function loadTask() {
|
||||
loading.value = true
|
||||
try {
|
||||
const task = await getSchema(route.params.id)
|
||||
form.value = {
|
||||
name: task.name,
|
||||
categoryId: task.category?.id ?? null,
|
||||
status: task.status,
|
||||
taskType: task.taskType,
|
||||
deadline: formatDateForInput(task.deadline),
|
||||
startDate: formatDateForInput(task.startDate),
|
||||
endDate: formatDateForInput(task.endDate),
|
||||
weekdays: task.weekdays || [],
|
||||
monthDays: task.monthDays || [],
|
||||
yearDays: task.yearDays || [],
|
||||
}
|
||||
setDynamicLabel(task.name)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function buildPayload() {
|
||||
const f = form.value
|
||||
const payload = {
|
||||
name: f.name,
|
||||
categoryId: f.categoryId,
|
||||
status: f.status,
|
||||
taskType: f.taskType,
|
||||
deadline: null,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
weekdays: null,
|
||||
monthDays: null,
|
||||
yearDays: null,
|
||||
}
|
||||
|
||||
if (f.taskType === 'einzel') {
|
||||
payload.deadline = f.deadline
|
||||
} else {
|
||||
payload.startDate = f.startDate
|
||||
payload.endDate = f.endDate
|
||||
if (f.taskType === 'woechentlich') payload.weekdays = f.weekdays
|
||||
if (f.taskType === 'monatlich') payload.monthDays = f.monthDays
|
||||
if (f.taskType === 'multi' || f.taskType === 'jaehrlich') payload.yearDays = f.yearDays
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const payload = buildPayload()
|
||||
if (isEdit.value) {
|
||||
await updateSchema(route.params.id, payload)
|
||||
} else {
|
||||
await createSchema(payload)
|
||||
}
|
||||
router.back()
|
||||
} catch (e) {
|
||||
error.value = 'Speichern fehlgeschlagen.'
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function remove() {
|
||||
if (!confirm('Aufgabe wirklich löschen?')) return
|
||||
await deleteSchema(route.params.id)
|
||||
router.back()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
categoriesStore.fetchCategories()
|
||||
if (isEdit.value) loadTask()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="header-row">
|
||||
<div></div>
|
||||
<div class="btn-row">
|
||||
<button type="submit" form="task-form" class="btn-primary" :disabled="saving">
|
||||
<Icon name="save" />
|
||||
</button>
|
||||
<button @click="router.back()"><Icon name="arrowLeft" /></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="loading" class="loading">Laden...</p>
|
||||
|
||||
<form v-else id="task-form" @submit.prevent="save">
|
||||
<!-- Name + Kategorie nebeneinander -->
|
||||
<div class="form-row">
|
||||
<div class="form-group flex-1">
|
||||
<label for="name">Name</label>
|
||||
<input id="name" v-model="form.name" type="text" required />
|
||||
</div>
|
||||
<div class="form-group flex-1">
|
||||
<label for="category">Kategorie</label>
|
||||
<select id="category" v-model="form.categoryId">
|
||||
<option :value="null">Keine Kategorie</option>
|
||||
<option v-for="cat in categoriesStore.items" :key="cat.id" :value="cat.id">
|
||||
{{ cat.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isEdit" class="form-group">
|
||||
<label for="status">Status</label>
|
||||
<select id="status" v-model="form.status">
|
||||
<option value="aktiv">Aktiv</option>
|
||||
<option value="erledigt">Erledigt</option>
|
||||
<option value="inaktiv">Inaktiv</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Aufgabentyp -->
|
||||
<div class="form-group">
|
||||
<label>Aufgabentyp</label>
|
||||
<div class="radio-group">
|
||||
<label class="radio-label">
|
||||
<input type="radio" v-model="form.taskType" value="einzel" /> Einzel
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" v-model="form.taskType" value="taeglich" /> Täglich
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" v-model="form.taskType" value="multi" /> Multi
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" v-model="form.taskType" value="woechentlich" /> Wöchentlich
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" v-model="form.taskType" value="monatlich" /> Monatlich
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" v-model="form.taskType" value="jaehrlich" /> Jährlich
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Einzel: Datum -->
|
||||
<div v-if="form.taskType === 'einzel'" class="form-group">
|
||||
<label for="deadline">Datum (optional)</label>
|
||||
<input id="deadline" v-model="form.deadline" type="date" />
|
||||
</div>
|
||||
|
||||
<!-- Alle außer Einzel: Start + Enddatum nebeneinander -->
|
||||
<template v-if="form.taskType !== 'einzel'">
|
||||
<div class="form-row">
|
||||
<div class="form-group flex-1">
|
||||
<label for="startDate">Startdatum (leer = heute)</label>
|
||||
<input id="startDate" v-model="form.startDate" type="date" />
|
||||
</div>
|
||||
<div class="form-group flex-1">
|
||||
<label for="endDate">Enddatum (optional)</label>
|
||||
<input id="endDate" v-model="form.endDate" type="date" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Wöchentlich -->
|
||||
<div v-if="form.taskType === 'woechentlich'" class="form-group">
|
||||
<label>Wochentage</label>
|
||||
<WeekdayPicker v-model="form.weekdays" />
|
||||
</div>
|
||||
|
||||
<!-- Monatlich -->
|
||||
<div v-if="form.taskType === 'monatlich'" class="form-group">
|
||||
<label>Monatstage</label>
|
||||
<MonthdayPicker v-model="form.monthDays" />
|
||||
</div>
|
||||
|
||||
<!-- Multi + Jährlich -->
|
||||
<div v-if="form.taskType === 'multi' || form.taskType === 'jaehrlich'" class="form-group">
|
||||
<label>Jahresansicht</label>
|
||||
<YearPicker v-model="form.yearDays" />
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
|
||||
<div v-if="isEdit" class="form-actions">
|
||||
<button type="button" class="btn-danger" @click="remove">
|
||||
<Icon name="trash" />
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.radio-group {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.radio-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.error {
|
||||
color: var(--danger);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
122
frontend/src/views/TaskDetailView.vue
Normal file
122
frontend/src/views/TaskDetailView.vue
Normal file
@@ -0,0 +1,122 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, inject } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { getTask, updateTask, deleteTask } from '../services/api'
|
||||
import { useCategoriesStore } from '../stores/categories'
|
||||
import Icon from '../components/Icon.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const setDynamicLabel = inject('setDynamicLabel')
|
||||
|
||||
const categoriesStore = useCategoriesStore()
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
const occurrence = ref(null)
|
||||
const form = ref({ name: '', status: 'aktiv', date: '', categoryId: null })
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
const data = await getTask(route.params.id)
|
||||
occurrence.value = data
|
||||
form.value = { name: data.name, status: data.status, date: data.date, categoryId: data.category?.id ?? null }
|
||||
setDynamicLabel(data.name)
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
await updateTask(route.params.id, {
|
||||
name: form.value.name,
|
||||
categoryId: form.value.categoryId,
|
||||
status: form.value.status,
|
||||
date: form.value.date || null,
|
||||
})
|
||||
saving.value = false
|
||||
router.back()
|
||||
}
|
||||
|
||||
async function remove() {
|
||||
if (!confirm('Aufgabe wirklich löschen?')) return
|
||||
await deleteTask(route.params.id)
|
||||
router.back()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
categoriesStore.fetchCategories()
|
||||
load()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="header-row">
|
||||
<button type="button" class="btn-danger" @click="remove">
|
||||
<Icon name="trash" />
|
||||
</button>
|
||||
<div class="btn-row">
|
||||
<button class="btn-primary" :disabled="saving" @click="save">
|
||||
<Icon name="save" />
|
||||
</button>
|
||||
<button @click="router.back()"><Icon name="arrowLeft" /></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="loading" class="loading">Laden...</p>
|
||||
|
||||
<div v-else>
|
||||
<div class="form-row">
|
||||
<div class="form-group flex-1">
|
||||
<label for="name">Name</label>
|
||||
<input id="name" v-model="form.name" type="text" required />
|
||||
</div>
|
||||
<div class="form-group flex-1">
|
||||
<label for="category">Kategorie</label>
|
||||
<select id="category" v-model="form.categoryId">
|
||||
<option :value="null">Keine Kategorie</option>
|
||||
<option v-for="cat in categoriesStore.items" :key="cat.id" :value="cat.id">
|
||||
{{ cat.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group flex-1">
|
||||
<label for="status">Status</label>
|
||||
<select id="status" v-model="form.status">
|
||||
<option value="aktiv">Aktiv</option>
|
||||
<option value="erledigt">Erledigt</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group flex-1">
|
||||
<label for="date">Datum</label>
|
||||
<input id="date" v-model="form.date" type="date" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.header-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user