diff --git a/package.json b/package.json index 9be2cbb..3e42c9e 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "@angular/platform-browser": "~12.2.0", "@angular/platform-browser-dynamic": "~12.2.0", "@angular/router": "~12.2.0", - "ngx-cookie-service": "^12.0.3", "rxjs": "~6.6.0", "tslib": "^2.3.0", "uuid": "^8.3.2", diff --git a/src/app/active-list-tasks/active-list-tasks.component.html b/src/app/active-list-tasks/active-list-tasks.component.html index 37f25c2..d2a3de0 100644 --- a/src/app/active-list-tasks/active-list-tasks.component.html +++ b/src/app/active-list-tasks/active-list-tasks.component.html @@ -1,7 +1,10 @@
- +
add - +
diff --git a/src/app/active-list-tasks/active-list-tasks.component.ts b/src/app/active-list-tasks/active-list-tasks.component.ts index ef70d9d..3593934 100644 --- a/src/app/active-list-tasks/active-list-tasks.component.ts +++ b/src/app/active-list-tasks/active-list-tasks.component.ts @@ -1,7 +1,9 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; +import { FormControl, Validators } from '@angular/forms'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Router } from '@angular/router'; import { Subscription } from 'rxjs'; +import { Task } from '../core/entity/task'; import { TaskList } from '../core/entity/task-list'; import { TaskListService } from '../core/service/task-list.service'; @@ -11,8 +13,9 @@ import { TaskListService } from '../core/service/task-list.service'; styleUrls: ['./active-list-tasks.component.scss'] }) export class ActiveListTasksComponent implements OnInit, OnDestroy { - private _activeTaskList?: TaskList; private _storeSubscription?: Subscription; + activeTaskList?: TaskList; + newTaskControl: FormControl = new FormControl(undefined, Validators.required); constructor( private _router: Router, @@ -23,8 +26,8 @@ export class ActiveListTasksComponent implements OnInit, OnDestroy { ngOnInit(): void { this._storeSubscription = this._taskListService.store$.subscribe(store => { if (store.activeTaskListId) { - this._activeTaskList = store.taskLists.find(taskList => taskList.id === store.activeTaskListId); - if (!this._activeTaskList) { + this.activeTaskList = store.taskLists.find(taskList => taskList.id === store.activeTaskListId); + if (!this.activeTaskList) { this._backToTaskListPane(); } } @@ -36,7 +39,21 @@ export class ActiveListTasksComponent implements OnInit, OnDestroy { } private _backToTaskListPane(): void { - this._snackBar.open('La task-list active n\'existe pas dans le store.', 'Fermer', {duration: 5000}); + console.error('La task-list active n\'existe pas dans le store.', 'Fermer', {duration: 5000}); this._router.navigate(['/']); } + + onNewTaskKeyDown(event: KeyboardEvent): void { + if (event.key === 'Enter') { + if (this.newTaskControl.valid) { + const newTask = { + title: this.newTaskControl.value as string, + creationDate: new Date(), + description: undefined as unknown as string + } as Task; + + this._taskListService.addTask(newTask); + } + } + } } diff --git a/src/app/active-list-tasks/task-display/task-display.component.html b/src/app/active-list-tasks/task-display/task-display.component.html index bfd5e0a..4a36f1b 100644 --- a/src/app/active-list-tasks/task-display/task-display.component.html +++ b/src/app/active-list-tasks/task-display/task-display.component.html @@ -3,7 +3,7 @@ drag_handle
- +