|
|
@@ -0,0 +1,61 @@
|
|
|
+import { Component, Input } from '@angular/core';
|
|
|
+import { Router } from '@angular/router';
|
|
|
+import { EventsApiService } from 'src/app/events-api.service';
|
|
|
+import { GroupEvent } from '../group-event';
|
|
|
+
|
|
|
+@Component({
|
|
|
+ selector: 'app-event-edit',
|
|
|
+ templateUrl: './event-edit.component.html',
|
|
|
+ styleUrls: ['./event-edit.component.scss']
|
|
|
+})
|
|
|
+export class EventEditComponent {
|
|
|
+ @Input()
|
|
|
+ public eventId: string = '';
|
|
|
+ @Input()
|
|
|
+ public isCreateMode: boolean = false;
|
|
|
+
|
|
|
+ public event: GroupEvent | null = null;
|
|
|
+ public startDate: Date | null = null;
|
|
|
+ public startTime: string = '';
|
|
|
+
|
|
|
+ public constructor(
|
|
|
+ private readonly eventsApi: EventsApiService,
|
|
|
+ private readonly router: Router
|
|
|
+ ) { }
|
|
|
+
|
|
|
+ public ngOnInit(): void {
|
|
|
+ if (this.isCreateMode) {
|
|
|
+ this.event = new GroupEvent();
|
|
|
+ }
|
|
|
+ // this.eventsApi.getTrack(this.trackId).then(track => {
|
|
|
+ // this.track = track;
|
|
|
+ // });
|
|
|
+ }
|
|
|
+
|
|
|
+ public updateEvent(event: SubmitEvent): void {
|
|
|
+ console.log({ date: this.startDate, time: this.startTime});
|
|
|
+ const match = this.startTime.match(/(\d{1,2}):(\d{1,2})/);
|
|
|
+ if (this.startDate && match) {
|
|
|
+ this.startDate.setHours(parseInt(match[1]));
|
|
|
+ this.startDate.setMinutes(parseInt(match[2]));
|
|
|
+ this.event!.startTime = this.startDate;
|
|
|
+ }
|
|
|
+ console.log(this.event);
|
|
|
+ if (this.isCreateMode) {
|
|
|
+ this.eventsApi.createEvent(this.event!);
|
|
|
+ }
|
|
|
+ // if (this.track) {
|
|
|
+ // this.tracksApi.updateTrack(this.track).then(result => {
|
|
|
+ // this.track = result;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ }
|
|
|
+
|
|
|
+ public deleteEvent(): void {
|
|
|
+ // if (this.track) {
|
|
|
+ // this.tracksApi.deleteTrack(this.track).then(() => {
|
|
|
+ // this.router.navigateByUrl("/tracks");
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ }
|
|
|
+}
|