feat: suppression d'un projet
This commit is contained in:
@@ -8,9 +8,10 @@ import { ProjectService } from '../../../services/project.service';
|
||||
import { Project } from '../../../model/Project';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Observable } from 'rxjs';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
@Component({
|
||||
imports: [RouterOutlet, ReactiveFormsModule],
|
||||
imports: [RouterOutlet, ReactiveFormsModule, MatIconModule],
|
||||
selector: 'app-root',
|
||||
styleUrl: './home.component.css',
|
||||
templateUrl: './home.component.html',
|
||||
@@ -85,10 +86,12 @@ export class Home {
|
||||
* submitTask
|
||||
*/
|
||||
public submitTask(): void {
|
||||
let response: Observable<Task> = this.taskService.addTask(this.newTaskForm.controls.name.value!,
|
||||
let response: Observable<Task> = this.taskService.addTask(
|
||||
this.newTaskForm.controls.name.value!,
|
||||
this.newTaskForm.controls.dueDate.value,
|
||||
this.newTaskForm.controls.priority.value,
|
||||
this.newTaskForm.controls.status.value);
|
||||
this.newTaskForm.controls.status.value
|
||||
);
|
||||
|
||||
response.subscribe({
|
||||
next: (response) => {
|
||||
@@ -128,7 +131,9 @@ export class Home {
|
||||
* submitGroup
|
||||
*/
|
||||
public submitGroup() {
|
||||
let response: Observable<Group> = this.groupService.addGroup(this.newGroupForm.controls.name.value!);
|
||||
let response: Observable<Group> = this.groupService.addGroup(
|
||||
this.newGroupForm.controls.name.value!
|
||||
);
|
||||
|
||||
response.subscribe({
|
||||
next: (response) => {
|
||||
@@ -145,8 +150,8 @@ export class Home {
|
||||
/**
|
||||
* deleteGroup
|
||||
*/
|
||||
public deleteGroup(id_group:number) {
|
||||
let response:Observable<void> = this.groupService.deleteGroup(id_group);
|
||||
public deleteGroup(id_group: number) {
|
||||
let response: Observable<void> = this.groupService.deleteGroup(id_group);
|
||||
|
||||
response.subscribe({
|
||||
next: () => {
|
||||
@@ -168,7 +173,9 @@ export class Home {
|
||||
* submitProject
|
||||
*/
|
||||
public submitProject() {
|
||||
let response: Observable<Project> = this.projectService.addProject(this.newProjectForm.controls.name.value!);
|
||||
let response: Observable<Project> = this.projectService.addProject(
|
||||
this.newProjectForm.controls.name.value!
|
||||
);
|
||||
|
||||
response.subscribe({
|
||||
next: (response) => {
|
||||
@@ -181,4 +188,22 @@ export class Home {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* deleteProject
|
||||
*/
|
||||
public deleteProject(id_project: number) {
|
||||
let response: Observable<void> = this.projectService.deleteProject(id_project);
|
||||
|
||||
response.subscribe({
|
||||
next: () => {
|
||||
this.projects.update((projects) => {
|
||||
return projects.filter((project) => project.id_project != id_project);
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(`Suppression du projet impossible\nErreur:${error.error.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user