Adding add task functionnality: without personalisation right now.
All checks were successful
Deploying Website / build (push) Successful in 1m1s
All checks were successful
Deploying Website / build (push) Successful in 1m1s
This commit is contained in:
parent
d4fe4db6ff
commit
08173fbdc3
@ -2,7 +2,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<h2>{{ user.name }}'s Tasks</h2>
|
<h2>{{ user.name }}'s Tasks</h2>
|
||||||
<menu>
|
<menu>
|
||||||
<button>Add Task</button>
|
<button (click)="onAddTask()">Add Task</button>
|
||||||
</menu>
|
</menu>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<app-task
|
<app-task
|
||||||
[task]="task"
|
[task]="task"
|
||||||
(complete)="onDeleteTask($event)"
|
(complete)="onCompleteTask($event)"
|
||||||
/>
|
/>
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,7 @@ export class TasksComponent {
|
|||||||
id: 't1',
|
id: 't1',
|
||||||
userId: 'u1',
|
userId: 'u1',
|
||||||
title: 'Master Angular',
|
title: 'Master Angular',
|
||||||
summary:
|
summary: 'Learn all the basic and advanced features of Angular & how to apply them.',
|
||||||
'Learn all the basic and advanced features of Angular & how to apply them.',
|
|
||||||
dueDate: '2025-12-31',
|
dueDate: '2025-12-31',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -32,8 +31,7 @@ export class TasksComponent {
|
|||||||
id: 't3',
|
id: 't3',
|
||||||
userId: 'u3',
|
userId: 'u3',
|
||||||
title: 'Prepare issue template',
|
title: 'Prepare issue template',
|
||||||
summary:
|
summary: 'Prepare and describe an issue template which will help with project management',
|
||||||
'Prepare and describe an issue template which will help with project management',
|
|
||||||
dueDate: '2024-06-15',
|
dueDate: '2024-06-15',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -42,7 +40,22 @@ export class TasksComponent {
|
|||||||
return this.tasks.filter((task) => task.userId === this.user.id);
|
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);
|
this.tasks = this.tasks.filter((task) => task.id !== taskId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user