reset to setup module state
Remove Task Manager implementation to match `# Setup module` in module.md. Backend src/ reduced to Kernel.php + empty Entity/, all migrations deleted, database dropped and recreated. Frontend components/views/services/stores removed, App.vue/router/style.css reduced to skeletons. CLAUDE.md shortened to Setup-stand. Old backend/plan.md, plan2.md removed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
171
CLAUDE.md
171
CLAUDE.md
@@ -1,158 +1,50 @@
|
||||
# Haushalt — Aufgabenverwaltung
|
||||
# Haushalt
|
||||
|
||||
Basis-Software mit 3 geplanten Apps: Task Manager, Shopping List, Meal Planner.
|
||||
|
||||
Aktueller Stand: **Setup module** (siehe `module.md`) — minimales Symfony + Vue Gerüst, kein Feature-Code.
|
||||
|
||||
## Tech-Stack
|
||||
|
||||
| Schicht | Technologie |
|
||||
|---------|------------|
|
||||
| Backend | Symfony 7.4, PHP 8.2+, Doctrine ORM 3.6 |
|
||||
| Frontend Web | Vue 3 (Composition API), Vite 8, Pinia, Vue Router 4 |
|
||||
| Datenbank | MySQL/MariaDB (utf8mb4) |
|
||||
| Backend | Symfony 7.4, PHP 8.3, Doctrine ORM |
|
||||
| Frontend Web | Vue 3 (Composition API), Vite, Pinia, Vue Router 4 |
|
||||
| Frontend Mobile | Kotlin + Jetpack Compose (noch nicht aufgesetzt) |
|
||||
| Datenbank | MariaDB 10.11 (utf8mb4) |
|
||||
| CORS | Nelmio CORS Bundle |
|
||||
| Umgebung | DDEV |
|
||||
|
||||
## Domain-Modell
|
||||
|
||||
**Task** — Einzelne Aufgabe
|
||||
- Felder: id, name, status, date, schema (nullable FK), category (nullable FK), createdAt
|
||||
- TaskStatus: Active (`active`), Done (`done`)
|
||||
- Tasks mit schema=null sind standalone (z.B. aus Single-Schemas erstellt)
|
||||
- Tasks mit schema!=null gehören zu einem wiederkehrenden Schema
|
||||
|
||||
**TaskSchema** — Template für wiederkehrende Aufgaben
|
||||
- Felder: id, name, status, taskType, category, startDate, endDate, days, createdAt
|
||||
- TaskSchemaStatus: Active (`active`), Disabled (`disabled`)
|
||||
- TaskSchemaType: Single (`single`), Daily (`daily`), Custom (`custom`)
|
||||
- `days`: JSON-Feld mit optionalen Keys: `week` (1-7), `month` (1-31), `year` ([{month, day}])
|
||||
- Single: Erstellt Tasks via YearPicker, Tasks werden detached (schema=null), Schema löscht sich automatisch
|
||||
- Daily: Erstellt Tasks für jeden Tag im Zeitraum start–end
|
||||
- Custom: Erstellt Tasks basierend auf days-Konfiguration im Zeitraum start–end
|
||||
- Disabled: Generiert keine neuen Tasks, bestehende bleiben
|
||||
|
||||
**Category** — Farbkodierte Kategorie
|
||||
- Felder: id, name, color (Hex #RRGGBB)
|
||||
|
||||
Enum-Case-Namen und DB-Werte sind Englisch.
|
||||
|
||||
## Architektur (Backend)
|
||||
## Struktur
|
||||
|
||||
```
|
||||
Controller → Service (Manager) → Repository → Entity
|
||||
↓
|
||||
DTO (Request)
|
||||
backend/
|
||||
src/
|
||||
Kernel.php — Standard-Symfony-Kernel, keine App-Klassen
|
||||
config/ — Symfony-Config (nelmio_cors, doctrine, framework, ...)
|
||||
migrations/ — leer
|
||||
public/index.php — Symfony-Einstieg
|
||||
frontend/
|
||||
src/
|
||||
main.js — Vue-Init mit Pinia + Router
|
||||
App.vue — RouterView, kein Content
|
||||
router/index.js — Router mit leerem routes-Array
|
||||
style.css — leer
|
||||
index.html, vite.config.js
|
||||
```
|
||||
|
||||
**Prinzipien:**
|
||||
- Controller: nur Routing + Response, keine Geschäftslogik
|
||||
- Manager-Services: Geschäftslogik (CRUD, Validierung, Toggle)
|
||||
- DTOs: typisierter Input (Request)
|
||||
- Validierung: nur auf Request-DTOs (`#[Assert\...]`), nicht auf Entities
|
||||
- Entities: Doctrine-Mapping + Getter/Setter, Serializer-Groups für API-Output
|
||||
- Task-Generierung: Lazy beim Aufruf von GET /api/tasks (nicht per Cronjob)
|
||||
## Dokumentation
|
||||
|
||||
## Verzeichnisstruktur (Backend)
|
||||
|
||||
```
|
||||
backend/src/
|
||||
Controller/Api/
|
||||
CategoryController.php — Category CRUD
|
||||
TaskController.php — Task CRUD + index + toggle
|
||||
TaskSchemaController.php — Schema CRUD
|
||||
DTO/
|
||||
Request/ — CreateSchemaRequest, UpdateSchemaRequest, CreateTaskRequest,
|
||||
UpdateTaskRequest, CreateCategoryRequest, UpdateCategoryRequest,
|
||||
SchemaValidationTrait
|
||||
Entity/
|
||||
Category.php, Task.php, TaskSchema.php
|
||||
Enum/
|
||||
TaskStatus.php, TaskSchemaStatus.php, TaskSchemaType.php
|
||||
Repository/
|
||||
CategoryRepository.php, TaskRepository.php, TaskSchemaRepository.php
|
||||
Service/
|
||||
CategoryManager.php — Category CRUD-Logik
|
||||
TaskManager.php — Task Create/Update/Delete/Toggle
|
||||
TaskSchemaManager.php — Schema CRUD + Single-Flow + Sync-Auslösung
|
||||
TaskGenerator.php — Erzeugt Task-Instanzen für Zeiträume (lazy)
|
||||
TaskSynchronizer.php — Sync nach Schema-Update (löschen/erstellen/reset)
|
||||
DeadlineCalculator.php — Berechnet Fälligkeitsdaten für Daily/Custom-Schemas
|
||||
```
|
||||
|
||||
## API-Routen
|
||||
|
||||
### Tasks (`/api/tasks`)
|
||||
```
|
||||
GET / — Alle Tasks (triggert Task-Generierung)
|
||||
GET /{id} — Task-Details
|
||||
POST / — Task direkt erstellen (schema=null)
|
||||
PUT /{id} — Task aktualisieren
|
||||
DELETE /{id} — Task löschen
|
||||
PATCH /{id}/toggle — Status Active↔Done umschalten
|
||||
```
|
||||
|
||||
### Schemas (`/api/schemas`)
|
||||
```
|
||||
GET / — Alle Schemas
|
||||
GET /{id} — Einzelnes Schema
|
||||
POST / — Erstellen (Single: erstellt Tasks + löscht Schema)
|
||||
PUT /{id} — Aktualisieren (synchronisiert zukünftige Tasks)
|
||||
DELETE /{id} — Löschen (?deleteTasks=1 für Task-Löschung)
|
||||
```
|
||||
|
||||
### Categories (`/api/categories`)
|
||||
```
|
||||
GET / — Alle Kategorien
|
||||
GET /{id} — Einzelne Kategorie
|
||||
POST / — Erstellen
|
||||
PUT /{id} — Aktualisieren
|
||||
DELETE /{id} — Löschen
|
||||
```
|
||||
|
||||
## Verzeichnisstruktur (Frontend)
|
||||
|
||||
```
|
||||
frontend/src/
|
||||
views/
|
||||
HomeView.vue — Startseite, Wochenansicht (client-seitig berechnet)
|
||||
AllTasksView.vue — Übersicht aller Schemas/Tasks
|
||||
SchemaView.vue — Schema erstellen/bearbeiten (3 Typen)
|
||||
TaskDetailView.vue — Einzelne Aufgabe bearbeiten
|
||||
CategoriesView.vue — Kategorien verwalten
|
||||
components/
|
||||
TaskCard.vue — Aufgaben-Karte (klickbar zum Toggle)
|
||||
DayColumn.vue — Tages-Spalte in Wochenansicht
|
||||
CategoryBadge.vue — Kategorie-Badge mit Farbe
|
||||
Icon.vue — SVG-Icons (eyeOpen, eyeClosed, plus, arrowLeft, save, trash, edit, close)
|
||||
WeekdayPicker.vue — Wochentag-Auswahl (Mo-So)
|
||||
MonthdayPicker.vue — Monatstag-Auswahl (Kalender-Grid)
|
||||
YearPicker.vue — Jahreskalender-Auswahl
|
||||
router/index.js — Routen mit Breadcrumb-Meta
|
||||
services/api.js — REST-Client (fetch-basiert)
|
||||
stores/categories.js — Pinia Store für Kategorien
|
||||
style.css — Globale Styles, CSS-Variablen, Light/Dark Mode
|
||||
App.vue — Root-Layout mit Breadcrumb-Navigation
|
||||
main.js — Vue-App-Init (Pinia + Router)
|
||||
```
|
||||
|
||||
## Frontend-Routen
|
||||
|
||||
```
|
||||
/ → HomeView (Wochenansicht)
|
||||
/tasks/all → AllTasksView (Übersicht)
|
||||
/tasks/new → SchemaView (Schema erstellen)
|
||||
/tasks/:id → TaskDetailView (Aufgabe bearbeiten)
|
||||
/schemas/:id → SchemaView (Schema bearbeiten)
|
||||
/categories → CategoriesView
|
||||
```
|
||||
- **`base.md`** — Vision: was gebaut wird (3 Apps, Systeme, Datenbank-Skizze)
|
||||
- **`module.md`** — Implementierungs-Schritte als Feature-Module (Backend + Frontend end-to-end pro Modul)
|
||||
- **`CLAUDE.md`** (diese Datei) — Ist-Zustand des Codes
|
||||
|
||||
## Code-Konventionen
|
||||
|
||||
- **Sprache Code**: Englisch (Klassen, Methoden, Variablen, CSS-Klassen)
|
||||
- **Sprache UI**: Deutsch (Labels, Fehlermeldungen, Platzhalter)
|
||||
- **Enum-Werte**: Englisch in DB und Code (`active`, `done`, `single`, `daily`, `custom`, `disabled`)
|
||||
- **API-Serialisierung**: Symfony Serializer-Groups auf Entities (`schema:read`, `task:read`, `category:read`)
|
||||
- **Validierung**: Auf Request-DTOs, nicht auf Entities
|
||||
- **Error-Handling**: `HttpException` → Symfony built-in
|
||||
- **Frontend**: Vue 3 Composition API mit `<script setup>`, fetch-basierter API-Client
|
||||
- **Wochenansicht**: Frontend berechnet Mo-So client-seitig aus allen Tasks
|
||||
- **Sprache Code**: Englisch (Klassen, Methoden, Variablen)
|
||||
- **Sprache UI**: Deutsch
|
||||
- **Enum-Werte**: Englisch in DB und Code
|
||||
- **Frontend**: Vue 3 Composition API mit `<script setup>`
|
||||
|
||||
## Development
|
||||
|
||||
@@ -162,7 +54,6 @@ ddev start
|
||||
|
||||
# Backend
|
||||
ddev exec "cd backend && php bin/console cache:clear"
|
||||
ddev exec "cd backend && php bin/console doctrine:migrations:migrate --no-interaction"
|
||||
|
||||
# Frontend
|
||||
ddev exec "cd frontend && npm install"
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260323230657 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, color VARCHAR(7) NOT NULL, PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('CREATE TABLE task (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, status VARCHAR(20) NOT NULL, task_type VARCHAR(20) NOT NULL, deadline DATE DEFAULT NULL, interval_type VARCHAR(20) DEFAULT NULL, start_date DATE DEFAULT NULL, end_date DATE DEFAULT NULL, weekdays JSON DEFAULT NULL, month_days JSON DEFAULT NULL, category_id INT DEFAULT NULL, INDEX IDX_527EDB2512469DE2 (category_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB2512469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE SET NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB2512469DE2');
|
||||
$this->addSql('DROP TABLE category');
|
||||
$this->addSql('DROP TABLE task');
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260324141105 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE task_completion (id INT AUTO_INCREMENT NOT NULL, date DATE NOT NULL, task_id INT NOT NULL, INDEX IDX_24C57CD18DB60186 (task_id), UNIQUE INDEX UNIQ_24C57CD18DB60186AA9E377A (task_id, date), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE task_completion ADD CONSTRAINT FK_24C57CD18DB60186 FOREIGN KEY (task_id) REFERENCES task (id) ON DELETE CASCADE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task_completion DROP FOREIGN KEY FK_24C57CD18DB60186');
|
||||
$this->addSql('DROP TABLE task_completion');
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260324154816 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE TABLE task_occurrence (id INT AUTO_INCREMENT NOT NULL, date DATE NOT NULL, status VARCHAR(20) NOT NULL, task_id INT NOT NULL, INDEX IDX_A2EECA5C8DB60186 (task_id), UNIQUE INDEX UNIQ_A2EECA5C8DB60186AA9E377A (task_id, date), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
||||
$this->addSql('ALTER TABLE task_occurrence ADD CONSTRAINT FK_A2EECA5C8DB60186 FOREIGN KEY (task_id) REFERENCES task (id) ON DELETE CASCADE');
|
||||
$this->addSql("INSERT INTO task_occurrence (task_id, date, status) SELECT task_id, date, 'erledigt' FROM task_completion");
|
||||
$this->addSql('ALTER TABLE task_completion DROP FOREIGN KEY FK_24C57CD18DB60186');
|
||||
$this->addSql('DROP TABLE task_completion');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task_occurrence DROP FOREIGN KEY FK_A2EECA5C8DB60186');
|
||||
$this->addSql('DROP TABLE task_occurrence');
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260325064344 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task_occurrence ADD name VARCHAR(255) DEFAULT NULL, ADD category_overridden TINYINT NOT NULL, ADD category_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE task_occurrence ADD CONSTRAINT FK_A2EECA5C12469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE SET NULL');
|
||||
$this->addSql('CREATE INDEX IDX_A2EECA5C12469DE2 ON task_occurrence (category_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task_occurrence DROP FOREIGN KEY FK_A2EECA5C12469DE2');
|
||||
$this->addSql('DROP INDEX IDX_A2EECA5C12469DE2 ON task_occurrence');
|
||||
$this->addSql('ALTER TABLE task_occurrence DROP name, DROP category_overridden, DROP category_id');
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260326165702 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Rename task → task_schema, task_occurrence → task';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// 1. Drop FKs on task_occurrence that reference task
|
||||
$this->addSql('ALTER TABLE task_occurrence DROP FOREIGN KEY FK_A2EECA5C8DB60186');
|
||||
|
||||
// 2. Drop FK on task.category_id
|
||||
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB2512469DE2');
|
||||
|
||||
// 3. Rename tables
|
||||
$this->addSql('RENAME TABLE task TO task_schema');
|
||||
$this->addSql('RENAME TABLE task_occurrence TO task');
|
||||
|
||||
// 4. Re-create FK: task.task_id → task_schema.id
|
||||
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB258DB60186 FOREIGN KEY (task_id) REFERENCES task_schema (id) ON DELETE CASCADE');
|
||||
|
||||
// 5. Re-create FK: task_schema.category_id → category.id
|
||||
$this->addSql('ALTER TABLE task_schema ADD CONSTRAINT FK_8327C58112469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE SET NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// Drop FKs
|
||||
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB258DB60186');
|
||||
$this->addSql('ALTER TABLE task_schema DROP FOREIGN KEY FK_8327C58112469DE2');
|
||||
|
||||
// Rename back
|
||||
$this->addSql('RENAME TABLE task TO task_occurrence');
|
||||
$this->addSql('RENAME TABLE task_schema TO task');
|
||||
|
||||
// Re-create original FKs
|
||||
$this->addSql('ALTER TABLE task_occurrence ADD CONSTRAINT FK_A2EECA5C8DB60186 FOREIGN KEY (task_id) REFERENCES task (id) ON DELETE CASCADE');
|
||||
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB2512469DE2 FOREIGN KEY (category_id) REFERENCES category (id) ON DELETE SET NULL');
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260330210659 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task ADD created_at DATETIME NOT NULL, CHANGE date date DATE DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE task RENAME INDEX idx_a2eeca5c8db60186 TO IDX_527EDB258DB60186');
|
||||
$this->addSql('ALTER TABLE task RENAME INDEX idx_a2eeca5c12469de2 TO IDX_527EDB2512469DE2');
|
||||
$this->addSql('ALTER TABLE task RENAME INDEX uniq_a2eeca5c8db60186aa9e377a TO UNIQ_527EDB258DB60186AA9E377A');
|
||||
$this->addSql('ALTER TABLE task_schema ADD year_days JSON DEFAULT NULL, ADD created_at DATETIME NOT NULL, DROP interval_type');
|
||||
$this->addSql('ALTER TABLE task_schema RENAME INDEX idx_527edb2512469de2 TO IDX_8327C58112469DE2');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE task DROP created_at, CHANGE date date DATE NOT NULL');
|
||||
$this->addSql('ALTER TABLE task RENAME INDEX idx_527edb258db60186 TO IDX_A2EECA5C8DB60186');
|
||||
$this->addSql('ALTER TABLE task RENAME INDEX idx_527edb2512469de2 TO IDX_A2EECA5C12469DE2');
|
||||
$this->addSql('ALTER TABLE task RENAME INDEX uniq_527edb258db60186aa9e377a TO UNIQ_A2EECA5C8DB60186AA9E377A');
|
||||
$this->addSql('ALTER TABLE task_schema ADD interval_type VARCHAR(20) DEFAULT NULL, DROP year_days, DROP created_at');
|
||||
$this->addSql('ALTER TABLE task_schema RENAME INDEX idx_8327c58112469de2 TO IDX_527EDB2512469DE2');
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260331120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Remove categoryOverridden: backfill task.category_id from schema, then drop column';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('UPDATE task t INNER JOIN task_schema ts ON t.task_id = ts.id SET t.category_id = ts.category_id WHERE t.category_overridden = 0');
|
||||
$this->addSql('ALTER TABLE task DROP category_overridden');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE task ADD category_overridden TINYINT(1) NOT NULL DEFAULT 0');
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260331150000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Major refactoring: English enums, unified days field, nullable task.schema, detach single tasks';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// 1. Migrate enum values to English
|
||||
$this->addSql("UPDATE task SET status = 'active' WHERE status = 'aktiv'");
|
||||
$this->addSql("UPDATE task SET status = 'done' WHERE status = 'erledigt'");
|
||||
|
||||
$this->addSql("UPDATE task_schema SET status = 'active' WHERE status = 'aktiv'");
|
||||
$this->addSql("UPDATE task_schema SET status = 'disabled' WHERE status IN ('erledigt', 'inaktiv')");
|
||||
|
||||
$this->addSql("UPDATE task_schema SET task_type = 'single' WHERE task_type = 'einzel'");
|
||||
$this->addSql("UPDATE task_schema SET task_type = 'daily' WHERE task_type = 'taeglich'");
|
||||
$this->addSql("UPDATE task_schema SET task_type = 'custom' WHERE task_type IN ('multi', 'woechentlich', 'monatlich', 'jaehrlich')");
|
||||
|
||||
// 2. Add unified days column
|
||||
$this->addSql('ALTER TABLE task_schema ADD days JSON DEFAULT NULL');
|
||||
|
||||
// 3. Migrate weekdays/monthDays/yearDays into days JSON via PHP
|
||||
$this->migrateDaysData();
|
||||
|
||||
// 4. Drop old columns from task_schema
|
||||
$this->addSql('ALTER TABLE task_schema DROP deadline, DROP weekdays, DROP month_days, DROP year_days');
|
||||
|
||||
// 5. Backfill task names/categories from schema (for all tasks that relied on getEffectiveName fallback)
|
||||
$this->addSql("UPDATE task t INNER JOIN task_schema ts ON t.task_id = ts.id SET t.name = ts.name WHERE t.name IS NULL");
|
||||
$this->addSql("UPDATE task t INNER JOIN task_schema ts ON t.task_id = ts.id SET t.category_id = ts.category_id WHERE t.category_id IS NULL AND ts.category_id IS NOT NULL");
|
||||
|
||||
// 6. Detach single tasks
|
||||
$this->addSql("UPDATE task t INNER JOIN task_schema ts ON t.task_id = ts.id SET t.name = ts.name WHERE ts.task_type = 'single' AND t.name IS NULL");
|
||||
$this->addSql("UPDATE task t INNER JOIN task_schema ts ON t.task_id = ts.id SET t.category_id = ts.category_id WHERE ts.task_type = 'single' AND t.category_id IS NULL");
|
||||
|
||||
// Drop FK + unique constraint before modifying task_id
|
||||
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB258DB60186');
|
||||
$this->addSql('DROP INDEX UNIQ_527EDB258DB60186AA9E377A ON task');
|
||||
|
||||
// Detach single tasks
|
||||
$this->addSql("UPDATE task t INNER JOIN task_schema ts ON t.task_id = ts.id SET t.task_id = NULL WHERE ts.task_type = 'single'");
|
||||
|
||||
// Delete single schemas
|
||||
$this->addSql("DELETE FROM task_schema WHERE task_type = 'single'");
|
||||
|
||||
// Make task_id nullable with SET NULL on delete
|
||||
$this->addSql('ALTER TABLE task MODIFY task_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB258DB60186 FOREIGN KEY (task_id) REFERENCES task_schema (id) ON DELETE SET NULL');
|
||||
}
|
||||
|
||||
private function migrateDaysData(): void
|
||||
{
|
||||
$rows = $this->connection->fetchAllAssociative(
|
||||
'SELECT id, weekdays, month_days, year_days FROM task_schema'
|
||||
);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$days = [];
|
||||
|
||||
$weekdays = $row['weekdays'] ? json_decode($row['weekdays'], true) : null;
|
||||
$monthDays = $row['month_days'] ? json_decode($row['month_days'], true) : null;
|
||||
$yearDays = $row['year_days'] ? json_decode($row['year_days'], true) : null;
|
||||
|
||||
if (!empty($weekdays)) {
|
||||
$days['week'] = $weekdays;
|
||||
}
|
||||
if (!empty($monthDays)) {
|
||||
$days['month'] = $monthDays;
|
||||
}
|
||||
if (!empty($yearDays)) {
|
||||
$days['year'] = $yearDays;
|
||||
}
|
||||
|
||||
if (!empty($days)) {
|
||||
$this->connection->executeStatement(
|
||||
'UPDATE task_schema SET days = ? WHERE id = ?',
|
||||
[json_encode($days), $row['id']]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE task_schema ADD deadline DATE DEFAULT NULL, ADD weekdays JSON DEFAULT NULL, ADD month_days JSON DEFAULT NULL, ADD year_days JSON DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE task_schema DROP days');
|
||||
|
||||
$this->addSql('ALTER TABLE task DROP FOREIGN KEY FK_527EDB258DB60186');
|
||||
$this->addSql('ALTER TABLE task MODIFY task_id INT NOT NULL');
|
||||
$this->addSql('ALTER TABLE task ADD CONSTRAINT FK_527EDB258DB60186 FOREIGN KEY (task_id) REFERENCES task_schema (id) ON DELETE CASCADE');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_527EDB258DB60186AA9E377A ON task (task_id, date)');
|
||||
|
||||
$this->addSql("UPDATE task SET status = 'aktiv' WHERE status = 'active'");
|
||||
$this->addSql("UPDATE task SET status = 'erledigt' WHERE status = 'done'");
|
||||
$this->addSql("UPDATE task_schema SET status = 'aktiv' WHERE status = 'active'");
|
||||
$this->addSql("UPDATE task_schema SET status = 'inaktiv' WHERE status = 'disabled'");
|
||||
$this->addSql("UPDATE task_schema SET task_type = 'einzel' WHERE task_type = 'single'");
|
||||
$this->addSql("UPDATE task_schema SET task_type = 'taeglich' WHERE task_type = 'daily'");
|
||||
}
|
||||
}
|
||||
123
backend/plan.md
123
backend/plan.md
@@ -1,123 +0,0 @@
|
||||
# Kategorien
|
||||
|
||||
## Entity
|
||||
|
||||
Category(id, name, color) — Farbkodierte Kategorie für Aufgaben
|
||||
|
||||
## Controller
|
||||
|
||||
CategoryController::index() — Alle Kategorien abrufen
|
||||
CategoryController::show(id) — Einzelne Kategorie abrufen
|
||||
CategoryController::create() — Neue Kategorie anlegen (201)
|
||||
CategoryController::update(id) — Kategorie aktualisieren
|
||||
CategoryController::delete(id) — Kategorie löschen (204)
|
||||
|
||||
## Service
|
||||
|
||||
CategoryManager::createCategory() — Neue Kategorie anlegen
|
||||
CategoryManager::updateCategory() — Kategorie aktualisieren
|
||||
CategoryManager::deleteCategory() — Kategorie löschen
|
||||
|
||||
## DTO
|
||||
|
||||
CreateCategoryRequest(name, color) — Kategorie anlegen
|
||||
UpdateCategoryRequest(name, color) — Kategorie ändern
|
||||
|
||||
## Repository
|
||||
|
||||
CategoryRepository — Standard Doctrine-Repository (keine eigenen Methoden)
|
||||
|
||||
---
|
||||
|
||||
# Aufgaben
|
||||
|
||||
## Entity
|
||||
|
||||
Task(id, schema, name, category, categoryOverridden, date, status, createdAt) — Einzelne Aufgabe eines Schemas
|
||||
|
||||
## Controller
|
||||
|
||||
TaskController::show(id) — Einzelnen Task abrufen
|
||||
TaskController::update(id) — Task aktualisieren (Name, Kategorie, Status, Datum)
|
||||
TaskController::delete(id) — Task löschen (204)
|
||||
|
||||
---
|
||||
|
||||
# Entity
|
||||
|
||||
TaskSchema(id, name, status, taskType, category, deadline, startDate, endDate, weekdays, monthDays, yearDays, createdAt) — Vorlage für wiederkehrende Aufgaben
|
||||
|
||||
# Controller
|
||||
|
||||
TaskSchemaController::index() — Alle Schemas abrufen
|
||||
TaskSchemaController::week(?start) — Wochenansicht ab Datum (Default: heute)
|
||||
TaskSchemaController::allSchemas() — Alle Schemas sortiert nach Erstellung
|
||||
TaskSchemaController::allTasks() — Alle Tasks über alle Schemas
|
||||
TaskSchemaController::show(id) — Einzelnes Schema abrufen
|
||||
TaskSchemaController::create() — Neues Schema anlegen (201)
|
||||
TaskSchemaController::update(id) — Schema aktualisieren + Tasks synchronisieren
|
||||
TaskSchemaController::delete(id) — Schema löschen (204)
|
||||
TaskSchemaController::toggle(id) — Task-Status umschalten (aktiv↔erledigt)
|
||||
|
||||
# Service
|
||||
|
||||
TaskManager::updateTask() — Task aktualisieren (Name, Kategorie, Status, Datum)
|
||||
TaskManager::toggleTaskStatus() — Task-Status umschalten (aktiv↔erledigt)
|
||||
TaskManager::deleteTask() — Task löschen
|
||||
|
||||
TaskSchemaManager::createSchema() — Neues Schema anlegen
|
||||
TaskSchemaManager::updateSchema() — Schema aktualisieren + Tasks synchronisieren
|
||||
TaskSchemaManager::deleteSchema() — Schema löschen
|
||||
|
||||
TaskGenerator::generateForRange() — Fehlende Tasks für einen Zeitraum erzeugen
|
||||
TaskGenerator::generateForTasksWithoutDate() — Tasks für Einzel-Schemas ohne Deadline erzeugen
|
||||
|
||||
TaskSynchronizer::syncForSchema() — Tasks nach Schema-Update synchronisieren
|
||||
|
||||
DeadlineCalculator::getDeadlinesForRange() — Fälligkeitsdaten anhand Wiederholungsregeln berechnen
|
||||
|
||||
TaskViewBuilder::buildWeekView() — Wochenansicht nach Tagen gruppiert
|
||||
TaskViewBuilder::buildAllTasksView() — Alle Tasks sortiert
|
||||
|
||||
# DTO
|
||||
|
||||
## Request
|
||||
|
||||
CreateSchemaRequest(name, categoryId, status, taskType, deadline, startDate, endDate, weekdays, monthDays, yearDays) — Schema anlegen
|
||||
UpdateSchemaRequest(name, categoryId, hasCategoryId, status, taskType, deadline, startDate, endDate, weekdays, monthDays, yearDays) — Schema ändern
|
||||
UpdateTaskRequest(name, categoryId, status, date) — Task ändern
|
||||
ToggleRequest(date) — Task-Status umschalten
|
||||
|
||||
## Response
|
||||
|
||||
WeekViewResponse(tasksWithoutDeadline[], days[]) — Wochenansicht
|
||||
DayResponse(date, tasks[]) — Tagesansicht mit Tasks
|
||||
ToggleResponse(completed) — Toggle-Ergebnis
|
||||
|
||||
# Enum
|
||||
|
||||
TaskStatus — Aufgabenstatus (aktiv, erledigt)
|
||||
TaskSchemaStatus — Schemastatus (aktiv, erledigt, inaktiv)
|
||||
TaskSchemaType — Wiederholungstyp (einzel, taeglich, multi, woechentlich, monatlich, jaehrlich)
|
||||
|
||||
# Repository
|
||||
|
||||
TaskRepository::findBySchemaAndDate() — Task anhand Schema und Datum finden
|
||||
TaskRepository::findInRange() — Alle Tasks in einem Zeitraum (ohne inaktive Schemas)
|
||||
TaskRepository::getExistingKeys() — Set aus "schemaId-YYYY-MM-DD" Keys für existierende Tasks
|
||||
TaskRepository::findBySchemaFromDate() — Tasks eines Schemas ab einem Datum
|
||||
TaskRepository::deleteFutureBySchema() — Zukünftige Tasks eines Schemas löschen
|
||||
TaskRepository::deleteFutureActiveBySchema() — Zukünftige aktive Tasks eines Schemas löschen
|
||||
TaskRepository::findAllSorted() — Alle Tasks mit Datum, sortiert nach Datum absteigend
|
||||
TaskRepository::findWithoutDate() — Alle aktiven Tasks ohne Datum, sortiert nach Erstellung
|
||||
|
||||
TaskSchemaRepository::findActiveSchemasInRange() — Aktive Schemas in einem Zeitraum finden
|
||||
|
||||
# Migration
|
||||
|
||||
Version20260323230657 — Erstellt Category- und Task-Tabelle (initiales Schema)
|
||||
Version20260324141105 — Erstellt task_completion-Tabelle mit Unique-Constraint (task_id, date)
|
||||
Version20260324154816 — Ersetzt task_completion durch task_occurrence, migriert Daten
|
||||
Version20260325064344 — Ergänzt name, category_overridden, category_id auf task_occurrence
|
||||
Version20260326165702 — Benennt task→task_schema und task_occurrence→task um
|
||||
Version20260330210659 — Ergänzt year_days, created_at; entfernt interval_type; passt Indizes an
|
||||
@@ -1,82 +0,0 @@
|
||||
# Backend
|
||||
## Entity
|
||||
- Task - Aufgaben Tabele
|
||||
- Category - Kategorie Tabele
|
||||
- Schema - TaksSchema Tabele
|
||||
## Enum
|
||||
- TaskStatus - Aufgaben Status
|
||||
- TaskSchemaStatus - Schema Status
|
||||
- TaskSchemaType - Schema Typen
|
||||
## Controller
|
||||
- TaskController - Aufgaben Aktionen
|
||||
- TaskSchemaController - Schema Aktionen
|
||||
- CategoryController - Kategorie Aktioenen
|
||||
## Services
|
||||
- TaskManager -
|
||||
- TaskSchemaManager -
|
||||
- CategoryManager -
|
||||
- TaskGenerator -
|
||||
- TaskSynchronizer -
|
||||
- DeadlineCalculator -
|
||||
## Repositorys
|
||||
- TaskRepository - Aufgaben Abfragen
|
||||
- CategoryRepository - Kategorie Abfragem
|
||||
- TaskSchemaRepository - Schema Abfragen
|
||||
|
||||
|
||||
|
||||
## Task
|
||||
|
||||
- Wird verwendet um Aufgaben anzuzeigen
|
||||
- Entity
|
||||
- name - Name der Aufgabe
|
||||
- status - Status der Aufgabe (active, done)
|
||||
- date - Deadline, null for no deadline
|
||||
- schema - schemaId, null no schema
|
||||
- category - categoryId, null no category
|
||||
- Controller
|
||||
- index() - Alle Tasks zurückgeben
|
||||
- show(id) - Ein Task zurückgeben
|
||||
- create() - Task erstellen
|
||||
- update(id) - Task aktualisieren
|
||||
- delete(id) - Task entfernen
|
||||
- toggle(id) - Status switchen (active, done)
|
||||
- Werden durch Schemas erstellt
|
||||
|
||||
## Category
|
||||
|
||||
- Kategorien die von Aufgaben und Schemas verwendet werden
|
||||
- Entity
|
||||
- name - Kategoriename
|
||||
- color - Hex-Farbe
|
||||
- Controller
|
||||
- index() - Alle Kategorien zurückgeben
|
||||
- show(id) - Eine Kategorie zurückgeben
|
||||
- create() - Kategorie erstellen
|
||||
- update(id) - Kategorie aktualisieren
|
||||
- delete(id) - Kategorie entfernen
|
||||
|
||||
## Schema
|
||||
|
||||
- Template um Aufgaben zu erstellen
|
||||
- Entity
|
||||
- name - Name für erstellte Aufgaben
|
||||
- status - Status für Schema (active, disabled)
|
||||
- category - Kategorie für erstellte Aufgaben
|
||||
- type
|
||||
- single - Einmal erstellt, schema = null
|
||||
- daily - Für jeden Tag erstellt, schema = id
|
||||
- custom - Benutzerdefiniert erstellt, schema = id
|
||||
- start - Startdatum für type=daily,custom
|
||||
- end - Enddatum für type=daily, custom
|
||||
- days - Tage für type=custom
|
||||
- week - Array für Wochentage (1-7)
|
||||
- month - Array für Monatstage (1-31)
|
||||
- year - Array für Jahrestage (1-365/366)
|
||||
- Controller
|
||||
- index() - Alle Schema zurückgeben
|
||||
- show(id) - Eine Schema zurückgeben
|
||||
- create() - Schema erstellen
|
||||
- update(id) - Schema aktualisieren
|
||||
- delete(id) - Schema entfernen
|
||||
- Anpasung -> Alle Tasks anpassen (keine Vergangenheit)
|
||||
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Api;
|
||||
|
||||
use App\DTO\Request\CreateCategoryRequest;
|
||||
use App\DTO\Request\UpdateCategoryRequest;
|
||||
use App\Entity\Category;
|
||||
use App\Repository\CategoryRepository;
|
||||
use App\Service\CategoryManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
#[Route('/api/categories', name: 'categories.')]
|
||||
class CategoryController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private CategoryRepository $categoryRepository,
|
||||
private CategoryManager $categoryManager,
|
||||
) {}
|
||||
|
||||
#[Route('', name: 'index', methods: ['GET'])]
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$categories = $this->categoryRepository->findAll();
|
||||
|
||||
return $this->json($categories, context: ['groups' => ['category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'show', methods: ['GET'])]
|
||||
public function show(Category $category): JsonResponse
|
||||
{
|
||||
return $this->json($category, context: ['groups' => ['category:read']]);
|
||||
}
|
||||
|
||||
#[Route('', name: 'create', methods: ['POST'])]
|
||||
public function create(#[MapRequestPayload] CreateCategoryRequest $dto): JsonResponse
|
||||
{
|
||||
$category = $this->categoryManager->createCategory($dto);
|
||||
|
||||
return $this->json($category, Response::HTTP_CREATED, context: ['groups' => ['category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'update', methods: ['PUT'])]
|
||||
public function update(#[MapRequestPayload] UpdateCategoryRequest $dto, Category $category): JsonResponse
|
||||
{
|
||||
$category = $this->categoryManager->updateCategory($category, $dto);
|
||||
|
||||
return $this->json($category, context: ['groups' => ['category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'delete', methods: ['DELETE'])]
|
||||
public function delete(Category $category): JsonResponse
|
||||
{
|
||||
$this->categoryManager->deleteCategory($category);
|
||||
|
||||
return $this->json(null, Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Api;
|
||||
|
||||
use App\DTO\Request\CreateTaskRequest;
|
||||
use App\DTO\Request\UpdateTaskRequest;
|
||||
use App\Entity\Task;
|
||||
use App\Repository\TaskRepository;
|
||||
use App\Service\TaskGenerator;
|
||||
use App\Service\TaskManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
#[Route('/api/tasks')]
|
||||
class TaskController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private TaskManager $taskManager,
|
||||
private TaskGenerator $taskGenerator,
|
||||
private TaskRepository $taskRepository,
|
||||
) {}
|
||||
|
||||
#[Route('', name: 'tasks.index', methods: ['GET'])]
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$today = new \DateTimeImmutable('today');
|
||||
$end = $today->modify('+6 days');
|
||||
$this->taskGenerator->generateForRange($today, $end);
|
||||
|
||||
$tasks = $this->taskRepository->findAllWithRelations();
|
||||
|
||||
return $this->json($tasks, context: ['groups' => ['task:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'tasks.show', methods: ['GET'])]
|
||||
public function show(Task $task): JsonResponse
|
||||
{
|
||||
return $this->json($task, context: ['groups' => ['task:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('', name: 'tasks.create', methods: ['POST'])]
|
||||
public function create(#[MapRequestPayload] CreateTaskRequest $dto): JsonResponse
|
||||
{
|
||||
$task = $this->taskManager->createTask($dto);
|
||||
|
||||
return $this->json($task, Response::HTTP_CREATED, context: ['groups' => ['task:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'tasks.update', methods: ['PUT'])]
|
||||
public function update(#[MapRequestPayload] UpdateTaskRequest $dto, Task $task): JsonResponse
|
||||
{
|
||||
$task = $this->taskManager->updateTask($task, $dto);
|
||||
|
||||
return $this->json($task, context: ['groups' => ['task:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'tasks.delete', methods: ['DELETE'])]
|
||||
public function delete(Task $task): JsonResponse
|
||||
{
|
||||
$this->taskManager->deleteTask($task);
|
||||
|
||||
return $this->json(null, Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
||||
#[Route('/{id}/toggle', name: 'tasks.toggle', methods: ['PATCH'])]
|
||||
public function toggle(Task $task): JsonResponse
|
||||
{
|
||||
$task = $this->taskManager->toggleTask($task);
|
||||
|
||||
return $this->json($task, context: ['groups' => ['task:read', 'category:read']]);
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Api;
|
||||
|
||||
use App\DTO\Request\CreateSchemaRequest;
|
||||
use App\DTO\Request\UpdateSchemaRequest;
|
||||
use App\Entity\TaskSchema;
|
||||
use App\Repository\TaskSchemaRepository;
|
||||
use App\Service\TaskSchemaManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
#[Route('/api/schemas')]
|
||||
class TaskSchemaController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private TaskSchemaRepository $schemaRepository,
|
||||
private TaskSchemaManager $schemaManager,
|
||||
) {}
|
||||
|
||||
#[Route('', name: 'schemas.index', methods: ['GET'])]
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$schemas = $this->schemaRepository->findBy([], ['createdAt' => 'DESC']);
|
||||
|
||||
return $this->json($schemas, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'schemas.show', methods: ['GET'])]
|
||||
public function show(TaskSchema $schema): JsonResponse
|
||||
{
|
||||
return $this->json($schema, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('', name: 'schemas.create', methods: ['POST'])]
|
||||
public function create(#[MapRequestPayload] CreateSchemaRequest $dto): JsonResponse
|
||||
{
|
||||
$result = $this->schemaManager->createSchema($dto);
|
||||
|
||||
if (is_array($result)) {
|
||||
return $this->json($result, Response::HTTP_CREATED, context: ['groups' => ['task:read', 'category:read']]);
|
||||
}
|
||||
|
||||
return $this->json($result, Response::HTTP_CREATED, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'schemas.update', methods: ['PUT'])]
|
||||
public function update(#[MapRequestPayload] UpdateSchemaRequest $dto, TaskSchema $schema): JsonResponse
|
||||
{
|
||||
$schema = $this->schemaManager->updateSchema($schema, $dto);
|
||||
|
||||
return $this->json($schema, context: ['groups' => ['schema:read', 'category:read']]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'schemas.delete', methods: ['DELETE'])]
|
||||
public function delete(TaskSchema $schema, Request $request): JsonResponse
|
||||
{
|
||||
$deleteTasks = (bool) $request->query->get('deleteTasks', false);
|
||||
$this->schemaManager->deleteSchema($schema, $deleteTasks);
|
||||
|
||||
return $this->json(null, Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class CreateCategoryRequest
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 255)]
|
||||
public string $name;
|
||||
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\CssColor(formats: Assert\CssColor::HEX_LONG)]
|
||||
public string $color;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class CreateSchemaRequest
|
||||
{
|
||||
use SchemaValidationTrait;
|
||||
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 255)]
|
||||
public ?string $name = null;
|
||||
|
||||
public ?int $categoryId = null;
|
||||
public ?string $status = null;
|
||||
public ?string $type = null;
|
||||
public ?string $startDate = null;
|
||||
public ?string $endDate = null;
|
||||
public ?array $days = null;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class CreateTaskRequest
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 255)]
|
||||
public ?string $name = null;
|
||||
|
||||
public ?int $categoryId = null;
|
||||
public ?string $date = null;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
trait SchemaValidationTrait
|
||||
{
|
||||
public function validate(ExecutionContextInterface $context): void
|
||||
{
|
||||
if ($this->type !== null && $this->type !== 'single') {
|
||||
if ($this->startDate !== null && $this->endDate !== null && $this->endDate < $this->startDate) {
|
||||
$context->buildViolation('endDate muss >= startDate sein.')
|
||||
->atPath('endDate')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->type === 'single') {
|
||||
$year = $this->days['year'] ?? null;
|
||||
if (empty($year)) {
|
||||
$context->buildViolation('Mindestens ein Datum muss ausgewählt werden.')
|
||||
->atPath('days')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->type === 'custom') {
|
||||
if (empty($this->days)) {
|
||||
$context->buildViolation('days darf nicht leer sein.')
|
||||
->atPath('days')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class UpdateCategoryRequest
|
||||
{
|
||||
#[Assert\Length(min: 1, max: 255)]
|
||||
public ?string $name = null;
|
||||
|
||||
#[Assert\CssColor(formats: Assert\CssColor::HEX_LONG)]
|
||||
public ?string $color = null;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class UpdateSchemaRequest
|
||||
{
|
||||
use SchemaValidationTrait;
|
||||
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 255)]
|
||||
public ?string $name = null;
|
||||
|
||||
public ?int $categoryId = null;
|
||||
public bool $hasCategoryId = false;
|
||||
public ?string $status = null;
|
||||
public ?string $type = null;
|
||||
public ?string $startDate = null;
|
||||
public ?string $endDate = null;
|
||||
public ?array $days = null;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
class UpdateTaskRequest
|
||||
{
|
||||
public ?string $name = null;
|
||||
public ?int $categoryId = null;
|
||||
public ?string $status = null;
|
||||
public ?string $date = null;
|
||||
}
|
||||
0
backend/src/Entity/.gitignore
vendored
0
backend/src/Entity/.gitignore
vendored
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\CategoryRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
|
||||
class Category
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['category:read', 'task:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['category:read', 'category:write', 'task:read'])]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 7)]
|
||||
#[Groups(['category:read', 'category:write', 'task:read'])]
|
||||
private ?string $color = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getColor(): ?string
|
||||
{
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
public function setColor(string $color): static
|
||||
{
|
||||
$this->color = $color;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Enum\TaskStatus;
|
||||
use App\Repository\TaskRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TaskRepository::class)]
|
||||
class Task
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['task:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(name: 'task_id', nullable: true, onDelete: 'SET NULL')]
|
||||
private ?TaskSchema $schema = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Groups(['task:read'])]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
|
||||
#[Groups(['task:read'])]
|
||||
private ?Category $category = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
||||
#[Groups(['task:read'])]
|
||||
private ?\DateTimeInterface $date = null;
|
||||
|
||||
#[ORM\Column(length: 20, enumType: TaskStatus::class)]
|
||||
#[Groups(['task:read'])]
|
||||
private TaskStatus $status = TaskStatus::Active;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
private \DateTimeInterface $createdAt;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
#[Groups(['task:read'])]
|
||||
#[SerializedName('schemaId')]
|
||||
public function getSchemaId(): ?int
|
||||
{
|
||||
return $this->schema?->getId();
|
||||
}
|
||||
|
||||
public function getSchema(): ?TaskSchema
|
||||
{
|
||||
return $this->schema;
|
||||
}
|
||||
|
||||
public function setSchema(?TaskSchema $schema): static
|
||||
{
|
||||
$this->schema = $schema;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(?string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCategory(): ?Category
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function setCategory(?Category $category): static
|
||||
{
|
||||
$this->category = $category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(?\DateTimeInterface $date): static
|
||||
{
|
||||
$this->date = $date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatus(): TaskStatus
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus(TaskStatus $status): static
|
||||
{
|
||||
$this->status = $status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['task:read'])]
|
||||
#[SerializedName('isPast')]
|
||||
public function isPast(): bool
|
||||
{
|
||||
return $this->date !== null && $this->date < new \DateTimeImmutable('today');
|
||||
}
|
||||
|
||||
public function getCreatedAt(): \DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt(\DateTimeInterface $createdAt): static
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Enum\TaskSchemaStatus;
|
||||
use App\Enum\TaskSchemaType;
|
||||
use App\Repository\TaskSchemaRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TaskSchemaRepository::class)]
|
||||
class TaskSchema
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['schema:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[Groups(['schema:read', 'schema:write'])]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 20, enumType: TaskSchemaStatus::class)]
|
||||
#[Groups(['schema:read', 'schema:write'])]
|
||||
private TaskSchemaStatus $status = TaskSchemaStatus::Active;
|
||||
|
||||
#[ORM\Column(name: 'task_type', length: 20, enumType: TaskSchemaType::class)]
|
||||
#[Groups(['schema:read', 'schema:write'])]
|
||||
#[SerializedName('type')]
|
||||
private TaskSchemaType $taskType = TaskSchemaType::Single;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(onDelete: 'SET NULL')]
|
||||
#[Groups(['schema:read'])]
|
||||
private ?Category $category = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
||||
#[Groups(['schema:read', 'schema:write'])]
|
||||
private ?\DateTimeInterface $startDate = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
||||
#[Groups(['schema:read', 'schema:write'])]
|
||||
private ?\DateTimeInterface $endDate = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true)]
|
||||
#[Groups(['schema:read', 'schema:write'])]
|
||||
private ?array $days = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
||||
#[Groups(['schema:read'])]
|
||||
private \DateTimeInterface $createdAt;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatus(): TaskSchemaStatus
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setStatus(TaskSchemaStatus $status): static
|
||||
{
|
||||
$this->status = $status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaskType(): TaskSchemaType
|
||||
{
|
||||
return $this->taskType;
|
||||
}
|
||||
|
||||
public function setTaskType(TaskSchemaType $taskType): static
|
||||
{
|
||||
$this->taskType = $taskType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCategory(): ?Category
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
public function setCategory(?Category $category): static
|
||||
{
|
||||
$this->category = $category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStartDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->startDate;
|
||||
}
|
||||
|
||||
public function setStartDate(?\DateTimeInterface $startDate): static
|
||||
{
|
||||
$this->startDate = $startDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->endDate;
|
||||
}
|
||||
|
||||
public function setEndDate(?\DateTimeInterface $endDate): static
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDays(): ?array
|
||||
{
|
||||
return $this->days;
|
||||
}
|
||||
|
||||
public function setDays(?array $days): static
|
||||
{
|
||||
$this->days = $days;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): \DateTimeInterface
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enum;
|
||||
|
||||
enum TaskSchemaStatus: string
|
||||
{
|
||||
case Active = 'active';
|
||||
case Disabled = 'disabled';
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enum;
|
||||
|
||||
enum TaskSchemaType: string
|
||||
{
|
||||
case Single = 'single';
|
||||
case Daily = 'daily';
|
||||
case Custom = 'custom';
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enum;
|
||||
|
||||
enum TaskStatus: string
|
||||
{
|
||||
case Active = 'active';
|
||||
case Done = 'done';
|
||||
}
|
||||
0
backend/src/Repository/.gitignore
vendored
0
backend/src/Repository/.gitignore
vendored
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Category;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Category>
|
||||
*/
|
||||
class CategoryRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Category::class);
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Task;
|
||||
use App\Entity\TaskSchema;
|
||||
use App\Enum\TaskSchemaStatus;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Task>
|
||||
*/
|
||||
class TaskRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Task::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Task[]
|
||||
*/
|
||||
public function findAllWithRelations(): array
|
||||
{
|
||||
return $this->createQueryBuilder('task')
|
||||
->leftJoin('task.schema', 'schema')
|
||||
->leftJoin('task.category', 'category')
|
||||
->addSelect('schema', 'category')
|
||||
->where('task.schema IS NULL OR schema.status != :disabled')
|
||||
->setParameter('disabled', TaskSchemaStatus::Disabled)
|
||||
->orderBy('task.date', 'ASC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
public function findBySchemaAndDate(TaskSchema $schema, \DateTimeInterface $date): ?Task
|
||||
{
|
||||
return $this->createQueryBuilder('task')
|
||||
->where('task.schema = :schema')
|
||||
->andWhere('task.date = :date')
|
||||
->setParameter('schema', $schema)
|
||||
->setParameter('date', $date)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Task[]
|
||||
*/
|
||||
public function findInRange(\DateTimeInterface $from, \DateTimeInterface $to): array
|
||||
{
|
||||
return $this->createQueryBuilder('task')
|
||||
->leftJoin('task.schema', 'schema')
|
||||
->leftJoin('task.category', 'category')
|
||||
->addSelect('schema', 'category')
|
||||
->where('task.date >= :from')
|
||||
->andWhere('task.date <= :to')
|
||||
->andWhere('task.schema IS NULL OR schema.status != :disabled')
|
||||
->setParameter('from', $from)
|
||||
->setParameter('to', $to)
|
||||
->setParameter('disabled', TaskSchemaStatus::Disabled)
|
||||
->orderBy('task.date', 'ASC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, true> Set of "schemaId-YYYY-MM-DD" keys
|
||||
*/
|
||||
public function getExistingKeys(\DateTimeInterface $from, \DateTimeInterface $to): array
|
||||
{
|
||||
$rows = $this->createQueryBuilder('task')
|
||||
->select('IDENTITY(task.schema) AS schemaId', 'task.date')
|
||||
->where('task.date >= :from')
|
||||
->andWhere('task.date <= :to')
|
||||
->andWhere('task.schema IS NOT NULL')
|
||||
->setParameter('from', $from)
|
||||
->setParameter('to', $to)
|
||||
->getQuery()
|
||||
->getArrayResult();
|
||||
|
||||
$set = [];
|
||||
foreach ($rows as $row) {
|
||||
$date = $row['date'] instanceof \DateTimeInterface
|
||||
? $row['date']->format('Y-m-d')
|
||||
: $row['date'];
|
||||
$set[$row['schemaId'] . '-' . $date] = true;
|
||||
}
|
||||
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Task[]
|
||||
*/
|
||||
public function findBySchemaFromDate(TaskSchema $schema, \DateTimeInterface $fromDate): array
|
||||
{
|
||||
return $this->createQueryBuilder('task')
|
||||
->where('task.schema = :schema')
|
||||
->andWhere('task.date >= :from')
|
||||
->setParameter('schema', $schema)
|
||||
->setParameter('from', $fromDate)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\TaskSchema;
|
||||
use App\Enum\TaskSchemaStatus;
|
||||
use App\Enum\TaskSchemaType;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<TaskSchema>
|
||||
*/
|
||||
class TaskSchemaRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, TaskSchema::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TaskSchema[]
|
||||
*/
|
||||
public function findActiveSchemasInRange(\DateTimeInterface $from, \DateTimeInterface $to): array
|
||||
{
|
||||
return $this->createQueryBuilder('t')
|
||||
->where('t.status = :active')
|
||||
->andWhere('t.taskType IN (:types)')
|
||||
->andWhere('t.startDate <= :to')
|
||||
->andWhere('t.endDate IS NULL OR t.endDate >= :from')
|
||||
->setParameter('active', TaskSchemaStatus::Active)
|
||||
->setParameter('types', [TaskSchemaType::Daily, TaskSchemaType::Custom])
|
||||
->setParameter('from', $from)
|
||||
->setParameter('to', $to)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\DTO\Request\CreateCategoryRequest;
|
||||
use App\DTO\Request\UpdateCategoryRequest;
|
||||
use App\Entity\Category;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class CategoryManager
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
) {}
|
||||
|
||||
public function createCategory(CreateCategoryRequest $request): Category
|
||||
{
|
||||
$category = new Category();
|
||||
$category->setName($request->name);
|
||||
$category->setColor($request->color);
|
||||
|
||||
$this->em->persist($category);
|
||||
$this->em->flush();
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
public function updateCategory(Category $category, UpdateCategoryRequest $request): Category
|
||||
{
|
||||
$category->setName($request->name);
|
||||
$category->setColor($request->color);
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
return $category;
|
||||
}
|
||||
|
||||
public function deleteCategory(Category $category): void
|
||||
{
|
||||
$this->em->remove($category);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\TaskSchema;
|
||||
use App\Enum\TaskSchemaType;
|
||||
|
||||
class DeadlineCalculator
|
||||
{
|
||||
/**
|
||||
* @return \DateTimeInterface[]
|
||||
*/
|
||||
public function getDeadlinesForRange(TaskSchema $schema, \DateTimeInterface $from, \DateTimeInterface $to): array
|
||||
{
|
||||
$startDate = $schema->getStartDate();
|
||||
if ($startDate === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$effectiveFrom = $from > $startDate ? $from : $startDate;
|
||||
$endDate = $schema->getEndDate();
|
||||
$effectiveTo = $endDate !== null && $to > $endDate ? $endDate : $to;
|
||||
|
||||
if ($effectiveFrom > $effectiveTo) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$deadlines = [];
|
||||
$current = new \DateTimeImmutable($effectiveFrom->format('Y-m-d'));
|
||||
$end = new \DateTimeImmutable($effectiveTo->format('Y-m-d'));
|
||||
|
||||
while ($current <= $end) {
|
||||
if ($this->matchesType($schema, $current)) {
|
||||
$deadlines[] = $current;
|
||||
}
|
||||
$current = $current->modify('+1 day');
|
||||
}
|
||||
|
||||
return $deadlines;
|
||||
}
|
||||
|
||||
private function matchesType(TaskSchema $schema, \DateTimeImmutable $date): bool
|
||||
{
|
||||
return match ($schema->getTaskType()) {
|
||||
TaskSchemaType::Daily => true,
|
||||
TaskSchemaType::Custom => $this->matchesDays($schema, $date),
|
||||
default => false,
|
||||
};
|
||||
}
|
||||
|
||||
private function matchesDays(TaskSchema $schema, \DateTimeImmutable $date): bool
|
||||
{
|
||||
$days = $schema->getDays() ?? [];
|
||||
|
||||
if (!empty($days['week']) && in_array((int) $date->format('N'), $days['week'], true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!empty($days['month']) && in_array((int) $date->format('j'), $days['month'], true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!empty($days['year'])) {
|
||||
$month = (int) $date->format('n');
|
||||
$day = (int) $date->format('j');
|
||||
foreach ($days['year'] as $yd) {
|
||||
if (($yd['month'] ?? 0) === $month && ($yd['day'] ?? 0) === $day) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Task;
|
||||
use App\Repository\TaskRepository;
|
||||
use App\Repository\TaskSchemaRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class TaskGenerator
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private TaskSchemaRepository $schemaRepository,
|
||||
private TaskRepository $taskRepository,
|
||||
private DeadlineCalculator $deadlineCalculator,
|
||||
) {}
|
||||
|
||||
public function generateForRange(\DateTimeInterface $from, \DateTimeInterface $to): void
|
||||
{
|
||||
$schemas = $this->schemaRepository->findActiveSchemasInRange($from, $to);
|
||||
$existingKeys = $this->taskRepository->getExistingKeys($from, $to);
|
||||
|
||||
$hasNew = false;
|
||||
|
||||
foreach ($schemas as $schema) {
|
||||
$deadlines = $this->deadlineCalculator->getDeadlinesForRange($schema, $from, $to);
|
||||
|
||||
foreach ($deadlines as $deadline) {
|
||||
$key = $schema->getId() . '-' . $deadline->format('Y-m-d');
|
||||
if (!isset($existingKeys[$key])) {
|
||||
$task = new Task();
|
||||
$task->setSchema($schema);
|
||||
$task->setDate(new \DateTime($deadline->format('Y-m-d')));
|
||||
$task->setName($schema->getName());
|
||||
$task->setCategory($schema->getCategory());
|
||||
|
||||
$this->em->persist($task);
|
||||
$existingKeys[$key] = true;
|
||||
$hasNew = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasNew) {
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\DTO\Request\CreateTaskRequest;
|
||||
use App\DTO\Request\UpdateTaskRequest;
|
||||
use App\Entity\Task;
|
||||
use App\Enum\TaskStatus;
|
||||
use App\Repository\CategoryRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class TaskManager
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private CategoryRepository $categoryRepository,
|
||||
) {}
|
||||
|
||||
public function createTask(CreateTaskRequest $request): Task
|
||||
{
|
||||
$task = new Task();
|
||||
$task->setName($request->name);
|
||||
|
||||
if ($request->categoryId !== null) {
|
||||
$category = $this->categoryRepository->find($request->categoryId);
|
||||
$task->setCategory($category);
|
||||
}
|
||||
|
||||
if ($request->date !== null) {
|
||||
$task->setDate(new \DateTime($request->date));
|
||||
}
|
||||
|
||||
$this->em->persist($task);
|
||||
$this->em->flush();
|
||||
|
||||
return $task;
|
||||
}
|
||||
|
||||
public function updateTask(Task $task, UpdateTaskRequest $request): Task
|
||||
{
|
||||
$task->setName($request->name);
|
||||
|
||||
$category = $request->categoryId !== null
|
||||
? $this->categoryRepository->find($request->categoryId)
|
||||
: null;
|
||||
$task->setCategory($category);
|
||||
|
||||
$status = TaskStatus::tryFrom($request->status);
|
||||
if ($status !== null) {
|
||||
$task->setStatus($status);
|
||||
}
|
||||
|
||||
$task->setDate($request->date ? new \DateTime($request->date) : null);
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
return $task;
|
||||
}
|
||||
|
||||
public function toggleTask(Task $task): Task
|
||||
{
|
||||
$newStatus = $task->getStatus() === TaskStatus::Active
|
||||
? TaskStatus::Done
|
||||
: TaskStatus::Active;
|
||||
$task->setStatus($newStatus);
|
||||
$this->em->flush();
|
||||
|
||||
return $task;
|
||||
}
|
||||
|
||||
public function deleteTask(Task $task): void
|
||||
{
|
||||
$this->em->remove($task);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\DTO\Request\CreateSchemaRequest;
|
||||
use App\DTO\Request\UpdateSchemaRequest;
|
||||
use App\Entity\Task;
|
||||
use App\Entity\TaskSchema;
|
||||
use App\Enum\TaskSchemaStatus;
|
||||
use App\Enum\TaskSchemaType;
|
||||
use App\Repository\CategoryRepository;
|
||||
use App\Repository\TaskRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class TaskSchemaManager
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private CategoryRepository $categoryRepository,
|
||||
private TaskRepository $taskRepository,
|
||||
private TaskSynchronizer $taskSynchronizer,
|
||||
) {}
|
||||
|
||||
public function createSchema(CreateSchemaRequest $request): TaskSchema|array
|
||||
{
|
||||
$schema = new TaskSchema();
|
||||
$schema->setName($request->name ?? '');
|
||||
|
||||
$this->applyFields($schema, $request);
|
||||
$this->resolveCategory($schema, $request);
|
||||
$this->applyDefaults($schema);
|
||||
|
||||
$this->em->persist($schema);
|
||||
$this->em->flush();
|
||||
|
||||
if ($schema->getTaskType() === TaskSchemaType::Single) {
|
||||
$tasks = $this->createSingleTasks($schema);
|
||||
$this->em->remove($schema);
|
||||
$this->em->flush();
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public function updateSchema(TaskSchema $schema, UpdateSchemaRequest $request): TaskSchema
|
||||
{
|
||||
if ($request->name !== null) {
|
||||
$schema->setName($request->name);
|
||||
}
|
||||
|
||||
$this->applyFields($schema, $request);
|
||||
$this->resolveCategory($schema, $request);
|
||||
$this->applyDefaults($schema);
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
$this->taskSynchronizer->syncForSchema($schema);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public function deleteSchema(TaskSchema $schema, bool $deleteTasks = false): void
|
||||
{
|
||||
if ($deleteTasks) {
|
||||
$tasks = $this->taskRepository->findBy(['schema' => $schema]);
|
||||
foreach ($tasks as $task) {
|
||||
$this->em->remove($task);
|
||||
}
|
||||
}
|
||||
|
||||
$this->em->remove($schema);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
private function applyFields(TaskSchema $schema, CreateSchemaRequest|UpdateSchemaRequest $request): void
|
||||
{
|
||||
if ($request->status !== null) {
|
||||
$status = TaskSchemaStatus::tryFrom($request->status);
|
||||
if ($status !== null) {
|
||||
$schema->setStatus($status);
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->type !== null) {
|
||||
$taskType = TaskSchemaType::tryFrom($request->type);
|
||||
if ($taskType !== null) {
|
||||
$schema->setTaskType($taskType);
|
||||
}
|
||||
}
|
||||
|
||||
$schema->setStartDate($request->startDate !== null ? new \DateTime($request->startDate) : null);
|
||||
$schema->setEndDate($request->endDate !== null ? new \DateTime($request->endDate) : null);
|
||||
$schema->setDays($request->days);
|
||||
}
|
||||
|
||||
private function resolveCategory(TaskSchema $schema, UpdateSchemaRequest|CreateSchemaRequest $request): void
|
||||
{
|
||||
if ($request instanceof UpdateSchemaRequest) {
|
||||
if ($request->hasCategoryId) {
|
||||
if ($request->categoryId !== null) {
|
||||
$category = $this->categoryRepository->find($request->categoryId);
|
||||
$schema->setCategory($category);
|
||||
} else {
|
||||
$schema->setCategory(null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($request->categoryId !== null) {
|
||||
$category = $this->categoryRepository->find($request->categoryId);
|
||||
$schema->setCategory($category);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function applyDefaults(TaskSchema $schema): void
|
||||
{
|
||||
if ($schema->getTaskType() !== TaskSchemaType::Single && $schema->getStartDate() === null) {
|
||||
$schema->setStartDate(new \DateTime('today'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Task[]
|
||||
*/
|
||||
private function createSingleTasks(TaskSchema $schema): array
|
||||
{
|
||||
$days = $schema->getDays()['year'] ?? [];
|
||||
$tasks = [];
|
||||
|
||||
foreach ($days as $yd) {
|
||||
$month = $yd['month'] ?? 1;
|
||||
$day = $yd['day'] ?? 1;
|
||||
$date = new \DateTime(sprintf('%d-%02d-%02d', (int) date('Y'), $month, $day));
|
||||
|
||||
$task = new Task();
|
||||
$task->setName($schema->getName());
|
||||
$task->setCategory($schema->getCategory());
|
||||
$task->setDate($date);
|
||||
|
||||
$this->em->persist($task);
|
||||
$tasks[] = $task;
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
return $tasks;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Task;
|
||||
use App\Entity\TaskSchema;
|
||||
use App\Repository\TaskRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class TaskSynchronizer
|
||||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $em,
|
||||
private TaskRepository $taskRepository,
|
||||
private DeadlineCalculator $deadlineCalculator,
|
||||
) {}
|
||||
|
||||
public function syncForSchema(TaskSchema $schema): void
|
||||
{
|
||||
$today = new \DateTimeImmutable('today');
|
||||
$end = $this->calculateSyncEnd($schema, $today);
|
||||
|
||||
$deadlines = $this->deadlineCalculator->getDeadlinesForRange($schema, $today, $end);
|
||||
$shouldExist = [];
|
||||
foreach ($deadlines as $deadline) {
|
||||
$shouldExist[$deadline->format('Y-m-d')] = true;
|
||||
}
|
||||
|
||||
$existingByDate = $this->loadExistingByDate($schema, $today);
|
||||
|
||||
$this->removeObsoleteTasks($existingByDate, $shouldExist);
|
||||
$this->resetFutureOverrides($schema, $existingByDate);
|
||||
$this->createMissingTasks($schema, $deadlines, $existingByDate);
|
||||
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
private function calculateSyncEnd(TaskSchema $schema, \DateTimeImmutable $today): \DateTimeImmutable
|
||||
{
|
||||
$minEnd = $today->modify('+6 days');
|
||||
$end = $schema->getEndDate()
|
||||
? new \DateTimeImmutable($schema->getEndDate()->format('Y-m-d'))
|
||||
: $minEnd;
|
||||
|
||||
return $end < $minEnd ? $minEnd : $end;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Task>
|
||||
*/
|
||||
private function loadExistingByDate(TaskSchema $schema, \DateTimeImmutable $today): array
|
||||
{
|
||||
$futureTasks = $this->taskRepository->findBySchemaFromDate($schema, $today);
|
||||
$existingByDate = [];
|
||||
foreach ($futureTasks as $task) {
|
||||
$existingByDate[$task->getDate()->format('Y-m-d')] = $task;
|
||||
}
|
||||
|
||||
return $existingByDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, Task> $existingByDate
|
||||
* @param array<string, true> $shouldExist
|
||||
*/
|
||||
private function removeObsoleteTasks(array &$existingByDate, array $shouldExist): void
|
||||
{
|
||||
foreach ($existingByDate as $dateKey => $task) {
|
||||
if (!isset($shouldExist[$dateKey])) {
|
||||
$this->em->remove($task);
|
||||
unset($existingByDate[$dateKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, Task> $existingByDate
|
||||
*/
|
||||
private function resetFutureOverrides(TaskSchema $schema, array $existingByDate): void
|
||||
{
|
||||
foreach ($existingByDate as $task) {
|
||||
$task->setName($schema->getName());
|
||||
$task->setCategory($schema->getCategory());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTimeInterface[] $deadlines
|
||||
* @param array<string, Task> $existingByDate
|
||||
*/
|
||||
private function createMissingTasks(TaskSchema $schema, array $deadlines, array $existingByDate): void
|
||||
{
|
||||
foreach ($deadlines as $deadline) {
|
||||
$dateKey = $deadline->format('Y-m-d');
|
||||
if (!isset($existingByDate[$dateKey])) {
|
||||
$task = new Task();
|
||||
$task->setSchema($schema);
|
||||
$task->setDate(new \DateTime($dateKey));
|
||||
$task->setName($schema->getName());
|
||||
$task->setCategory($schema->getCategory());
|
||||
|
||||
$this->em->persist($task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +1,7 @@
|
||||
<script setup>
|
||||
import { computed, provide, ref } from 'vue'
|
||||
import { RouterView, RouterLink, useRoute } from 'vue-router'
|
||||
|
||||
const route = useRoute()
|
||||
const dynamicLabel = ref('')
|
||||
|
||||
provide('setDynamicLabel', (label) => { dynamicLabel.value = label })
|
||||
|
||||
const breadcrumbs = computed(() => {
|
||||
const items = route.meta.breadcrumb || []
|
||||
return items.map(item => ({
|
||||
...item,
|
||||
label: item.dynamic ? dynamicLabel.value : item.label,
|
||||
}))
|
||||
})
|
||||
import { RouterView } from 'vue-router'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="app-header">
|
||||
<nav class="breadcrumb">
|
||||
<RouterLink to="/" class="breadcrumb-item">Haushalt</RouterLink>
|
||||
<template v-for="(crumb, i) in breadcrumbs" :key="i">
|
||||
<span class="breadcrumb-sep">></span>
|
||||
<RouterLink v-if="crumb.to" :to="crumb.to" class="breadcrumb-item">{{ crumb.label }}</RouterLink>
|
||||
<span v-else class="breadcrumb-item breadcrumb-current">{{ crumb.label }}</span>
|
||||
</template>
|
||||
</nav>
|
||||
</header>
|
||||
<main class="app-main">
|
||||
<RouterView />
|
||||
</main>
|
||||
<RouterView />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.app-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
background: var(--bg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.breadcrumb-item {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-h);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.breadcrumb-item:first-child {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.breadcrumb-sep {
|
||||
color: var(--text);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.breadcrumb-current {
|
||||
color: var(--text);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.app-main {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
category: { type: Object, default: null },
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
class="badge"
|
||||
:style="{ backgroundColor: category?.color || '#808080' }"
|
||||
>
|
||||
{{ category?.name || 'Allgemein' }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 0.125rem 0.5rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
@@ -1,65 +0,0 @@
|
||||
<script setup>
|
||||
import TaskCard from './TaskCard.vue'
|
||||
|
||||
defineProps({
|
||||
date: { type: String, required: true },
|
||||
tasks: { type: Array, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['toggle'])
|
||||
|
||||
function formatDate(dateStr) {
|
||||
const d = new Date(dateStr + 'T00:00:00')
|
||||
return d.toLocaleDateString('de-DE', {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section v-if="tasks.length" class="day">
|
||||
<div class="day-header"><span>{{ formatDate(date) }}</span></div>
|
||||
<div class="day-tasks">
|
||||
<TaskCard
|
||||
v-for="task in tasks"
|
||||
:key="task.id"
|
||||
:task="task"
|
||||
@toggle="(taskId) => emit('toggle', taskId)"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.day {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.day-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-top: 1px solid var(--border);
|
||||
margin-top: 1.25rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.day-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);
|
||||
}
|
||||
|
||||
.day-tasks {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
@@ -1,38 +0,0 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
name: { type: String, required: true },
|
||||
})
|
||||
|
||||
const icons = {
|
||||
eyeOpen: '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>',
|
||||
eyeClosed: '<path d="M17.94 17.94A10.07 10.07 0 0112 20c-7 0-11-8-11-8a18.45 18.45 0 015.06-5.94M9.9 4.24A9.12 9.12 0 0112 4c7 0 11 8 11 8a18.5 18.5 0 01-2.16 3.19m-6.72-1.07a3 3 0 11-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/>',
|
||||
plus: '<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>',
|
||||
arrowLeft: '<polyline points="15 18 9 12 15 6"/>',
|
||||
save: '<path d="M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/>',
|
||||
trash: '<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/>',
|
||||
edit: '<path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/>',
|
||||
close: '<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>',
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<svg
|
||||
class="icon"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
v-html="icons[name]"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.icon {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
vertical-align: -0.125em;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,96 +0,0 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Array, default: () => [] },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const now = new Date()
|
||||
const daysInMonth = computed(() => new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate())
|
||||
const firstDayOffset = computed(() => (new Date(now.getFullYear(), now.getMonth(), 1).getDay() + 6) % 7)
|
||||
|
||||
function toggle(value) {
|
||||
const current = [...props.modelValue]
|
||||
const index = current.indexOf(value)
|
||||
if (index === -1) current.push(value)
|
||||
else current.splice(index, 1)
|
||||
emit('update:modelValue', current)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="monthday-picker">
|
||||
<div class="weekday-header">Mo</div>
|
||||
<div class="weekday-header">Di</div>
|
||||
<div class="weekday-header">Mi</div>
|
||||
<div class="weekday-header">Do</div>
|
||||
<div class="weekday-header">Fr</div>
|
||||
<div class="weekday-header">Sa</div>
|
||||
<div class="weekday-header">So</div>
|
||||
<div v-for="n in firstDayOffset" :key="'pad-' + n" class="day-pad"></div>
|
||||
<label
|
||||
v-for="day in daysInMonth"
|
||||
:key="day"
|
||||
class="day-option"
|
||||
:class="{ active: modelValue.includes(day) }"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="modelValue.includes(day)"
|
||||
@change="toggle(day)"
|
||||
class="sr-only"
|
||||
/>
|
||||
{{ day }}
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.monthday-picker {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.weekday-header {
|
||||
font-size: 0.6rem;
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.day-pad {
|
||||
height: 2.5rem;
|
||||
}
|
||||
|
||||
.day-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 2.5rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
transition: all 0.15s;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.day-option.active {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
}
|
||||
</style>
|
||||
@@ -1,83 +0,0 @@
|
||||
<script setup>
|
||||
import CategoryBadge from './CategoryBadge.vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const props = defineProps({
|
||||
task: { type: Object, required: true },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['toggle'])
|
||||
const router = useRouter()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="card"
|
||||
:class="{
|
||||
'card--completed': task.status === 'done',
|
||||
'card--past': task.isPast,
|
||||
}"
|
||||
@click="emit('toggle', task.id)"
|
||||
>
|
||||
<div class="card-left">
|
||||
<span class="task-name">{{ task.name }}</span>
|
||||
<CategoryBadge :category="task.category" />
|
||||
</div>
|
||||
<div class="card-right" @click.stop>
|
||||
<button @click="router.push({ name: 'task-detail', params: { id: task.id } })">
|
||||
Anzeigen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 0.5rem 0.75rem;
|
||||
cursor: pointer;
|
||||
transition: box-shadow 0.15s;
|
||||
}
|
||||
|
||||
.card:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.card--completed {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.card--completed .task-name {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.card--past {
|
||||
border-left: 3px solid var(--danger);
|
||||
background: var(--danger-bg);
|
||||
}
|
||||
|
||||
.card-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.task-name {
|
||||
font-weight: 500;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
.card-right button {
|
||||
font-size: 0.75rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
}
|
||||
</style>
|
||||
@@ -1,84 +0,0 @@
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
modelValue: { type: Array, default: () => [] },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const days = [
|
||||
{ value: 1, label: 'Mo' },
|
||||
{ value: 2, label: 'Di' },
|
||||
{ value: 3, label: 'Mi' },
|
||||
{ value: 4, label: 'Do' },
|
||||
{ value: 5, label: 'Fr' },
|
||||
{ value: 6, label: 'Sa' },
|
||||
{ value: 7, label: 'So' },
|
||||
]
|
||||
|
||||
function toggle(value) {
|
||||
const current = [...props.modelValue]
|
||||
const index = current.indexOf(value)
|
||||
if (index === -1) {
|
||||
current.push(value)
|
||||
} else {
|
||||
current.splice(index, 1)
|
||||
}
|
||||
emit('update:modelValue', current)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="weekday-picker">
|
||||
<label
|
||||
v-for="day in days"
|
||||
:key="day.value"
|
||||
class="day-option"
|
||||
:class="{ active: modelValue.includes(day.value) }"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="modelValue.includes(day.value)"
|
||||
@change="toggle(day.value)"
|
||||
class="sr-only"
|
||||
/>
|
||||
{{ day.label }}
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.weekday-picker {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.day-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
transition: all 0.15s;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.day-option.active {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
}
|
||||
</style>
|
||||
@@ -1,185 +0,0 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Array, default: () => [] },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
const monthNames = ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
|
||||
|
||||
function buildCells(startIndex, count) {
|
||||
const now = new Date()
|
||||
const currentMonth = now.getMonth()
|
||||
const currentYear = now.getFullYear()
|
||||
const result = []
|
||||
|
||||
let row = 2
|
||||
let col = 2
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
const idx = startIndex + i
|
||||
const m = (currentMonth + idx) % 12
|
||||
const y = currentYear + Math.floor((currentMonth + idx) / 12)
|
||||
const daysInMonth = new Date(y, m + 1, 0).getDate()
|
||||
const firstDayOffset = (new Date(y, m, 1).getDay() + 6) % 7
|
||||
|
||||
result.push({
|
||||
type: 'label',
|
||||
name: monthNames[m],
|
||||
row,
|
||||
col: 1,
|
||||
key: `label-${y}-${m}`,
|
||||
})
|
||||
|
||||
if (i === 0) {
|
||||
row++
|
||||
col = 2 + firstDayOffset
|
||||
} else {
|
||||
const newCol = 2 + firstDayOffset
|
||||
if (newCol < col) {
|
||||
row++
|
||||
}
|
||||
col = newCol
|
||||
}
|
||||
|
||||
for (let d = 1; d <= daysInMonth; d++) {
|
||||
result.push({
|
||||
type: 'day',
|
||||
month: m + 1,
|
||||
day: d,
|
||||
row,
|
||||
col,
|
||||
key: `d-${y}-${m}-${d}`,
|
||||
})
|
||||
col++
|
||||
if (col > 8) {
|
||||
col = 2
|
||||
row++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
const totalMonths = 12 - new Date().getMonth()
|
||||
const leftCount = Math.ceil(totalMonths / 2)
|
||||
const rightCount = totalMonths - leftCount
|
||||
|
||||
const leftCells = computed(() => buildCells(0, leftCount))
|
||||
const rightCells = computed(() => buildCells(leftCount, rightCount))
|
||||
|
||||
function isSelected(month, day) {
|
||||
return props.modelValue.some(yd => yd.month === month && yd.day === day)
|
||||
}
|
||||
|
||||
function toggle(month, day) {
|
||||
const current = [...props.modelValue]
|
||||
const index = current.findIndex(yd => yd.month === month && yd.day === day)
|
||||
if (index === -1) {
|
||||
current.push({ month, day })
|
||||
} else {
|
||||
current.splice(index, 1)
|
||||
}
|
||||
emit('update:modelValue', current)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="year-picker-columns">
|
||||
<div v-for="(cells, side) in [leftCells, rightCells]" :key="side" class="year-picker">
|
||||
<div class="header" style="grid-row:1;grid-column:1"></div>
|
||||
<div class="weekday-header" style="grid-row:1;grid-column:2">Mo</div>
|
||||
<div class="weekday-header" style="grid-row:1;grid-column:3">Di</div>
|
||||
<div class="weekday-header" style="grid-row:1;grid-column:4">Mi</div>
|
||||
<div class="weekday-header" style="grid-row:1;grid-column:5">Do</div>
|
||||
<div class="weekday-header" style="grid-row:1;grid-column:6">Fr</div>
|
||||
<div class="weekday-header" style="grid-row:1;grid-column:7">Sa</div>
|
||||
<div class="weekday-header" style="grid-row:1;grid-column:8">So</div>
|
||||
|
||||
<template v-for="cell in cells" :key="cell.key">
|
||||
<div
|
||||
v-if="cell.type === 'label'"
|
||||
class="month-label"
|
||||
:style="{ gridRow: cell.row, gridColumn: cell.col }"
|
||||
>
|
||||
{{ cell.name }}
|
||||
</div>
|
||||
<label
|
||||
v-else
|
||||
class="day-option"
|
||||
:class="{ active: isSelected(cell.month, cell.day) }"
|
||||
:style="{ gridRow: cell.row, gridColumn: cell.col }"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isSelected(cell.month, cell.day)"
|
||||
@change="toggle(cell.month, cell.day)"
|
||||
class="sr-only"
|
||||
/>
|
||||
{{ cell.day }}
|
||||
</label>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.year-picker-columns {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.year-picker {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 2.5rem repeat(7, 1fr);
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.weekday-header {
|
||||
font-size: 0.6rem;
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.month-label {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-h);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.day-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 2rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 0.65rem;
|
||||
color: var(--text);
|
||||
transition: all 0.15s;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.day-option.active {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
}
|
||||
</style>
|
||||
@@ -1,46 +1,8 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import HomeView from '../views/HomeView.vue'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
component: HomeView,
|
||||
meta: { breadcrumb: [] },
|
||||
},
|
||||
{
|
||||
path: '/tasks/all',
|
||||
name: 'tasks-all',
|
||||
component: () => import('../views/AllTasksView.vue'),
|
||||
meta: { breadcrumb: [{ label: 'Übersicht' }] },
|
||||
},
|
||||
{
|
||||
path: '/tasks/new',
|
||||
name: 'schema-create',
|
||||
component: () => import('../views/SchemaView.vue'),
|
||||
meta: { breadcrumb: [{ label: 'Übersicht', to: '/tasks/all' }, { label: 'Neue Aufgabe' }] },
|
||||
},
|
||||
{
|
||||
path: '/tasks/:id',
|
||||
name: 'task-detail',
|
||||
component: () => import('../views/TaskDetailView.vue'),
|
||||
meta: { breadcrumb: [{ label: 'Übersicht', to: '/tasks/all' }, { label: '', dynamic: true }] },
|
||||
},
|
||||
{
|
||||
path: '/schemas/:id',
|
||||
name: 'schema-detail',
|
||||
component: () => import('../views/SchemaView.vue'),
|
||||
meta: { breadcrumb: [{ label: 'Übersicht', to: '/tasks/all' }, { label: '', dynamic: true }] },
|
||||
},
|
||||
{
|
||||
path: '/categories',
|
||||
name: 'categories',
|
||||
component: () => import('../views/CategoriesView.vue'),
|
||||
meta: { breadcrumb: [{ label: 'Kategorien' }] },
|
||||
},
|
||||
],
|
||||
routes: [],
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
const API_BASE = `${location.protocol}//${location.hostname}/api`
|
||||
|
||||
async function request(path, options = {}) {
|
||||
const url = API_BASE + path
|
||||
const res = await fetch(url, {
|
||||
headers: { 'Content-Type': 'application/json', ...options.headers },
|
||||
...options,
|
||||
})
|
||||
if (res.status === 204) return null
|
||||
if (!res.ok) {
|
||||
const err = await res.json().catch(() => ({}))
|
||||
throw { status: res.status, body: err }
|
||||
}
|
||||
return res.json()
|
||||
}
|
||||
|
||||
// Categories
|
||||
export const getCategories = () => request('/categories')
|
||||
export const getCategory = (id) => request(`/categories/${id}`)
|
||||
export const createCategory = (data) => request('/categories', { method: 'POST', body: JSON.stringify(data) })
|
||||
export const updateCategory = (id, data) => request(`/categories/${id}`, { method: 'PUT', body: JSON.stringify(data) })
|
||||
export const deleteCategory = (id) => request(`/categories/${id}`, { method: 'DELETE' })
|
||||
|
||||
// Schemas
|
||||
export const getSchemas = () => request('/schemas')
|
||||
export const getSchema = (id) => request(`/schemas/${id}`)
|
||||
export const createSchema = (data) => request('/schemas', { method: 'POST', body: JSON.stringify(data) })
|
||||
export const updateSchema = (id, data) => request(`/schemas/${id}`, { method: 'PUT', body: JSON.stringify(data) })
|
||||
export const deleteSchema = (id, deleteTasks = false) => {
|
||||
const params = deleteTasks ? '?deleteTasks=1' : ''
|
||||
return request(`/schemas/${id}${params}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
// Tasks
|
||||
export const getTasks = () => request('/tasks')
|
||||
export const getTask = (id) => request(`/tasks/${id}`)
|
||||
export const createTask = (data) => request('/tasks', { method: 'POST', body: JSON.stringify(data) })
|
||||
export const updateTask = (id, data) => request(`/tasks/${id}`, { method: 'PUT', body: JSON.stringify(data) })
|
||||
export const deleteTask = (id) => request(`/tasks/${id}`, { method: 'DELETE' })
|
||||
export const toggleTask = (id) => request(`/tasks/${id}/toggle`, { method: 'PATCH' })
|
||||
@@ -1,34 +0,0 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import * as api from '../services/api'
|
||||
|
||||
export const useCategoriesStore = defineStore('categories', () => {
|
||||
const items = ref([])
|
||||
const loaded = ref(false)
|
||||
|
||||
async function fetchCategories(force = false) {
|
||||
if (loaded.value && !force) return
|
||||
items.value = await api.getCategories()
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
async function addCategory(data) {
|
||||
const category = await api.createCategory(data)
|
||||
items.value.push(category)
|
||||
return category
|
||||
}
|
||||
|
||||
async function editCategory(id, data) {
|
||||
const updated = await api.updateCategory(id, data)
|
||||
const index = items.value.findIndex((c) => c.id === id)
|
||||
if (index !== -1) items.value[index] = updated
|
||||
return updated
|
||||
}
|
||||
|
||||
async function removeCategory(id) {
|
||||
await api.deleteCategory(id)
|
||||
items.value = items.value.filter((c) => c.id !== id)
|
||||
}
|
||||
|
||||
return { items, loaded, fetchCategories, addCategory, editCategory, removeCategory }
|
||||
})
|
||||
@@ -1,140 +0,0 @@
|
||||
:root {
|
||||
--text: #6b6375;
|
||||
--text-h: #08060d;
|
||||
--bg: #fff;
|
||||
--border: #e5e4e7;
|
||||
--accent: #aa3bff;
|
||||
--accent-bg: rgba(170, 59, 255, 0.1);
|
||||
--danger: #dc2626;
|
||||
--danger-bg: rgba(220, 38, 38, 0.1);
|
||||
--warning: #f59e0b;
|
||||
--warning-bg: rgba(245, 158, 11, 0.1);
|
||||
--success: #16a34a;
|
||||
--shadow: rgba(0, 0, 0, 0.1) 0 2px 8px;
|
||||
|
||||
--sans: system-ui, 'Segoe UI', Roboto, sans-serif;
|
||||
|
||||
font: 16px/1.5 var(--sans);
|
||||
color-scheme: light dark;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--text: #9ca3af;
|
||||
--text-h: #f3f4f6;
|
||||
--bg: #16171d;
|
||||
--border: #2e303a;
|
||||
--accent: #c084fc;
|
||||
--accent-bg: rgba(192, 132, 252, 0.15);
|
||||
--danger: #ef4444;
|
||||
--danger-bg: rgba(239, 68, 68, 0.15);
|
||||
--warning: #fbbf24;
|
||||
--warning-bg: rgba(251, 191, 36, 0.15);
|
||||
--success: #22c55e;
|
||||
--shadow: rgba(0, 0, 0, 0.3) 0 2px 8px;
|
||||
}
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
font-weight: 600;
|
||||
color: var(--text-h);
|
||||
margin: 0 0 0.5rem;
|
||||
}
|
||||
|
||||
h1 { font-size: 1.5rem; }
|
||||
h2 { font-size: 1.25rem; }
|
||||
h3 { font-size: 1rem; }
|
||||
|
||||
a {
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
button {
|
||||
font-family: var(--sans);
|
||||
font-size: 0.875rem;
|
||||
padding: 0.5rem 1rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: var(--bg);
|
||||
color: var(--text-h);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
color: var(--danger);
|
||||
border-color: var(--danger);
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: var(--danger-bg);
|
||||
}
|
||||
|
||||
input[type="text"],
|
||||
input[type="date"],
|
||||
select {
|
||||
font-family: var(--sans);
|
||||
font-size: 0.875rem;
|
||||
padding: 0.5rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: var(--bg);
|
||||
color: var(--text-h);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
input[type="text"]:focus,
|
||||
input[type="date"]:focus,
|
||||
select:focus {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: -1px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-h);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { getSchemas, getTasks, 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 getSchemas()
|
||||
: await getTasks()
|
||||
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',
|
||||
})
|
||||
}
|
||||
|
||||
function getDateKey(item) {
|
||||
if (!item.date) return null
|
||||
return item.date.split('T')[0]
|
||||
}
|
||||
|
||||
const groupedItems = computed(() => {
|
||||
const today = new Date().toISOString().split('T')[0]
|
||||
const noDate = items.value.filter(i => !getDateKey(i))
|
||||
const current = items.value.filter(i => {
|
||||
const d = getDateKey(i)
|
||||
return d && d >= today
|
||||
})
|
||||
const past = items.value.filter(i => {
|
||||
const d = getDateKey(i)
|
||||
return d && d < today
|
||||
})
|
||||
|
||||
const monthMap = {}
|
||||
const months = []
|
||||
for (const item of past) {
|
||||
const dateKey = getDateKey(item)
|
||||
const d = new Date(dateKey + 'T00:00:00')
|
||||
const sortKey = dateKey.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.id)
|
||||
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 === 'done' }">{{ item.name }}</span>
|
||||
<CategoryBadge :category="item.category" />
|
||||
</div>
|
||||
<div class="task-right" @click.stop>
|
||||
<button @click="router.push({ name: 'task-detail', params: { id: item.id } })">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 === 'done' }">{{ item.name }}</span>
|
||||
<CategoryBadge :category="item.category" />
|
||||
</div>
|
||||
<div class="task-right" @click.stop>
|
||||
<span class="task-date">{{ formatDate(getDateKey(item)) }}</span>
|
||||
<button @click="router.push({ name: 'task-detail', params: { id: item.id } })">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 === 'done' }">{{ item.name }}</span>
|
||||
<CategoryBadge :category="item.category" />
|
||||
</div>
|
||||
<span class="task-date">{{ formatDate(getDateKey(item)) }}</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>
|
||||
@@ -1,141 +0,0 @@
|
||||
<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>
|
||||
@@ -1,129 +0,0 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useCategoriesStore } from '../stores/categories'
|
||||
import { getTasks, 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 allTasks = ref([])
|
||||
const loading = ref(true)
|
||||
const showCompleted = ref(true)
|
||||
|
||||
function getWeekDates() {
|
||||
const now = new Date()
|
||||
const day = now.getDay()
|
||||
const monday = new Date(now)
|
||||
monday.setDate(now.getDate() - ((day + 6) % 7))
|
||||
const dates = []
|
||||
for (let i = 0; i < 7; i++) {
|
||||
const d = new Date(monday)
|
||||
d.setDate(monday.getDate() + i)
|
||||
dates.push(d.toISOString().split('T')[0])
|
||||
}
|
||||
return dates
|
||||
}
|
||||
|
||||
const weekDates = getWeekDates()
|
||||
|
||||
function filterTasks(tasks) {
|
||||
if (showCompleted.value) return tasks
|
||||
return tasks.filter(t => t.status !== 'done')
|
||||
}
|
||||
|
||||
const tasksWithoutDeadline = computed(() => {
|
||||
const tasks = allTasks.value.filter(t => t.date === null)
|
||||
return filterTasks(tasks)
|
||||
})
|
||||
|
||||
const days = computed(() => {
|
||||
return weekDates.map(date => {
|
||||
const tasks = allTasks.value.filter(t => {
|
||||
if (!t.date) return false
|
||||
return t.date.split('T')[0] === date
|
||||
})
|
||||
return { date, tasks: filterTasks(tasks) }
|
||||
})
|
||||
})
|
||||
|
||||
async function fetchTasks(showLoading = true) {
|
||||
if (showLoading) loading.value = true
|
||||
try {
|
||||
allTasks.value = await getTasks()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleToggle(taskId) {
|
||||
await toggleTask(taskId)
|
||||
await fetchTasks(false)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
categoriesStore.fetchCategories()
|
||||
fetchTasks()
|
||||
})
|
||||
</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>
|
||||
@@ -1,294 +0,0 @@
|
||||
<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 deleteTasksOnRemove = ref(false)
|
||||
|
||||
const form = ref({
|
||||
name: '',
|
||||
categoryId: null,
|
||||
status: 'active',
|
||||
type: 'single',
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
days: {
|
||||
week: [],
|
||||
month: [],
|
||||
year: [],
|
||||
},
|
||||
})
|
||||
|
||||
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,
|
||||
type: task.type,
|
||||
startDate: formatDateForInput(task.startDate),
|
||||
endDate: formatDateForInput(task.endDate),
|
||||
days: {
|
||||
week: task.days?.week || [],
|
||||
month: task.days?.month || [],
|
||||
year: task.days?.year || [],
|
||||
},
|
||||
}
|
||||
setDynamicLabel(task.name)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function buildPayload() {
|
||||
const f = form.value
|
||||
const payload = {
|
||||
name: f.name,
|
||||
categoryId: f.categoryId,
|
||||
status: f.status,
|
||||
type: f.type,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
days: null,
|
||||
}
|
||||
|
||||
if (f.type === 'single') {
|
||||
payload.days = { year: f.days.year }
|
||||
} else if (f.type === 'daily') {
|
||||
payload.startDate = f.startDate
|
||||
payload.endDate = f.endDate
|
||||
} else if (f.type === 'custom') {
|
||||
payload.startDate = f.startDate
|
||||
payload.endDate = f.endDate
|
||||
const days = {}
|
||||
if (f.days.week.length) days.week = f.days.week
|
||||
if (f.days.month.length) days.month = f.days.month
|
||||
if (f.days.year.length) days.year = f.days.year
|
||||
payload.days = Object.keys(days).length ? days : null
|
||||
}
|
||||
|
||||
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('Schema wirklich löschen?')) return
|
||||
await deleteSchema(route.params.id, deleteTasksOnRemove.value)
|
||||
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="active">Aktiv</option>
|
||||
<option value="disabled">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.type" value="single" /> Einzel
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" v-model="form.type" value="daily" /> Täglich
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" v-model="form.type" value="custom" /> Benutzerdefiniert
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Einzel: Jahresansicht -->
|
||||
<div v-if="form.type === 'single'" class="form-group">
|
||||
<label>Tage auswählen</label>
|
||||
<YearPicker v-model="form.days.year" />
|
||||
</div>
|
||||
|
||||
<!-- Daily + Custom: Start + Enddatum -->
|
||||
<template v-if="form.type === 'daily' || form.type === 'custom'">
|
||||
<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>
|
||||
|
||||
<!-- Custom: Alle Picker -->
|
||||
<template v-if="form.type === 'custom'">
|
||||
<div class="form-group">
|
||||
<label>Wochentage</label>
|
||||
<WeekdayPicker v-model="form.days.week" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Monatstage</label>
|
||||
<MonthdayPicker v-model="form.days.month" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Jahresansicht</label>
|
||||
<YearPicker v-model="form.days.year" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<p v-if="error" class="error">{{ error }}</p>
|
||||
|
||||
<div v-if="isEdit" class="form-actions">
|
||||
<div class="delete-section">
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" v-model="deleteTasksOnRemove" />
|
||||
Aufgaben löschen
|
||||
</label>
|
||||
<button type="button" class="btn-danger" @click="remove">
|
||||
<Icon name="trash" />
|
||||
</button>
|
||||
</div>
|
||||
</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;
|
||||
}
|
||||
|
||||
.delete-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.error {
|
||||
color: var(--danger);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
@@ -1,122 +0,0 @@
|
||||
<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: 'active', 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="active">Aktiv</option>
|
||||
<option value="done">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