Skip to content

Commit

Permalink
Fix submission opening time bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dlimyy committed Sep 6, 2023
1 parent c6e3b18 commit 2051daa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ <h5>Or</h5>
</div>
<div class="row text-center align-items-center">
<div id="submission-start-date" class="col-md-7 col-xs-center">
<tm-datepicker [isDisabled]="!model.isEditable" (dateChangeCallback)="triggerModelChange('submissionStartDate', $event)"
<tm-datepicker [isDisabled]="!model.isEditable" (dateChangeCallback)="triggerSubmissionOpeningDateModelChange('submissionStartDate', $event)"
[minDate]="minDateForSubmissionStart" [maxDate]="maxDateForSubmissionStart"
[date]="model.submissionStartDate"></tm-datepicker>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,35 @@ export class SessionEditFormComponent {
});
}

/**
* Triggers the change of the model when the submission opening date changes.
*/
triggerSubmissionOpeningDateModelChange(field: string, date: DateFormat): void {
const minDate: DateFormat = this.minDateForSubmissionStart;
if (JSON.stringify(minDate) === JSON.stringify(date)) {
const minTime: TimeFormat = this.minTimeForSubmissionStart;
this.configureSubmissionOpeningTime(minTime);
this.model.submissionStartTime = minTime;
}
this.modelChange.emit({
...this.model,
[field]: date,
});
}

/**
* Configures the time for the submission opening time.
*/
configureSubmissionOpeningTime(time : TimeFormat) : void {
if (time.hour < 24 && time.minute > 0) {
// Case where minutes is not 0 since the earliest time with 0 minutes is the hour before
time.hour += 1;
time.minute = 0;
} else if (time.hour === 23 && time.minute > 0) {
time.minute = 59;
}
}

/**
* Handles course Id change event.
*
Expand Down

0 comments on commit 2051daa

Please sign in to comment.