bug : enregistre en base cocher toutes les taches

This commit is contained in:
HarmandI 2022-03-05 20:22:10 +01:00
parent 3d16635cef
commit cca4e96f2b
3 changed files with 15 additions and 11 deletions

View file

@ -3,7 +3,7 @@ import { Router } from '@angular/router';
import { Tache } from 'src/app/models/tache';
import { ToDoList } from 'src/app/models/to-do-list';
import { TodoService } from 'src/app/services/todo.service';
import { TodoList } from 'src/app/todo-list';
@Component({
selector: 'app-to-do-list',
@ -13,7 +13,6 @@ import { TodoList } from 'src/app/todo-list';
export class ToDoListComponent implements OnInit {
@Input() todo!: ToDoList;
public beforeEditCache: string;
//public todos: ToDoList[];
public todoTitle: string;
public idTodo: number;
public filter: string;
@ -24,7 +23,6 @@ export class ToDoListComponent implements OnInit {
constructor(private TodoService: TodoService, private router: Router) {
this.beforeEditCache = '';
//this.todos = [];
this.todoTitle = '';
this.idTodo = 0;
this.filter = '';
@ -37,8 +35,10 @@ export class ToDoListComponent implements OnInit {
this.beforeEditCache = '';
this.casesRestantes = true;
this.filter = 'tous';
this.idTodo = 4;
this.todoTitle = '';
if (this.toDoRest()===0){
this.masterSelected=true;
}
}
//supprimer la todoList en fonction de son id
deleteTodo(id: number): void {
@ -81,7 +81,7 @@ export class ToDoListComponent implements OnInit {
tache.editing = true;
}
// modifier une tâche validation de l'input
// modifier une tâche validation de l'input + update check
doneEdit(tache: Tache): void {
if (tache.texte.trim().length === 0) {
tache.texte = this.beforeEditCache;
@ -112,17 +112,21 @@ export class ToDoListComponent implements OnInit {
return this.todo.taches.filter((tache: Tache) => !tache.etat).length;
}
//Cocher toutes les tâches de la liste
//Vérifie si toutes les tâches de la liste sont cochées
listComplete(): boolean {
return this.todo.taches.filter((tache: Tache) => tache).length > 0;
}
//cocher toutes les cases de la todoList
//cocher/décoche les éléments à partir de la case checkAll
cocherAllTodoList(): void {
for (var i = 0; i < this.todo.taches.length; i++) {
this.todo.taches[i].etat = this.masterSelected;
this.TodoService.updateTache(this.todo.taches[i]).subscribe((resp) => {
console.log(this.todo.taches[i]);
});
}
this.cocherAllTodoList();
//this.cocherAllTodoList();
}
casesQuiRestes(): boolean {

View file

@ -1,7 +1,7 @@
<app-header></app-header>
<div class="row">
<div class="col-md-auto">
<app-side-bar></app-side-bar>
<app-side-bar [backgroundColor]="'#4E9E7B'"></app-side-bar>
</div>
<div class="col menu text-center">
<h2>To-Do-List</h2>

View file

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ToDoList } from 'src/app/models/to-do-list';
import { TodoService } from 'src/app/services/todo.service';
import { Team } from 'src/app/models/team';
@Component({
selector: 'app-page-to-do-list',
@ -30,7 +30,7 @@ export class PageToDoListComponent implements OnInit {
});
}
//Ajouter une todo List si l'input n'est pas vide
//Ajouter une todo List si l'input contient un texte
addTodoByTeamId() {
const todoList: ToDoList = {
nom: this.todoListTitle,