Merge pull request #87 from AlineRinquin/isa2

bug : enregistre en base cocher toutes les taches
This commit is contained in:
AlineRinquin 2022-03-06 12:12:26 +01:00 committed by GitHub
commit 773b8a1b87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 { Tache } from 'src/app/models/tache';
import { ToDoList } from 'src/app/models/to-do-list'; import { ToDoList } from 'src/app/models/to-do-list';
import { TodoService } from 'src/app/services/todo.service'; import { TodoService } from 'src/app/services/todo.service';
import { TodoList } from 'src/app/todo-list';
@Component({ @Component({
selector: 'app-to-do-list', selector: 'app-to-do-list',
@ -13,7 +13,6 @@ import { TodoList } from 'src/app/todo-list';
export class ToDoListComponent implements OnInit { export class ToDoListComponent implements OnInit {
@Input() todo!: ToDoList; @Input() todo!: ToDoList;
public beforeEditCache: string; public beforeEditCache: string;
//public todos: ToDoList[];
public todoTitle: string; public todoTitle: string;
public idTodo: number; public idTodo: number;
public filter: string; public filter: string;
@ -24,7 +23,6 @@ export class ToDoListComponent implements OnInit {
constructor(private TodoService: TodoService, private router: Router) { constructor(private TodoService: TodoService, private router: Router) {
this.beforeEditCache = ''; this.beforeEditCache = '';
//this.todos = [];
this.todoTitle = ''; this.todoTitle = '';
this.idTodo = 0; this.idTodo = 0;
this.filter = ''; this.filter = '';
@ -37,8 +35,10 @@ export class ToDoListComponent implements OnInit {
this.beforeEditCache = ''; this.beforeEditCache = '';
this.casesRestantes = true; this.casesRestantes = true;
this.filter = 'tous'; this.filter = 'tous';
this.idTodo = 4;
this.todoTitle = ''; this.todoTitle = '';
if (this.toDoRest()===0){
this.masterSelected=true;
}
} }
//supprimer la todoList en fonction de son id //supprimer la todoList en fonction de son id
deleteTodo(id: number): void { deleteTodo(id: number): void {
@ -81,7 +81,7 @@ export class ToDoListComponent implements OnInit {
tache.editing = true; 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 { doneEdit(tache: Tache): void {
if (tache.texte.trim().length === 0) { if (tache.texte.trim().length === 0) {
tache.texte = this.beforeEditCache; tache.texte = this.beforeEditCache;
@ -112,17 +112,21 @@ export class ToDoListComponent implements OnInit {
return this.todo.taches.filter((tache: Tache) => !tache.etat).length; 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 { listComplete(): boolean {
return this.todo.taches.filter((tache: Tache) => tache).length > 0; 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 { cocherAllTodoList(): void {
for (var i = 0; i < this.todo.taches.length; i++) { for (var i = 0; i < this.todo.taches.length; i++) {
this.todo.taches[i].etat = this.masterSelected; 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 { casesQuiRestes(): boolean {

View file

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

View file

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ToDoList } from 'src/app/models/to-do-list'; import { ToDoList } from 'src/app/models/to-do-list';
import { TodoService } from 'src/app/services/todo.service'; import { TodoService } from 'src/app/services/todo.service';
import { Team } from 'src/app/models/team';
@Component({ @Component({
selector: 'app-page-to-do-list', 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() { addTodoByTeamId() {
const todoList: ToDoList = { const todoList: ToDoList = {
nom: this.todoListTitle, nom: this.todoListTitle,