Adding add task functionnality: without personalisation right now.
All checks were successful
Deploying Website / build (push) Successful in 1m1s

This commit is contained in:
Maxime Delporte 2025-04-21 12:57:42 -03:00
parent d4fe4db6ff
commit 08173fbdc3
2 changed files with 20 additions and 7 deletions

View File

@ -2,7 +2,7 @@
<header>
<h2>{{ user.name }}'s Tasks</h2>
<menu>
<button>Add Task</button>
<button (click)="onAddTask()">Add Task</button>
</menu>
</header>
@ -12,7 +12,7 @@
<li>
<app-task
[task]="task"
(complete)="onDeleteTask($event)"
(complete)="onCompleteTask($event)"
/>
</li>
}

View File

@ -17,8 +17,7 @@ export class TasksComponent {
id: 't1',
userId: 'u1',
title: 'Master Angular',
summary:
'Learn all the basic and advanced features of Angular & how to apply them.',
summary: 'Learn all the basic and advanced features of Angular & how to apply them.',
dueDate: '2025-12-31',
},
{
@ -32,8 +31,7 @@ export class TasksComponent {
id: 't3',
userId: 'u3',
title: 'Prepare issue template',
summary:
'Prepare and describe an issue template which will help with project management',
summary: 'Prepare and describe an issue template which will help with project management',
dueDate: '2024-06-15',
},
];
@ -42,7 +40,22 @@ export class TasksComponent {
return this.tasks.filter((task) => task.userId === this.user.id);
}
onDeleteTask(taskId: string) {
onAddTask() {
let taskNumber = this.tasks.length + 2;
let taskId = 't' + (taskNumber).toString();
let newTask: Task = {
id: taskId,
userId: this.user.id,
title: 'New task for ' + this.user.name,
summary: 'Summary',
dueDate: '2025-12-31',
};
this.tasks.push(newTask);
}
onCompleteTask(taskId: string) {
this.tasks = this.tasks.filter((task) => task.id !== taskId);
}
}