Clear subtasks in UI
All checks were successful
Java CI with Maven / build-and-push-frontend (push) Successful in 8s
Java CI with Maven / build-and-push-backend (push) Successful in 7s

This commit is contained in:
Sebastian Böckelmann 2024-03-17 09:16:37 +01:00
parent 4059500fa4
commit 0a60b8b27e
4 changed files with 108 additions and 24 deletions

View File

@ -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<SimpleStatusResponse>;
public tasksTaskIDSubtasksDelete(taskID: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpResponse<SimpleStatusResponse>>;
public tasksTaskIDSubtasksDelete(taskID: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<HttpEvent<SimpleStatusResponse>>;
public tasksTaskIDSubtasksDelete(taskID: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext}): Observable<any> {
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<SimpleStatusResponse>(`${this.configuration.basePath}/tasks/${encodeURIComponent(String(taskID))}/subtasks`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: localVarHeaders,
observe: observe,
reportProgress: reportProgress
}
);
}
/** /**
* @param taskID internal id of task * @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 observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.

View File

@ -1,12 +1,14 @@
import {Component, Inject, OnInit} from '@angular/core'; import {Component, Inject, OnInit} from '@angular/core';
import {TaskEditorData} from "../task-editor/TaskEditorData"; 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 {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {MatSnackBar} from "@angular/material/snack-bar"; import {MatSnackBar} from "@angular/material/snack-bar";
export interface ClearTaskDialogData { export interface ClearTaskDialogData {
taskgroupID: number, taskgroupID: number | undefined,
tasks: TaskEntityInfo[] parentTaskID: number | undefined
tasks: TaskEntityInfo[],
subtasks: boolean
} }
@Component({ @Component({
selector: 'app-clear-task-dialog', selector: 'app-clear-task-dialog',
@ -23,7 +25,8 @@ export class ClearTaskDialogComponent implements OnInit{
constructor(@Inject(MAT_DIALOG_DATA) public editorData: ClearTaskDialogData, constructor(@Inject(MAT_DIALOG_DATA) public editorData: ClearTaskDialogData,
private taskgroupService: TaskgroupService, private taskgroupService: TaskgroupService,
private dialogRef: MatDialogRef<ClearTaskDialogComponent>, private dialogRef: MatDialogRef<ClearTaskDialogComponent>,
private snackbar: MatSnackBar) { private snackbar: MatSnackBar,
private taskService: TaskService) {
} }
ngOnInit(): void { ngOnInit(): void {
@ -48,22 +51,43 @@ export class ClearTaskDialogComponent implements OnInit{
} }
clearTasks() { clearTasks() {
this.taskgroupService.taskgroupsTaskgroupIDClearDelete(this.editorData.taskgroupID).subscribe({ if(this.editorData.subtasks) {
next: resp => { this.taskService.tasksTaskIDSubtasksDelete(this.editorData.parentTaskID!).subscribe({
if(resp.status == "success") { next: resp => {
const deletedTasks = this.editorData.tasks; if(resp.status == "success") {
this.dialogRef.close(deletedTasks); 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 => { } else {
if(err.status == 403) { this.taskgroupService.taskgroupsTaskgroupIDClearDelete(this.editorData.taskgroupID!).subscribe({
this.snackbar.open("No permission", "", {duration: 2000}); next: resp => {
} else if(err.status == 404) { if(resp.status == "success") {
this.snackbar.open("Not found", "", {duration: 2000}); const deletedTasks = this.editorData.tasks;
} else { this.dialogRef.close(deletedTasks);
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});
}
} }
} })
}) }
} }
} }

View File

@ -20,7 +20,7 @@ import {TaskWeeklySeriesCreatorComponent} from "../task-weekly-series-creator/ta
}) })
export class TaskDashboardComponent implements OnChanges{ export class TaskDashboardComponent implements OnChanges{
ngOnChanges(): void { ngOnChanges(): void {
if(this.taskgroupID != undefined) { if(this.subTasks.length == 0 && this.taskgroupID != undefined) {
this.fetchTasks() this.fetchTasks()
} else if(this.subTasks.length > 0) { } else if(this.subTasks.length > 0) {
this.datasource.data = this.subTasks; this.datasource.data = this.subTasks;
@ -33,6 +33,7 @@ export class TaskDashboardComponent implements OnChanges{
@Input("taskgroupID") taskgroupID: number | undefined @Input("taskgroupID") taskgroupID: number | undefined
@Input("subTasks") subTasks: TaskEntityInfo[] = [] @Input("subTasks") subTasks: TaskEntityInfo[] = []
@Input("parentTaskID") parentTaskID: number | undefined
@ViewChild(MatPaginator) paginator: MatPaginator | undefined @ViewChild(MatPaginator) paginator: MatPaginator | undefined
@ViewChild(MatSort) sort: MatSort | undefined @ViewChild(MatSort) sort: MatSort | undefined
@ -111,9 +112,11 @@ export class TaskDashboardComponent implements OnChanges{
} }
clearTasks() { clearTasks() {
const clearTaskData: ClearTaskDialogData = { let clearTaskData: ClearTaskDialogData = {
tasks: this.datasource.data, 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"}); const dialogRef = this.dialog.open(ClearTaskDialogComponent, {data: clearTaskData, width: "600px"});
dialogRef.afterClosed().subscribe(res => { dialogRef.afterClosed().subscribe(res => {

View File

@ -44,8 +44,8 @@
<mat-expansion-panel *ngIf="subTasks.length > 0" style="margin-top: 20px" expanded> <mat-expansion-panel *ngIf="subTasks.length > 0" style="margin-top: 20px" expanded>
<mat-expansion-panel-header>Subtasks</mat-expansion-panel-header> <mat-expansion-panel-header>Subtasks</mat-expansion-panel-header>
<div> <div *ngIf="task != undefined">
<app-task-dashboard [subTasks]="subTasks"></app-task-dashboard> <app-task-dashboard [subTasks]="subTasks" [taskgroupID]="taskgroupID" [parentTaskID]="task!.taskID"></app-task-dashboard>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>