From 08173fbdc3db4d105aa84b10e9885c86127626d8 Mon Sep 17 00:00:00 2001 From: Maxime Delporte Date: Mon, 21 Apr 2025 12:57:42 -0300 Subject: [PATCH] Adding add task functionnality: without personalisation right now. --- src/app/tasks/tasks.component.html | 4 ++-- src/app/tasks/tasks.component.ts | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/app/tasks/tasks.component.html b/src/app/tasks/tasks.component.html index 14fe5ec..8d08920 100644 --- a/src/app/tasks/tasks.component.html +++ b/src/app/tasks/tasks.component.html @@ -2,7 +2,7 @@

{{ user.name }}'s Tasks

- +
@@ -12,7 +12,7 @@
  • } diff --git a/src/app/tasks/tasks.component.ts b/src/app/tasks/tasks.component.ts index 9b2f553..95bbba4 100644 --- a/src/app/tasks/tasks.component.ts +++ b/src/app/tasks/tasks.component.ts @@ -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); } }