Adapt datetime-picker
All checks were successful
Java CI with Maven / build (push) Successful in 45s

This commit is contained in:
Sebastian Böckelmann 2023-11-12 11:12:47 +01:00
parent f271b59b8e
commit 48f162ce0b
2 changed files with 15 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import {Component, EventEmitter, Output, ViewChild} from "@angular/core"; import {Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild} from "@angular/core";
import {MatDatepicker} from "@angular/material/datepicker"; import {MatDatepicker} from "@angular/material/datepicker";
import {NgxMaterialTimepickerComponent, NgxMaterialTimepickerToggleComponent} from "ngx-material-timepicker"; import {NgxMaterialTimepickerComponent, NgxMaterialTimepickerToggleComponent} from "ngx-material-timepicker";
import {FormControl, Validators} from "@angular/forms"; import {FormControl, Validators} from "@angular/forms";
@ -8,11 +8,13 @@ import {FormControl, Validators} from "@angular/forms";
templateUrl: './date-time-picker.component.html', templateUrl: './date-time-picker.component.html',
styleUrls: ['./date-time-picker.component.css'] styleUrls: ['./date-time-picker.component.css']
}) })
export class DateTimePickerComponent { export class DateTimePickerComponent implements OnInit, OnChanges{
@ViewChild('picker') picker?: MatDatepicker<any>; @ViewChild('picker') picker?: MatDatepicker<any>;
@ViewChild('toggleTimepicker') toggleTimepicker?: NgxMaterialTimepickerComponent @ViewChild('toggleTimepicker') toggleTimepicker?: NgxMaterialTimepickerComponent
@Output('onTimeSet') timeSet: EventEmitter<Date> = new EventEmitter<Date>(); @Output('onTimeSet') timeSet: EventEmitter<Date> = new EventEmitter<Date>();
@Input('date') date: Date | undefined
dateControl: FormControl = new FormControl('', [Validators.required]) dateControl: FormControl = new FormControl('', [Validators.required])
timeControl: FormControl = new FormControl('', [Validators.required]) timeControl: FormControl = new FormControl('', [Validators.required])
constructor() { } constructor() { }
@ -21,6 +23,12 @@ export class DateTimePickerComponent {
} }
ngOnChanges() {
if(this.date != undefined) {
this.setDateTime(this.date);
}
}
setDateTime(date: Date) { setDateTime(date: Date) {
console.log(date) console.log(date)
this.dateControl.setValue(date); this.dateControl.setValue(date);

View File

@ -2,7 +2,7 @@ import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges
import {FormControl, Validators} from "@angular/forms"; import {FormControl, Validators} from "@angular/forms";
import { import {
BasicScheduleEntityInfo, BasicScheduleEntityInfo,
BasicScheduleInfo, BasicScheduleInfo, ScheduleInfo,
ScheduleService, ScheduleService,
TaskEntityInfo, TaskEntityInfo,
TaskgroupEntityInfo TaskgroupEntityInfo
@ -20,7 +20,7 @@ export class BasicSchedulerComponent implements OnChanges{
dateCtrl: FormControl = new FormControl('', [Validators.required]) dateCtrl: FormControl = new FormControl('', [Validators.required])
@Input('taskgroup') taskgroup: TaskgroupEntityInfo | undefined @Input('taskgroup') taskgroup: TaskgroupEntityInfo | undefined
@Input('task') task: TaskEntityInfo | undefined @Input('task') task: TaskEntityInfo | undefined
@Input('scheduleInfo') scheduleEntityInfo: BasicScheduleEntityInfo | undefined @Input('scheduleInfo') scheduleEntityInfo: ScheduleInfo | undefined
@Output('onSchedule') scheduleEmitter: EventEmitter<BasicScheduleEntityInfo> = new EventEmitter<BasicScheduleEntityInfo>(); @Output('onSchedule') scheduleEmitter: EventEmitter<BasicScheduleEntityInfo> = new EventEmitter<BasicScheduleEntityInfo>();
constructor(private scheduleService: ScheduleService, constructor(private scheduleService: ScheduleService,
@ -72,13 +72,10 @@ export class BasicSchedulerComponent implements OnChanges{
ngOnChanges(): void { ngOnChanges(): void {
if(this.scheduleEntityInfo != undefined) { if(this.scheduleEntityInfo != undefined) {
this.dateCtrl.setValue(this.scheduleEntityInfo!.scheduleID) const schedule = this.scheduleEntityInfo as BasicScheduleInfo
this.dateCtrl.setValue(schedule.scheduleDate)
} }
} }
setEditedBasicSchedule(basicSchedule: BasicScheduleEntityInfo) {
this.dateCtrl.setValue(basicSchedule.scheduleDate)
this.scheduleEntityInfo = basicSchedule;
console.log(this.dateCtrl.value)
}
} }