From 0dfe602ac7d0871dc02edf40c4db1001baa011bf Mon Sep 17 00:00:00 2001 From: s416122 Date: Mon, 13 Jan 2020 15:38:54 +0100 Subject: [PATCH] =?UTF-8?q?Dost=C4=99pno=C5=9B=C4=87=20testu=20w=20grupie?= =?UTF-8?q?=20o=20okre=C5=9Blonym=20czasie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../group-details/group-details.component.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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();