Compare commits
2 Commits
a03322b52d
...
d3040c0268
| Author | SHA1 | Date | |
|---|---|---|---|
| d3040c0268 | |||
| ad85a96c33 |
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
export interface Group{
|
export interface Group{
|
||||||
id_group: number;
|
id_group: number;
|
||||||
id_project: number;
|
id_project?: number;
|
||||||
name_group: string;
|
name_group: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,13 @@ export class GroupService extends BaseService {
|
|||||||
public getGroups(): Observable<Group[]> {
|
public getGroups(): Observable<Group[]> {
|
||||||
return this.get<Group[]>("group");
|
return this.get<Group[]>("group");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public addGroup(name:string):Observable<Group>{
|
||||||
|
let body:Group = {
|
||||||
|
id_group:0,
|
||||||
|
name_group:name,
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.post<Group>("group/add",body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,13 @@ export class ProjectService extends BaseService {
|
|||||||
public getProjects(): Observable<Project[]> {
|
public getProjects(): Observable<Project[]> {
|
||||||
return this.get<Project[]>("project");
|
return this.get<Project[]>("project");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public addProject(name: string): Observable<Project> {
|
||||||
|
let body: Project = {
|
||||||
|
name_project: name,
|
||||||
|
id_project: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.post<Project>("project/add", body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
<button (click)="toggleForm()">
|
<button (click)="toggleTaskForm()">
|
||||||
Ajouter une tâche
|
Ajouter une tâche
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
@@ -44,6 +44,18 @@
|
|||||||
{{ group.name_group }}
|
{{ group.name_group }}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<button (click)="toggleGroupForm()">Ajouter un groupe</button>
|
||||||
|
|
||||||
|
|
||||||
|
@if (showGroupForm){
|
||||||
|
<form [formGroup]="newGroupForm" (ngSubmit)="submitGroup()">
|
||||||
|
<label for="name-group">Nom </label>
|
||||||
|
<input id="name-group" type="text" formControlName="name" />
|
||||||
|
|
||||||
|
<button type="submit" [disabled]="!newGroupForm.valid">Valider</button>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
@@ -55,6 +67,17 @@
|
|||||||
{{ project.name_project }}
|
{{ project.name_project }}
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<button (click)="toggleProjectForm()">Ajouter un projet</button>
|
||||||
|
|
||||||
|
@if (showProjectForm){
|
||||||
|
<form [formGroup]="newProjectForm" (ngSubmit)="submitProject()">
|
||||||
|
<label for="name-project">Nom </label>
|
||||||
|
<input id="name-project" type="text" formControlName="name" />
|
||||||
|
|
||||||
|
<button type="submit" [disabled]="!newProjectForm.valid">Valider</button>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<router-outlet />
|
<router-outlet />
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { Observable } from 'rxjs';
|
|||||||
templateUrl: './home.component.html',
|
templateUrl: './home.component.html',
|
||||||
})
|
})
|
||||||
export class Home {
|
export class Home {
|
||||||
|
//#region Attributs
|
||||||
private taskService: TaskService = inject(TaskService);
|
private taskService: TaskService = inject(TaskService);
|
||||||
private groupService: GroupService = inject(GroupService);
|
private groupService: GroupService = inject(GroupService);
|
||||||
private projectService: ProjectService = inject(ProjectService);
|
private projectService: ProjectService = inject(ProjectService);
|
||||||
@@ -33,6 +34,20 @@ export class Home {
|
|||||||
|
|
||||||
showTaskForm: boolean = false;
|
showTaskForm: boolean = false;
|
||||||
|
|
||||||
|
newGroupForm = new FormGroup({
|
||||||
|
name: new FormControl('', Validators.required),
|
||||||
|
});
|
||||||
|
|
||||||
|
showGroupForm: boolean = false;
|
||||||
|
|
||||||
|
newProjectForm = new FormGroup({
|
||||||
|
name: new FormControl('', Validators.required),
|
||||||
|
});
|
||||||
|
|
||||||
|
showProjectForm: boolean = false;
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
this.taskService.getTasks().subscribe((response: Task[]): void => {
|
this.taskService.getTasks().subscribe((response: Task[]): void => {
|
||||||
this.tasks.set(response);
|
this.tasks.set(response);
|
||||||
@@ -47,7 +62,7 @@ export class Home {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public toggleForm(): void {
|
public toggleTaskForm(): void {
|
||||||
this.showTaskForm = !this.showTaskForm;
|
this.showTaskForm = !this.showTaskForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,4 +81,38 @@ export class Home {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public toggleGroupForm(): void {
|
||||||
|
this.showGroupForm = !this.showGroupForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* submitGroup
|
||||||
|
*/
|
||||||
|
public submitGroup() {
|
||||||
|
let response: Observable<Group> = this.groupService.addGroup(this.newGroupForm.controls.name.value!);
|
||||||
|
|
||||||
|
response.subscribe(response => {
|
||||||
|
this.groups.update(values => {
|
||||||
|
return [...values, response];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toggleProjectForm(): void {
|
||||||
|
this.showProjectForm = !this.showProjectForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* submitProject
|
||||||
|
*/
|
||||||
|
public submitProject() {
|
||||||
|
let response: Observable<Project> = this.projectService.addProject(this.newProjectForm.controls.name.value!);
|
||||||
|
|
||||||
|
response.subscribe(response => {
|
||||||
|
this.projects.update(values => {
|
||||||
|
return [...values, response];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user