diff --git a/backend/.idea/workspace.xml b/backend/.idea/workspace.xml index 93cfbcd..eea8ce0 100644 --- a/backend/.idea/workspace.xml +++ b/backend/.idea/workspace.xml @@ -5,23 +5,9 @@ - - - - - - - - - - - - - - - + diff --git a/backend/src/main/java/core/services/TaskScheduleService.java b/backend/src/main/java/core/services/TaskScheduleService.java index e62d68a..b1fe601 100644 --- a/backend/src/main/java/core/services/TaskScheduleService.java +++ b/backend/src/main/java/core/services/TaskScheduleService.java @@ -200,14 +200,17 @@ public class TaskScheduleService { basicTaskSchedule.setFinishedTime(timeReference); basicTaskScheduleRepository.save(basicTaskSchedule); taskRepository.save(task); - new ServiceResult<>(minutesSpent); + return new ServiceResult<>(minutesSpent); } } case PLANNED -> { //Does not make sense until advanced schedule/moderate schedule is implemented return new ServiceResult<>(0); } + default -> { + throw new RuntimeException("INVALID MODE"); + } } - throw new RuntimeException("INVALID MODE"); + } } diff --git a/frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts b/frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts index c610b42..5cc7abf 100644 --- a/frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts +++ b/frontend/src/app/dashboard/forgotten-task-start-dialog/forgotten-task-start-dialog.component.ts @@ -1,10 +1,11 @@ import {Component, OnInit} from '@angular/core'; -import {ScheduleService, TaskService, TaskShortInfo} from "../../../api"; +import {ForgottenActivityRequest, ScheduleService, TaskService, TaskShortInfo} from "../../../api"; import {MatSnackBar} from "@angular/material/snack-bar"; import {DialogRef} from "@angular/cdk/dialog"; import {MatDialogRef} from "@angular/material/dialog"; import {filter, map, Observable, startWith} from "rxjs"; import {FormControl} from "@angular/forms"; +import ModeEnum = ForgottenActivityRequest.ModeEnum; @Component({ selector: 'app-forgotten-task-start-dialog', @@ -53,7 +54,7 @@ export class ForgottenTaskStartDialogComponent implements OnInit{ const task = this.tasks.find(task => task.taskName === this.myControl.value); if(task != undefined) { this.scheduleService.schedulesTaskIDForgottenPost(task.taskID, { - mode: "MANUAL", + mode: this.determineRegisterMode(), minutesSpent: this.minutesSpentControl.value }).subscribe({ next: resp => { @@ -74,7 +75,13 @@ export class ForgottenTaskStartDialogComponent implements OnInit{ } } - private determineRegisterMode(): string { - return "MANUAL"; + private determineRegisterMode(): ModeEnum { + if(this.lastSchedule) { + return "LAST"; + } else if(this.plannedSchedule) { + return "PLANNED"; + } else { + return "MANUAL"; + } } }