From c162d5060534d442fa9ad4be88e89345771f5b30 Mon Sep 17 00:00:00 2001 From: HarmandI Date: Sun, 6 Mar 2022 18:50:11 +0100 Subject: [PATCH] Corrections des bugs --- .../to-do-list/to-do-list.component.scss | 4 +-- .../to-do-list/to-do-list.component.ts | 27 +++++++++++++------ src/app/models/to-do-list.ts | 1 + 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/app/components/to-do-list/to-do-list.component.scss b/src/app/components/to-do-list/to-do-list.component.scss index 7bfbde7..8ce3710 100644 --- a/src/app/components/to-do-list/to-do-list.component.scss +++ b/src/app/components/to-do-list/to-do-list.component.scss @@ -58,7 +58,7 @@ } .deleteTache { - width: 75%; + width: 10%; cursor: pointer; margin-left: 14px; &:hover { @@ -77,7 +77,7 @@ } .modifier-element { - font-size: 24px; + font-size: 18px; color: white; margin-left: 12px; width: 100%; diff --git a/src/app/components/to-do-list/to-do-list.component.ts b/src/app/components/to-do-list/to-do-list.component.ts index 0892eb3..15ae91a 100644 --- a/src/app/components/to-do-list/to-do-list.component.ts +++ b/src/app/components/to-do-list/to-do-list.component.ts @@ -4,7 +4,6 @@ import { Tache } from 'src/app/models/tache'; import { ToDoList } from 'src/app/models/to-do-list'; import { TodoService } from 'src/app/services/todo.service'; - @Component({ selector: 'app-to-do-list', templateUrl: './to-do-list.component.html', @@ -36,8 +35,8 @@ export class ToDoListComponent implements OnInit { this.casesRestantes = true; this.filter = 'tous'; this.todoTitle = ''; - if (this.toDoRest()===0){ - this.masterSelected=true; + if (this.toDoRest() === 0) { + this.masterSelected = true; } } //supprimer la todoList en fonction de son id @@ -52,6 +51,7 @@ export class ToDoListComponent implements OnInit { addTache(idTodoList: number) { //idTodoList id que la todoList que l'on récupère console.log(idTodoList); + //permet de construire l'objet à passer en base const tache: Tache = { id: 0, texte: this.todoTitle, @@ -70,9 +70,19 @@ export class ToDoListComponent implements OnInit { //modifier le titre de la to-do-list updateTodo(todoList: ToDoList): void { - this.TodoService.updateTodo(todoList)?.subscribe((resp) => { - window.location.reload(); - }); + let nouvelleTodolist = { + id: todoList.id, + nom: todoList.nom, + team: todoList.team, + }; + console.log(todoList.team); + if (nouvelleTodolist.nom != '') { + this.TodoService.updateTodo(nouvelleTodolist)?.subscribe((resp) => { + window.location.reload(); + }); + } else { + window.alert('Il faut saisir du texte'); // sinon msg d'erreur} + } } //modifier la tâche par l'input @@ -94,12 +104,14 @@ export class ToDoListComponent implements OnInit { }); } - // annuler la modification + // annuler la modification de la tâche cancelEdit(tache: Tache): void { tache.texte = this.beforeEditCache; tache.editing = false; } + + //supprimer la tache deleteTache(id: number) { this.TodoService.deleteTacheById(id).subscribe((resp) => { @@ -123,7 +135,6 @@ export class ToDoListComponent implements OnInit { this.todo.taches[i].etat = this.masterSelected; this.TodoService.updateTache(this.todo.taches[i]).subscribe((resp) => { console.log(this.todo.taches[i]); - }); } //this.cocherAllTodoList(); diff --git a/src/app/models/to-do-list.ts b/src/app/models/to-do-list.ts index 4b8c345..219a143 100644 --- a/src/app/models/to-do-list.ts +++ b/src/app/models/to-do-list.ts @@ -5,4 +5,5 @@ export interface ToDoList { nom: string; taches: Tache[]; id: number; + team? : Team; }