Dostępność testu w grupie o określonym czasie

This commit is contained in:
s416122 2020-01-13 15:38:54 +01:00
parent cd33d8d7a9
commit 0dfe602ac7

View File

@ -47,6 +47,7 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
cellRenderer: this.customCellRendererFunc cellRenderer: this.customCellRendererFunc
} }
]; ];
timetest: number;
constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router, constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router,
public snackBar: MatSnackBar) { } public snackBar: MatSnackBar) { }
@ -120,8 +121,14 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
public onRowClicked(e) { public onRowClicked(e) {
if (e.event.target !== undefined) { if (e.event.target !== undefined) {
const data = e.data; const data = e.data;
const now1 = new Date();
const now = now1.getTime();
const actionType = e.event.target.getAttribute('data-action-type'); 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) { switch (actionType) {
case 'remove': case 'remove':
return this.onActionRemoveClick(e); return this.onActionRemoveClick(e);
@ -130,7 +137,23 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
default: default:
this.goTo(e); 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) { goTo(event: RowDoubleClickedEvent) {
@ -283,6 +306,7 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
this.data = data; this.data = data;
data.forEach(x => { data.forEach(x => {
const temp = new Date(x['dateFrom']); const temp = new Date(x['dateFrom']);
const tempstop = new Date(x['dateTo']);
x['startDate'] = ''; x['startDate'] = '';
const hours = temp.getHours(); const hours = temp.getHours();
const minutes = temp.getMinutes(); const minutes = temp.getMinutes();