issue-106 #107

Merged
sebastian merged 18 commits from issue-106 into master 2024-03-17 09:17:11 +01:00
4 changed files with 108 additions and 24 deletions
Showing only changes of commit 0a60b8b27e - Show all commits

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 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 {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<ClearTaskDialogComponent>,
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});
}
}
}
})
})
}
}
}

View File

@ -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 => {

View File

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