diff --git a/frontend/src/api/api/task.service.ts b/frontend/src/api/api/task.service.ts index c15e918..6299a9a 100644 --- a/frontend/src/api/api/task.service.ts +++ b/frontend/src/api/api/task.service.ts @@ -401,6 +401,63 @@ export class TaskService { ); } + /** + * @param taskID internal id of task + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public tasksTaskIDSubtasksDelete(taskID: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable; + public tasksTaskIDSubtasksDelete(taskID: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public tasksTaskIDSubtasksDelete(taskID: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable>; + public tasksTaskIDSubtasksDelete(taskID: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable { + if (taskID === null || taskID === undefined) { + throw new Error('Required parameter taskID was null or undefined when calling tasksTaskIDSubtasksDelete.'); + } + + let localVarHeaders = this.defaultHeaders; + + let localVarCredential: string | undefined; + // authentication (API_TOKEN) required + localVarCredential = this.configuration.lookupCredential('API_TOKEN'); + if (localVarCredential) { + localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); + } + + let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; + if (localVarHttpHeaderAcceptSelected === undefined) { + // to determine the Accept header + const httpHeaderAccepts: string[] = [ + 'application/json' + ]; + localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); + } + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); + } + + let localVarHttpContext: HttpContext | undefined = options && options.context; + if (localVarHttpContext === undefined) { + localVarHttpContext = new HttpContext(); + } + + + let responseType_: 'text' | 'json' = 'json'; + if(localVarHttpHeaderAcceptSelected && localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } + + return this.httpClient.delete(`${this.configuration.basePath}/tasks/${encodeURIComponent(String(taskID))}/subtasks`, + { + context: localVarHttpContext, + responseType: responseType_, + withCredentials: this.configuration.withCredentials, + headers: localVarHeaders, + observe: observe, + reportProgress: reportProgress + } + ); + } + /** * @param taskID internal id of task * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. diff --git a/frontend/src/app/tasks/clear-task-dialog/clear-task-dialog.component.ts b/frontend/src/app/tasks/clear-task-dialog/clear-task-dialog.component.ts index 86c8af5..400dd26 100644 --- a/frontend/src/app/tasks/clear-task-dialog/clear-task-dialog.component.ts +++ b/frontend/src/app/tasks/clear-task-dialog/clear-task-dialog.component.ts @@ -1,12 +1,14 @@ import {Component, Inject, OnInit} from '@angular/core'; import {TaskEditorData} from "../task-editor/TaskEditorData"; -import {TaskEntityInfo, TaskgroupService} from "../../../api"; +import {TaskEntityInfo, TaskgroupService, TaskService} from "../../../api"; import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; import {MatSnackBar} from "@angular/material/snack-bar"; export interface ClearTaskDialogData { - taskgroupID: number, - tasks: TaskEntityInfo[] + taskgroupID: number | undefined, + parentTaskID: number | undefined + tasks: TaskEntityInfo[], + subtasks: boolean } @Component({ selector: 'app-clear-task-dialog', @@ -23,7 +25,8 @@ export class ClearTaskDialogComponent implements OnInit{ constructor(@Inject(MAT_DIALOG_DATA) public editorData: ClearTaskDialogData, private taskgroupService: TaskgroupService, private dialogRef: MatDialogRef, - private snackbar: MatSnackBar) { + private snackbar: MatSnackBar, + private taskService: TaskService) { } ngOnInit(): void { @@ -48,22 +51,43 @@ export class ClearTaskDialogComponent implements OnInit{ } clearTasks() { - this.taskgroupService.taskgroupsTaskgroupIDClearDelete(this.editorData.taskgroupID).subscribe({ - next: resp => { - if(resp.status == "success") { - const deletedTasks = this.editorData.tasks; - this.dialogRef.close(deletedTasks); + if(this.editorData.subtasks) { + this.taskService.tasksTaskIDSubtasksDelete(this.editorData.parentTaskID!).subscribe({ + next: resp => { + if(resp.status == "success") { + const deletedTasks = this.editorData.tasks; + this.dialogRef.close(deletedTasks); + } + }, + error: err => { + if(err.status == 403) { + this.snackbar.open("No permission", "", {duration: 2000}); + } else if(err.status == 404) { + this.snackbar.open("Not found", "", {duration: 2000}); + } else { + this.snackbar.open("Unexpected error", "", {duration: 2000}); + } } - }, - error: err => { - if(err.status == 403) { - this.snackbar.open("No permission", "", {duration: 2000}); - } else if(err.status == 404) { - this.snackbar.open("Not found", "", {duration: 2000}); - } else { - this.snackbar.open("Unexpected error", "", {duration: 2000}); + }) + } else { + this.taskgroupService.taskgroupsTaskgroupIDClearDelete(this.editorData.taskgroupID!).subscribe({ + next: resp => { + if(resp.status == "success") { + const deletedTasks = this.editorData.tasks; + this.dialogRef.close(deletedTasks); + } + }, + error: err => { + if(err.status == 403) { + this.snackbar.open("No permission", "", {duration: 2000}); + } else if(err.status == 404) { + this.snackbar.open("Not found", "", {duration: 2000}); + } else { + this.snackbar.open("Unexpected error", "", {duration: 2000}); + } } - } - }) + }) + } + } } diff --git a/frontend/src/app/tasks/task-dashboard/task-dashboard.component.ts b/frontend/src/app/tasks/task-dashboard/task-dashboard.component.ts index a961599..18277d3 100644 --- a/frontend/src/app/tasks/task-dashboard/task-dashboard.component.ts +++ b/frontend/src/app/tasks/task-dashboard/task-dashboard.component.ts @@ -20,7 +20,7 @@ import {TaskWeeklySeriesCreatorComponent} from "../task-weekly-series-creator/ta }) export class TaskDashboardComponent implements OnChanges{ ngOnChanges(): void { - if(this.taskgroupID != undefined) { + if(this.subTasks.length == 0 && this.taskgroupID != undefined) { this.fetchTasks() } else if(this.subTasks.length > 0) { this.datasource.data = this.subTasks; @@ -33,6 +33,7 @@ export class TaskDashboardComponent implements OnChanges{ @Input("taskgroupID") taskgroupID: number | undefined @Input("subTasks") subTasks: TaskEntityInfo[] = [] + @Input("parentTaskID") parentTaskID: number | undefined @ViewChild(MatPaginator) paginator: MatPaginator | undefined @ViewChild(MatSort) sort: MatSort | undefined @@ -111,9 +112,11 @@ export class TaskDashboardComponent implements OnChanges{ } clearTasks() { - const clearTaskData: ClearTaskDialogData = { + let clearTaskData: ClearTaskDialogData = { tasks: this.datasource.data, - taskgroupID: this.taskgroupID! + taskgroupID: this.taskgroupID, + parentTaskID: this.parentTaskID, + subtasks: this.subTasks.length > 0 } const dialogRef = this.dialog.open(ClearTaskDialogComponent, {data: clearTaskData, width: "600px"}); dialogRef.afterClosed().subscribe(res => { diff --git a/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.html b/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.html index c530aad..6ab6c82 100644 --- a/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.html +++ b/frontend/src/app/tasks/task-detail-overview/task-detail-overview.component.html @@ -44,8 +44,8 @@ Subtasks -
- +
+