diff --git a/FrontEnd/src/app/groups/group-details/group-details.component.ts b/FrontEnd/src/app/groups/group-details/group-details.component.ts index 2dd96c6..11789dd 100644 --- a/FrontEnd/src/app/groups/group-details/group-details.component.ts +++ b/FrontEnd/src/app/groups/group-details/group-details.component.ts @@ -47,6 +47,7 @@ export class GroupDetailsComponent implements OnInit, OnDestroy { cellRenderer: this.customCellRendererFunc } ]; + timetest: number; constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router, public snackBar: MatSnackBar) { } @@ -120,8 +121,14 @@ export class GroupDetailsComponent implements OnInit, OnDestroy { public onRowClicked(e) { if (e.event.target !== undefined) { const data = e.data; + const now1 = new Date(); + const now = now1.getTime(); const actionType = e.event.target.getAttribute('data-action-type'); - + const temp = new Date(data['dateFrom']); + const timetest = temp.getTime(); + const tempstop = new Date(data['dateTo']); + const timeteststop = tempstop.getTime(); + if (timetest < now && now < timeteststop ) { switch (actionType) { case 'remove': return this.onActionRemoveClick(e); @@ -130,7 +137,23 @@ export class GroupDetailsComponent implements OnInit, OnDestroy { default: this.goTo(e); } + } else { + switch (actionType) { + case 'remove': + return this.onActionRemoveClick(e); + case 'edit': + return this.showAvailabilityDialog(e.data); + default: + this.noTime(); + } } + + } + } + + noTime() { + this.snackBar.open('Test jest jeszcze nieaktywny.', null, + { duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] }); } goTo(event: RowDoubleClickedEvent) { @@ -283,6 +306,7 @@ export class GroupDetailsComponent implements OnInit, OnDestroy { this.data = data; data.forEach(x => { const temp = new Date(x['dateFrom']); + const tempstop = new Date(x['dateTo']); x['startDate'] = ''; const hours = temp.getHours(); const minutes = temp.getMinutes();