Merge pull request #80 from AlineRinquin/isa2
correction bug list et tache vides
This commit is contained in:
commit
80ebbf2ec6
@ -23,7 +23,6 @@ import { MeteoComponent } from './components/meteo/meteo.component';
|
||||
import { CalendrierComponent } from './components/calendrier/calendrier.component';
|
||||
import { CardMemberComponent } from './components/card-member/card-member.component';
|
||||
import { ToDoListComponent } from './components/to-do-list/to-do-list.component';
|
||||
import { TacheComponent } from './components/tache/tache.component';
|
||||
import { CardMenuComponent } from './components/card-menu/card-menu.component';
|
||||
import { FicheContactComponent } from './components/fiche-contact/fiche-contact.component';
|
||||
import { CreneauComponent } from './components/creneau/creneau.component';
|
||||
@ -68,7 +67,6 @@ registerLocaleData(localeFr)
|
||||
CalendrierComponent,
|
||||
CardMemberComponent,
|
||||
ToDoListComponent,
|
||||
TacheComponent,
|
||||
CardMenuComponent,
|
||||
FicheContactComponent,
|
||||
CreneauComponent,
|
||||
|
@ -1 +0,0 @@
|
||||
<p>tache works!</p>
|
@ -1,25 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TacheComponent } from './tache.component';
|
||||
|
||||
describe('TacheComponent', () => {
|
||||
let component: TacheComponent;
|
||||
let fixture: ComponentFixture<TacheComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ TacheComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TacheComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -1,15 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tache',
|
||||
templateUrl: './tache.component.html',
|
||||
styleUrls: ['./tache.component.scss']
|
||||
})
|
||||
export class TacheComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
@ -40,14 +40,15 @@ export class ToDoListComponent implements OnInit {
|
||||
this.idTodo = 4;
|
||||
this.todoTitle = '';
|
||||
}
|
||||
//supprimer la todoList
|
||||
//supprimer la todoList en fonction de son id
|
||||
deleteTodo(id: number): void {
|
||||
window.alert('La to-do-List a bien été supprimé!');
|
||||
this.TodoService.deleteTodoById(id).subscribe((resp) => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
//ajouter tache
|
||||
|
||||
//ajouter tache par l'id de son parent todoList
|
||||
addTache(idTodoList: number) {
|
||||
//idTodoList id que la todoList que l'on récupère
|
||||
console.log(idTodoList);
|
||||
@ -58,9 +59,13 @@ export class ToDoListComponent implements OnInit {
|
||||
editing: false,
|
||||
};
|
||||
console.log(this.tache);
|
||||
this.TodoService.addTache(tache, idTodoList).subscribe((resp) => {
|
||||
window.location.reload();
|
||||
});
|
||||
if (this.todoTitle != '') {
|
||||
this.TodoService.addTache(tache, idTodoList).subscribe((resp) => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
window.alert('Il faut saisir du texte'); // sinon msg d'erreur
|
||||
}
|
||||
}
|
||||
|
||||
//modifier le titre de la to-do-list
|
||||
@ -70,13 +75,13 @@ export class ToDoListComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
//modifier par l'input
|
||||
//modifier la tâche par l'input
|
||||
modifier(tache: Tache): void {
|
||||
this.beforeEditCache = tache.texte;
|
||||
tache.editing = true;
|
||||
}
|
||||
|
||||
// ajouter la modification dans la liste
|
||||
// modifier une tâche validation de l'input
|
||||
doneEdit(tache: Tache): void {
|
||||
if (tache.texte.trim().length === 0) {
|
||||
tache.texte = this.beforeEditCache;
|
||||
@ -112,12 +117,6 @@ export class ToDoListComponent implements OnInit {
|
||||
return this.todo.taches.filter((tache: Tache) => tache).length > 0;
|
||||
}
|
||||
|
||||
//Effacer la to do list
|
||||
|
||||
effacerList(): void {
|
||||
//this.todo = [];
|
||||
}
|
||||
|
||||
//cocher toutes les cases de la todoList
|
||||
cocherAllTodoList(): void {
|
||||
for (var i = 0; i < this.todo.taches.length; i++) {
|
||||
|
@ -25,3 +25,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-footer></app-footer>
|
||||
|
@ -21,6 +21,7 @@ export class PageToDoListComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
//récupère les todoLists existantes en fonctoin de l'id de la team en utilisant le service
|
||||
this.TodoService.getToDoListByTeamId()?.subscribe((listTodos: any) => {
|
||||
console.log(listTodos);
|
||||
this.listTodos = listTodos;
|
||||
@ -28,23 +29,21 @@ export class PageToDoListComponent implements OnInit {
|
||||
this.idTodo = 0;
|
||||
});
|
||||
}
|
||||
//Ajouter une todo List
|
||||
|
||||
//Ajouter une todo List si l'input n'est pas vide
|
||||
addTodoByTeamId() {
|
||||
const todoList: ToDoList = {
|
||||
nom: this.todoListTitle,
|
||||
taches: [],
|
||||
id: 0,
|
||||
};
|
||||
this.TodoService.addTodoByTeamId(todoList)?.subscribe((resp) => {
|
||||
console.log(todoList);
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
deleteTodo(id: number): void {
|
||||
window.alert('La to-do-List a bien été supprimé!');
|
||||
this.TodoService.deleteTodoById(id).subscribe((resp) => {
|
||||
window.location.reload();
|
||||
});
|
||||
if (this.todoListTitle != '') {
|
||||
this.TodoService.addTodoByTeamId(todoList)?.subscribe((resp) => {
|
||||
console.log(todoList);
|
||||
window.location.reload(); //rafraîchit l'aperçu
|
||||
});
|
||||
}else{
|
||||
window.alert('Il faut saisir du texte'); // sinon msg d'erreur
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,37 +18,46 @@ export class TodoService {
|
||||
this.apiUrl = environment.apiUrl;
|
||||
}
|
||||
|
||||
//recupère les todolistexistantes en BDD par le tokenService en fonction de l'iD de la team
|
||||
getToDoListByTeamId(): Observable<any> | void {
|
||||
const teamId = this.tokenService.getCurrentTeamId();
|
||||
return this.http.get(`${this.apiUrl}/todolist/team/${teamId}`);
|
||||
}
|
||||
|
||||
//supprime les taches par l'id dela tache dans la todoList
|
||||
deleteTacheById(idTache: any): Observable<any> {
|
||||
return this.http.delete(`${this.apiUrl}/taches/delete/${idTache}`, {
|
||||
responseType: 'text',
|
||||
});
|
||||
}
|
||||
|
||||
//ajoute une tache avec auto-incrémentation de l'id dans la todolist
|
||||
addTache(newtache: Tache, idTodoList: number): Observable<any> {
|
||||
// console.log(newtache);
|
||||
return this.http.post(`${this.apiUrl}/taches/add/${idTodoList}`, newtache);
|
||||
}
|
||||
|
||||
// modifie une tâche par son id
|
||||
updateTache(tache: Tache): Observable<any> {
|
||||
console.log(tache);
|
||||
// console.log(tache);
|
||||
return this.http.put(`${this.apiUrl}/taches/update/1`, tache);
|
||||
}
|
||||
|
||||
//ajoute ne todoList sur une team (par son id) via le token
|
||||
addTodoByTeamId(newtodoList: TodoList): Observable<any> {
|
||||
const teamId = this.tokenService.getCurrentTeamId();
|
||||
console.log(newtodoList + 'newtodoList');
|
||||
return this.http.post(`${this.apiUrl}/todolist/add/${teamId}`, newtodoList);
|
||||
}
|
||||
|
||||
//suprime une todoList en fonction de son id
|
||||
deleteTodoById(idTodo: any): Observable<any> {
|
||||
return this.http.delete(`${this.apiUrl}/todolist/delete/${idTodo}`, {
|
||||
responseType: 'text',
|
||||
});
|
||||
}
|
||||
|
||||
//modfie une todoList par son id
|
||||
updateTodo(todoList: TodoList): Observable<any> {
|
||||
console.log(todoList);
|
||||
return this.http.put(`${this.apiUrl}/todolist/update/666`, todoList);
|
||||
|
Loading…
Reference in New Issue
Block a user