issue-106 #107

Merged
sebastian merged 18 commits from issue-106 into master 2024-03-17 09:17:11 +01:00
8 changed files with 47 additions and 62 deletions
Showing only changes of commit f080c6db52 - Show all commits

View File

@ -16,18 +16,9 @@ export interface TaskRepeatDayInfo {
* number repeating days
*/
offset: number;
deadlineStrategy: TaskRepeatDayInfo.DeadlineStrategyEnum;
/**
* Date until the tasks repeat
*/
endingDate: string;
}
export namespace TaskRepeatDayInfo {
export type DeadlineStrategyEnum = 'DEADLINE_EQUAL_START' | 'DEADLINE_FIT_START';
export const DeadlineStrategyEnum = {
EqualStart: 'DEADLINE_EQUAL_START' as DeadlineStrategyEnum,
FitStart: 'DEADLINE_FIT_START' as DeadlineStrategyEnum
};
}

View File

@ -20,5 +20,22 @@ export interface TaskRepeatWeekDayInfo {
* internal identifier of task
*/
taskID: number;
/**
* day of week
*/
dayOfWeek: TaskRepeatWeekDayInfo.DayOfWeekEnum;
}
export namespace TaskRepeatWeekDayInfo {
export type DayOfWeekEnum = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
export const DayOfWeekEnum = {
Monday: 'MONDAY' as DayOfWeekEnum,
Tuesday: 'TUESDAY' as DayOfWeekEnum,
Wednesday: 'WEDNESDAY' as DayOfWeekEnum,
Thursday: 'THURSDAY' as DayOfWeekEnum,
Friday: 'FRIDAY' as DayOfWeekEnum,
Saturday: 'SATURDAY' as DayOfWeekEnum,
Sunday: 'SUNDAY' as DayOfWeekEnum
};
}

View File

@ -13,19 +13,10 @@ import { TaskRepeatWeekDayInfo } from './taskRepeatWeekDayInfo';
export interface TaskRepeatWeekInfo {
deadlineStrategy: TaskRepeatWeekInfo.DeadlineStrategyEnum;
/**
* Date until the tasks repeat
*/
endDate: string;
weekDayInfos: Array<TaskRepeatWeekDayInfo>;
}
export namespace TaskRepeatWeekInfo {
export type DeadlineStrategyEnum = 'DEADLINE_EQUAL_START' | 'DEADLINE_FIT_START';
export const DeadlineStrategyEnum = {
EqualStart: 'DEADLINE_EQUAL_START' as DeadlineStrategyEnum,
FitStart: 'DEADLINE_FIT_START' as DeadlineStrategyEnum
};
}

View File

@ -7,13 +7,6 @@
<mat-label>Offset</mat-label>
<input matInput formControlName="offsetCtrl" type="number" (keypress)="($event.charCode >= 48 && $event.charCode < 58)">
</mat-form-field>
<mat-form-field appearance="outline" class="long-form">
<mat-label>Deadline Strategy</mat-label>
<mat-select formControlName="deadlineStrategyCtrl">
<mat-option value="DEADLINE_FIT_START">Fit Next Start</mat-option>
<mat-option value="DEADLINE_EQUAL_START">Equal Same Start</mat-option>
</mat-select>
</mat-form-field>
<div>
<button mat-raised-button color="primary" matStepperNext>Next</button>
</div>

View File

@ -2,7 +2,6 @@ import {Component, Inject} from '@angular/core';
import {FormBuilder, Validators} from "@angular/forms";
import {TaskEntityInfo, TaskRepeatDayInfo, TaskseriesService} from "../../../api";
import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import DeadlineStrategyEnum = TaskRepeatDayInfo.DeadlineStrategyEnum;
import * as moment from "moment";
@ -15,7 +14,6 @@ export class TaskSeriesCreatorComponent {
dailyFormGroup = this._formBuilder.group({
offsetCtrl: ['', Validators.required],
deadlineStrategyCtrl: ['', Validators.required]
})
endDateFormGroup = this._formBuilder.group({
@ -32,7 +30,6 @@ export class TaskSeriesCreatorComponent {
save() {
this.taskSeriesService.tasksTaskIDTaskseriesDailyPost(this.task.taskID,{
offset: Number(this.dailyFormGroup.get('offsetCtrl')!.value!),
deadlineStrategy: this.convertDeadlineStrategyCtrlToDeadlineEnum(),
endingDate: moment( this.endDateFormGroup.get('endDateCtrl')!.value!).format('YYYY-MM-DDTHH:mm:ss.SSSZ')
}).subscribe({
next: resp => {
@ -40,13 +37,4 @@ export class TaskSeriesCreatorComponent {
}
})
}
convertDeadlineStrategyCtrlToDeadlineEnum() {
const deadlineStrategy = this.dailyFormGroup.get('deadlineStrategyCtrl')!.value;
if(deadlineStrategy === DeadlineStrategyEnum.EqualStart) {
return DeadlineStrategyEnum.EqualStart;
} else {
return DeadlineStrategyEnum.FitStart;
}
}
}

View File

@ -24,14 +24,6 @@
</div>
</mat-accordion>
</div>
<mat-form-field appearance="outline" class="long-form" id="deadline-strategy-form">
<mat-label>Deadline-Strategy</mat-label>
<mat-select formControlName="deadlineStrategyCtrl">
<mat-option *ngFor="let deadlineStrategy of availableDeadlineStrategys" [value]="deadlineStrategy">
{{deadlineStrategy}}
</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="outline" class="long-form" id="endDate-form">
<mat-label>Ending Date</mat-label>

View File

@ -3,7 +3,7 @@ import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";
import {TaskEntityInfo, TaskRepeatDayInfo, TaskRepeatWeekDayInfo, TaskseriesService} from "../../../api";
import * as moment from "moment";
import {FormArray, FormBuilder, FormGroup, Validators} from "@angular/forms";
import DeadlineStrategyEnum = TaskRepeatDayInfo.DeadlineStrategyEnum;
import DayOfWeekEnum = TaskRepeatWeekDayInfo.DayOfWeekEnum;
@Component({
@ -14,7 +14,6 @@ import DeadlineStrategyEnum = TaskRepeatDayInfo.DeadlineStrategyEnum;
export class TaskWeeklySeriesCreatorComponent implements OnInit{
repeatingOffsetForm: FormGroup | undefined
availableDeadlineStrategys: DeadlineStrategyEnum[] = ["DEADLINE_EQUAL_START", "DEADLINE_FIT_START"]
constructor(private dialogRef: MatDialogRef<TaskWeeklySeriesCreatorComponent>,
private taskRepeatingService: TaskseriesService,
@ -27,7 +26,6 @@ export class TaskWeeklySeriesCreatorComponent implements OnInit{
offsets: this.formbuilder.array(this.tasks.map(task => this.formbuilder.group({
offsetCtrl: ['', [Validators.required, Validators.min(1)]]
}))),
deadlineStrategyCtrl: ['', Validators.required],
endingDateCtrl: ['', Validators.required]
})
@ -62,12 +60,12 @@ export class TaskWeeklySeriesCreatorComponent implements OnInit{
for(let i=0; i<formArrayValues.length; i++) {
weekDayInfos.push({
taskID: this.tasks[i].taskID,
offset: Number(formArrayValues[i].offsetCtrl) * 7
offset: Number(formArrayValues[i].offsetCtrl) * 7,
dayOfWeek: this.getDayOfWeekFromTask(this.tasks[i])!
})
}
this.taskRepeatingService.tasksTaskseriesWeeklyPost({
deadlineStrategy: this.repeatingOffsetForm!.controls['deadlineStrategyCtrl']!.value!,
endDate: moment(this.repeatingOffsetForm!.controls['endingDateCtrl']!.value!).format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
weekDayInfos: weekDayInfos
}).subscribe({
@ -77,6 +75,21 @@ export class TaskWeeklySeriesCreatorComponent implements OnInit{
})
}
private getDayOfWeekFromTask(task: TaskEntityInfo): DayOfWeekEnum | undefined {
const weekday = moment(task.startDate).isoWeekday();
switch (weekday) {
case 1: return DayOfWeekEnum.Monday;
case 2: return DayOfWeekEnum.Tuesday;
case 3: return DayOfWeekEnum.Wednesday;
case 4: return DayOfWeekEnum.Thursday;
case 5: return DayOfWeekEnum.Friday;
case 6: return DayOfWeekEnum.Saturday;
case 7: return DayOfWeekEnum.Sunday;
default: return undefined;
}
}
cancel() {
this.dialogRef.close(false);
}

View File

@ -2963,7 +2963,6 @@ components:
TaskRepeatDayInfo:
required:
- offset
- deadlineStrategy
- endingDate
additionalProperties: false
properties:
@ -2972,11 +2971,6 @@ components:
description: number repeating days
example: 7
minimum: 1
deadlineStrategy:
type: string
enum:
- DEADLINE_EQUAL_START
- DEADLINE_FIT_START
endingDate:
type: string
format: date
@ -2985,6 +2979,7 @@ components:
required:
- offset
- taskID
- dayOfWeek
additionalProperties: false
properties:
offset:
@ -2996,18 +2991,23 @@ components:
type: number
description: internal identifier of task
example: 1
dayOfWeek:
type: string
description: day of week
enum:
- MONDAY
- TUESDAY
- WEDNESDAY
- THURSDAY
- FRIDAY
- SATURDAY
- SUNDAY
TaskRepeatWeekInfo:
required:
- weekDayInfos
- deadlineStrategy
- endDate
additionalProperties: false
properties:
deadlineStrategy:
type: string
enum:
- DEADLINE_EQUAL_START
- DEADLINE_FIT_START
endDate:
type: string
format: date