Skip to content

Commit

Permalink
CSCEXAM-1204 Fix min date mechanism for date-time-picker
Browse files Browse the repository at this point in the history
- Use it for restricting examination event dates
  • Loading branch information
lupari committed Aug 15, 2024
1 parent 9e02d6a commit 7e42d7c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h1 class="xm-modal-title">
[minuteStep]="15"
[readonly]="true"
[initialTime]="start()"
[minDate]="examMinDate"
[maxDate]="examMaxDate"
(updated)="onStartDateChange($event)"
autofocus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class ExaminationEventDialogComponent implements OnInit {
@Input() config?: ExaminationEventConfiguration;
@Input() maintenancePeriods: MaintenancePeriod[] = [];
@Input() requiresPassword = false;
@Input() examMinDate = '';
@Input() examMaxDate = '';
start = signal(new Date(new Date().getTime() + 60 * 1000));
description = signal('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export class ExamPublicationComponent implements OnInit {
size: 'lg',
});
modalRef.componentInstance.requiresPassword = this.exam.implementation === 'CLIENT_AUTH';
modalRef.componentInstance.examMinDate = this.exam.periodStart;
modalRef.componentInstance.examMaxDate = this.exam.periodEnd;
modalRef.componentInstance.maintenancePeriods = this.maintenancePeriods;
modalRef.componentInstance.examId = this.exam.id;
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/shared/date/date-time-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export class DateTimePickerComponent implements OnInit, OnChanges {
@Input() minuteStep = 0;
@Input() disabled = false;
@Input() readonly = false;
@Input() minDate = new Date().toISOString();
@Input() maxDate?: string;
@Input() disableDate?: boolean = false;
@Input() disableTime?: boolean = false;
@Output() updated = new EventEmitter<{ date: Date }>();

date: Date = new Date();
time!: { hour: number; minute: number; second: number; millisecond?: number };
minDate?: string;

ngOnInit() {
const now = new Date();
Expand All @@ -70,7 +70,6 @@ export class DateTimePickerComponent implements OnInit, OnChanges {
if (this.initialTime) {
this.setDateTime(this.initialTime);
}
this.minDate = now.toISOString();
}

ngOnChanges() {
Expand Down

0 comments on commit 7e42d7c

Please sign in to comment.