Add tache ok
This commit is contained in:
parent
efb86420d0
commit
507edc6151
6
package-lock.json
generated
6
package-lock.json
generated
@ -2645,9 +2645,9 @@
|
|||||||
"integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q=="
|
"integrity": "sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q=="
|
||||||
},
|
},
|
||||||
"bootstrap-icons": {
|
"bootstrap-icons": {
|
||||||
"version": "1.7.2",
|
"version": "1.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.8.1.tgz",
|
||||||
"integrity": "sha512-NiR2PqC73AQOPdVSu6GJfnk+hN2z6powcistXk1JgPnKuoV2FSdSl26w931Oz9HYbKCcKUSB6ncZTYJAYJl3QQ=="
|
"integrity": "sha512-IXUqislddPJfwq6H+2nTkHyr9epO9h6u1AG0OZCx616w+TgzeoCjfmI3qJMQqt1J586gN2IxzB4M99Ip4sTZ1w=="
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"@angular/platform-browser-dynamic": "~13.0.0",
|
"@angular/platform-browser-dynamic": "~13.0.0",
|
||||||
"@angular/router": "~13.0.0",
|
"@angular/router": "~13.0.0",
|
||||||
"bootstrap": "^5.1.3",
|
"bootstrap": "^5.1.3",
|
||||||
"bootstrap-icons": "^1.7.2",
|
"bootstrap-icons": "^1.8.1",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"ngx-autofocus-fix": "^1.0.4",
|
"ngx-autofocus-fix": "^1.0.4",
|
||||||
"rxjs": "~7.4.0",
|
"rxjs": "~7.4.0",
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
class="todo-input"
|
class="todo-input"
|
||||||
placeholder="+ Nouvelle Tâche"
|
placeholder="+ Nouvelle Tâche"
|
||||||
[(ngModel)]="todoTitle"
|
[(ngModel)]="todoTitle"
|
||||||
(keyup.enter)="addTache()"
|
(keyup.enter)="addTache(todo.id)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{{todo}}
|
||||||
|
|
||||||
<div class="element" *ngFor="let tache of todo.taches">
|
<div class="element" *ngFor="let tache of todo.taches">
|
||||||
<div class="element-gauche">
|
<div class="element-gauche">
|
||||||
@ -63,7 +63,7 @@
|
|||||||
<div>{{ toDoRest() }} tâches</div>
|
<div>{{ toDoRest() }} tâches</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="extra-container">
|
<div class="extra-container">
|
||||||
<div>
|
<!-- <div>
|
||||||
<button [ngClass]="{ active: filter === 'tous' }" (click)="filter = 'tous'">
|
<button [ngClass]="{ active: filter === 'tous' }" (click)="filter = 'tous'">
|
||||||
Toutes la To Do List
|
Toutes la To Do List
|
||||||
</button>
|
</button>
|
||||||
@ -80,6 +80,6 @@
|
|||||||
Terminées
|
Terminées
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Todo } from 'src/app/interfaces/todo';
|
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 { 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',
|
||||||
@ -9,25 +11,26 @@ import { TodoService } from 'src/app/services/todo.service';
|
|||||||
styleUrls: ['./to-do-list.component.scss'],
|
styleUrls: ['./to-do-list.component.scss'],
|
||||||
})
|
})
|
||||||
export class ToDoListComponent implements OnInit {
|
export class ToDoListComponent implements OnInit {
|
||||||
@Input() todo : any;
|
@Input() todo!: ToDoList;
|
||||||
public beforeEditCache: string;
|
public beforeEditCache: string;
|
||||||
public todos: Todo[];
|
//public todos: ToDoList[];
|
||||||
public todoTitle: string;
|
public todoTitle: string;
|
||||||
public idTodo: number;
|
public idTodo: number;
|
||||||
public filter : string;
|
public filter : string;
|
||||||
public casesRestantes : boolean;
|
public casesRestantes : boolean;
|
||||||
public masterSelected: boolean;
|
public masterSelected: boolean;
|
||||||
public result : any;
|
public result : any;
|
||||||
|
public tache : Tache [];
|
||||||
|
|
||||||
constructor(private TodoService : TodoService, private router: Router ) {
|
constructor(private TodoService : TodoService, private router: Router ) {
|
||||||
this.beforeEditCache = '';
|
this.beforeEditCache = '';
|
||||||
this.todos = [];
|
//this.todos = [];
|
||||||
this.todoTitle = '';
|
this.todoTitle = '';
|
||||||
this.idTodo = 0;
|
this.idTodo = 0;
|
||||||
this.filter ='';
|
this.filter ='';
|
||||||
this.casesRestantes=true;
|
this.casesRestantes=true;
|
||||||
this.masterSelected= false;
|
this.masterSelected= false;
|
||||||
|
this.tache = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -37,31 +40,41 @@ export class ToDoListComponent implements OnInit {
|
|||||||
this.filter='tous';
|
this.filter='tous';
|
||||||
this.idTodo = 4;
|
this.idTodo = 4;
|
||||||
this.todoTitle = '';
|
this.todoTitle = '';
|
||||||
this.todos = [
|
/* this.todos = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'Finish Angular Screencast',
|
texte: 'Finish Angular Screencast',
|
||||||
completed: false,
|
etat: false,
|
||||||
editing: false,
|
editing: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
title: 'Take over world',
|
texte: 'Take over world',
|
||||||
completed: false,
|
etat: false,
|
||||||
editing: false,
|
editing: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
title: 'One more thing',
|
texte: 'One more thing',
|
||||||
completed: false,
|
etat: false,
|
||||||
editing: false,
|
editing: false,
|
||||||
},
|
},
|
||||||
];
|
]; */
|
||||||
}
|
}
|
||||||
//ajouter tache
|
//ajouter tache
|
||||||
addTache(): void {
|
|
||||||
this.TodoService.addTache(todo).subscribe((resp)=>{
|
addTache(idTodoList : number) {//idTodoList id que la todoList que l'on récupère
|
||||||
this.router.navigate(['to-do-list'])
|
console.log(idTodoList);
|
||||||
|
const tache: Tache = {
|
||||||
|
id : 0,
|
||||||
|
texte: this.todoTitle,
|
||||||
|
etat : false,
|
||||||
|
editing : false,
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log(this.tache);
|
||||||
|
this.TodoService.addTache(tache,idTodoList).subscribe((resp)=>{
|
||||||
|
window.location.reload();
|
||||||
})
|
})
|
||||||
/* if (this.todoTitle.trim().length === 0) {
|
/* if (this.todoTitle.trim().length === 0) {
|
||||||
return;
|
return;
|
||||||
@ -83,24 +96,24 @@ export class ToDoListComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
//modifier la tâche
|
//modifier la tâche
|
||||||
modifier(todo: Todo): void {
|
modifier(tache: Tache): void {
|
||||||
this.beforeEditCache = todo.title;
|
this.beforeEditCache = tache.texte;
|
||||||
todo.editing = true;
|
tache.editing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// modifier l'apparence focus
|
// modifier l'apparence focus
|
||||||
doneEdit(todo: Todo): void {
|
doneEdit(tache: Tache): void {
|
||||||
if (todo.title.trim().length === 0) {
|
if (tache.texte.trim().length === 0) {
|
||||||
todo.title = this.beforeEditCache;
|
tache.texte = this.beforeEditCache;
|
||||||
}
|
}
|
||||||
this.casesRestantes= this.casesQuiRestes();
|
this.casesRestantes= this.casesQuiRestes();
|
||||||
todo.editing = false;
|
tache.editing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// annuler la modification
|
// annuler la modification
|
||||||
cancelEdit(todo: Todo): void {
|
cancelEdit(tache: Tache): void {
|
||||||
todo.title = this.beforeEditCache;
|
tache.texte = this.beforeEditCache;
|
||||||
todo.editing = false;
|
tache.editing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//supprimer la tache
|
//supprimer la tache
|
||||||
@ -115,24 +128,24 @@ export class ToDoListComponent implements OnInit {
|
|||||||
|
|
||||||
//nombre de tâches restantes
|
//nombre de tâches restantes
|
||||||
toDoRest(): number{
|
toDoRest(): number{
|
||||||
return this.todos.filter(todo=> !todo.completed).length;
|
return this.todo.taches.filter((tache: Tache)=> !tache.etat).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Cocher toutes les tâches de la liste
|
//Cocher toutes les tâches de la liste
|
||||||
listComplete(): boolean {
|
listComplete(): boolean {
|
||||||
return this.todos.filter(todo=> todo.completed).length>0;
|
return this.todo.taches.filter((tache: Tache)=> tache).length>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Effacer la to do list
|
//Effacer la to do list
|
||||||
|
|
||||||
effacerList(): void {
|
effacerList(): void {
|
||||||
this.todos = [];
|
//this.todo = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
//cocher toutes les cases de la todoList
|
//cocher toutes les cases de la todoList
|
||||||
cocherAllTodoList(): void {
|
cocherAllTodoList(): void {
|
||||||
for (var i = 0; i < this.todos.length; i++) {
|
for (var i = 0; i < this.todo.taches.length; i++) {
|
||||||
this.todos[i].completed = this.masterSelected;
|
this.todo.taches[i].etat = this.masterSelected;
|
||||||
}
|
}
|
||||||
this.cocherAllTodoList();
|
this.cocherAllTodoList();
|
||||||
}
|
}
|
||||||
@ -142,16 +155,16 @@ export class ToDoListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//barre de filtre des tâches
|
//barre de filtre des tâches
|
||||||
todosFilter(): Todo[] {
|
/* todosFilter(): ToDoList[] {
|
||||||
if(this.filter === 'tous'){
|
if(this.filter === 'tous'){
|
||||||
return this.todos
|
return this.todo.taches
|
||||||
}else if (this.filter === 'active'){
|
}else if (this.filter === 'active'){
|
||||||
return this.todos.filter(todo=> !todo.completed)
|
return this.todo.taches.filter((tache: Tache)=> !tache.etat)
|
||||||
}else if (this.filter === 'complete'){
|
}else if (this.filter === 'complete'){
|
||||||
return this.todos.filter(todo=>todo.completed)
|
return this.todo.taches.filter((tache: Tache)=>tache.etat)
|
||||||
}
|
|
||||||
return this.todos
|
|
||||||
}
|
}
|
||||||
|
return this.todo
|
||||||
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export interface Todo {
|
export interface Todo {
|
||||||
id : number,
|
id : number,
|
||||||
title : string,
|
texte : string,
|
||||||
completed: boolean,
|
etat: boolean,
|
||||||
editing: boolean
|
// todoListId: number // FK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/app/models/tache.ts
Normal file
10
src/app/models/tache.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
import { ToDoList } from './to-do-list';
|
||||||
|
|
||||||
|
|
||||||
|
export interface Tache {
|
||||||
|
id : number,
|
||||||
|
texte: string,
|
||||||
|
etat : boolean,
|
||||||
|
editing : boolean
|
||||||
|
}
|
@ -1,7 +1,11 @@
|
|||||||
|
import { Tache } from './tache';
|
||||||
import { Team } from './team';
|
import { Team } from './team';
|
||||||
|
|
||||||
export interface ToDoList {
|
export interface ToDoList {
|
||||||
nom: string;
|
nom: string;
|
||||||
team: Team;
|
team: Team;
|
||||||
tache: string;
|
taches: Tache [];
|
||||||
|
id:number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@ import { HttpClient } from '@angular/common/http';
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import { Todo } from '../interfaces/todo';
|
import { Tache } from '../models/tache';
|
||||||
|
import { ToDoList } from '../models/to-do-list';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@ -23,8 +24,8 @@ export class TodoService {
|
|||||||
return this.http.delete(`${this.apiUrl}/taches/delete/${idTache}`,{responseType:'text'});
|
return this.http.delete(`${this.apiUrl}/taches/delete/${idTache}`,{responseType:'text'});
|
||||||
}
|
}
|
||||||
|
|
||||||
addTache(todo:Todo): Observable<any> {
|
addTache(newtache: Tache,idTodoList:number): Observable<any> {
|
||||||
console.log(todo);
|
console.log(newtache);
|
||||||
return this.http.post(`${this.apiUrl}/taches/add`, todo);
|
return this.http.post(`${this.apiUrl}/taches/add/${idTodoList}`, newtache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
src/app/todo-list.ts
Normal file
2
src/app/todo-list.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export interface TodoList {
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user