Add tasks from TaskOverview

This commit is contained in:
Sebastian 2023-10-28 19:09:07 +02:00
parent 217e48aead
commit 98efb9150c
2 changed files with 26 additions and 2 deletions

View File

@ -1,4 +1,4 @@
<button mat-raised-button class="greenBtn long-btn" *ngIf="tasks.length > 0">Add</button> <button mat-raised-button class="greenBtn long-btn" *ngIf="tasks.length > 0" (click)="openTaskCreation()">Add</button>
<mat-card *ngFor="let task of tasks"> <mat-card *ngFor="let task of tasks">
<mat-card-content> <mat-card-content>
<h3>{{task.taskName}}</h3> <h3>{{task.taskName}}</h3>

View File

@ -1,6 +1,9 @@
import {Component, EventEmitter, Input, Output} from '@angular/core'; import {Component, EventEmitter, Input, Output} from '@angular/core';
import {BasicScheduleEntityInfo, ScheduleInfo, ScheduleService, TaskOverviewInfo, TaskService} from "../../../api"; import {BasicScheduleEntityInfo, ScheduleInfo, ScheduleService, TaskOverviewInfo, TaskService} from "../../../api";
import {MatSnackBar} from "@angular/material/snack-bar"; import {MatSnackBar} from "@angular/material/snack-bar";
import {TaskEditorData} from "../../tasks/task-editor/TaskEditorData";
import {TaskEditorComponent} from "../../tasks/task-editor/task-editor.component";
import {MatDialog} from "@angular/material/dialog";
@Component({ @Component({
selector: 'app-task-overview', selector: 'app-task-overview',
@ -16,7 +19,8 @@ export class TaskOverviewComponent {
constructor(private scheduleService: ScheduleService, constructor(private scheduleService: ScheduleService,
private snackbar: MatSnackBar, private snackbar: MatSnackBar,
private taskService: TaskService) { private taskService: TaskService,
private dialog: MatDialog) {
} }
startTaskNow(task: TaskOverviewInfo) { startTaskNow(task: TaskOverviewInfo) {
@ -55,4 +59,24 @@ export class TaskOverviewComponent {
} }
}) })
} }
openTaskCreation() {
const editorData: TaskEditorData = {
task: undefined,
taskgroupID: this.taskgroupID!
}
const dialogRef = this.dialog.open(TaskEditorComponent, {data: editorData, width: "600px"})
dialogRef.afterClosed().subscribe(res => {
if(res != undefined) {
this.tasks.push({
taskID: res.taskID,
eta: res.eta,
limit: res.deadline,
taskName: res.taskName,
activeTime: 0,
overdue: res.overdue
})
}
})
}
} }