Added task editing page

This commit is contained in:
Marta Borgia Leiva 2026-02-11 10:50:13 +01:00
parent ffc79a28dc
commit 69edc4e197
9 changed files with 322 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, Input, Output, inject } from '@angular/core';
import { Router } from '@angular/router';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Task } from '../../models/tasks.models';
@ -11,6 +12,7 @@ import { Task } from '../../models/tasks.models';
styleUrl: './task-item.component.css',
})
export class TaskItemComponent {
private router = inject(Router);
private _task!: Task;
statusValue: Task['status'] = 'pending';
@ -24,6 +26,9 @@ export class TaskItemComponent {
return this._task;
}
@Input()
projectId?: number;
@Output() statusChange = new EventEmitter<{
task: Task;
status: Task['status'];
@ -59,4 +64,14 @@ export class TaskItemComponent {
this.remove.emit(this._task);
}
}
onEdit() {
if (!this._task || this.projectId == null) {
return;
}
this.router.navigate(['/projects', this.projectId, 'tasks', this._task.id, 'edit'], {
state: { task: this._task },
});
}
}